Skip to content

ADFA-2786 | Harden structure view drawing#1360

Open
jatezzz wants to merge 1 commit into
stagefrom
fix/ADFA-2786-harden-structure-view-drawing
Open

ADFA-2786 | Harden structure view drawing#1360
jatezzz wants to merge 1 commit into
stagefrom
fix/ADFA-2786-harden-structure-view-drawing

Conversation

@jatezzz
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz commented Jun 2, 2026

Description

This PR hardens StructureView.dispatchDraw() to avoid unsafe assumptions while drawing the LayoutEditor structure connector lines.

The method now skips entries when the mapped view or expected parent hierarchy is not available, instead of directly accessing or casting parent-chain values during the draw cycle.

This helps prevent drawing-related crashes if the structure view contains stale, detached, or partially unavailable rows.

Details

No UI behavior changes are expected.

Screen.Recording.2026-06-02.at.12.37.30.PM.mov

Ticket

ADFA-2786

Observation

The original Sentry crash path is not currently reproducible in stage, but this change reduces a remaining latent risk in nearby drawing code by avoiding direct parent-chain casts inside dispatchDraw().

Avoid unsafe parent-chain access while rendering structure connectors
@jatezzz jatezzz requested review from a team and Daniel-ADFA June 2, 2026 17:46
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7383885a-c7f1-49e1-8dcd-f4d47c29acc5

📥 Commits

Reviewing files that changed from the base of the PR and between 1793332 and d42dab5.

📒 Files selected for processing (1)
  • layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/StructureView.kt

📝 Walkthrough

Release Notes

Changes

  • Hardened StructureView.dispatchDraw() with null-safe lookup logic — The method now safely handles missing view mappings and parent hierarchy references during the structure connector line drawing cycle. Instead of using unsafe casts that could crash, the method now uses safe casts (as?) and skips drawing for unavailable entries.
  • Improved resilience for stale or detached rows — The drawing method will gracefully skip processing when mapped views or expected parent chains are not available, preventing crashes when the structure view contains detached or partially unavailable rows.

Benefits

  • Eliminates potential ClassCastException crashes that could occur when the parent hierarchy is not of the expected ViewGroup type.
  • Reduces latent risk from direct parent-chain casting operations during the draw cycle.
  • No UI behavior changes—only internal robustness improvements.

Notes

  • The original Sentry crash path associated with ADFA-2786 is not currently reproducible in stage; this change provides defensive protection against similar issues.
  • No exported or public API changes.

Walkthrough

StructureView.kt's dispatchDraw method adopts null-safe view and parent resolution across three code paths: the main mapping loop now skips entries with missing views or parents; the TextInputLayout drawing branch handles absent parent hierarchy gracefully; and the generic container branch similarly uses safe casts instead of assertions.

Changes

Null-safe parent resolution in dispatchDraw

Layer / File(s) Summary
Null-safe view and parent resolution
layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/StructureView.kt
Main loop retrieves mapped views via nullable lookup and derives parent with safe cast, skipping missing entries. TextInputLayout and generic container drawing branches replace direct parent.parent as ViewGroup casts with safe-cast checks, continuing when the parent hierarchy is absent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • Daniel-ADFA

Poem

🐰 A cast that crashes, now handles grace,
Three branches tamed with null-safe pace,
No more assertions, just a careful peek,
Safe unboxing is the style we seek!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: hardening the structure view drawing logic to handle unsafe assumptions more safely.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of the null-safe lookup logic changes and the rationale for preventing drawing-related crashes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-2786-harden-structure-view-drawing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants