Repository navigation
refactor(ui): share ref lifetimes and settle menu focus - #181189
Conversation
Use the existing ref and plugin surface owners, replace composer menu loader state with a lazy boundary, and focus committed views without production flush calls. Preserve immediate cleanup for resources admitted before settlement.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs changes before merge. What this changesThis PR shares DOM-ref cleanup, reuses the sidebar plugin renderer, and moves focus work after Solid commits. Example: A mounted view replaces one registered button with another.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-authored PR open: the lifecycle consolidation is useful, but an introduced header-menu focus regression blocks merging. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherControl UI views register rendered controls with shared owners, which provide keyboard-navigation targets and release registrations when views retire. flowchart LR
A[User input] --> B[Control UI views]
B --> C[Shared ref lifetime]
C --> D[DOM control registries]
B --> E[Lazy menu content]
E --> D
D --> F[Focus and disposal]
Technical reviewBest possible solution: Keep the existing-owner consolidation and preserve the header menu's pre-open commit until its deferred handoff correctly recovers focus from a removed parked row. Do we have a high-confidence way to reproduce the issue? Source establishes both the unreleased ref-registration leak and the introduced parked-menu focus failure; this read-only review ran no target code. Is this the best way to solve the issue? Reusing elementRef and PluginSurface is the smallest existing-owner approach, but removing the header's synchronous opening commit requires a complete focus handoff. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 89a423050f6f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -28, Tests +40, Other -20. Total -8 across 34 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 22, 2026, 11:47 PM ET / October 23, 2026, 03:47 UTC. |
|
Merged via squash.
|
) * refactor(ui): share ref lifetimes and settle menu focus Use the existing ref and plugin surface owners, replace composer menu loader state with a lazy boundary, and focus committed views without production flush calls. Preserve immediate cleanup for resources admitted before settlement. * test(ui): keep rail frame fixture in shared helpers * fix(ui): preserve keyed sidebar and tab lifetimes * refactor(ui): settle command palette custody cleanup * fix(ui): restore focus after parked menu rows change * test(ui): own panel-toggle fixture lifetimes * test(ui): scope sidebar pagination failure to its roster * test(ui): wait for delivered dialog viewport changes
What Problem This Solves
Component teardown was scattered across cleanup registrations, the sidebar duplicated fallback rendering, and menu/preview focus paths forced synchronous Solid flushes.
User Impact
Sidebar updates retain their rows and focus, tab labels remain measurable through tooltip changes, and the composer menu loads on demand with keyboard navigation preserved. Host tags, styles, routes, and actions stay intact.
Why This Change Was Made
Use main’s replacement-safe
elementRefprimitive for element registrations andPluginSurfacefor the sidebar fallback. Pair component setup with settled teardown and hand off focus after Solid commits. The composer plus menu owns a lazy component with loading, error, and retry boundaries, preserving its cold-import timing.Immediate cleanup stays where a runtime, request, media lease, or native registration can begin before first settlement. Native/plugin and retained-root owner APIs stay where callbacks require that contract.
Full UI CI caught two defects during development: the sidebar fallback now mounts
SessionBodythrough JSX to retain its owner and DOM, and keyed tab owners retain label registrations through tooltip-wrapper changes. Integration preserves main’s newer command-palette/tab-strip ref arrays and lazy effort picker.Evidence
Final reviewed head:
c92a86ff0f7ea7b3f93b42a8239b84f5f01f36ac. This candidate integrates mainbbc1e28e76dfb4d31f63e0ea3640e5a294e7077d, including the cold tool placeholder repair in #181460. That repair restores the live verb/path/diff while the heavy card renderer loads; its exact original full-CI case passed. The final root addition ties palette custody reset to settled shell lifetime: the shell connects only after settlement, and existing attachment/input handoff coverage remains green.The previous full CI 39922712591 exposed two fixture defects now repaired. Panel-toggle tests constructed two Solid-aware owners outside a Solid root; their seven assertions passed with seven unhandled cleanup errors. Both controllers now have an owned root, and all seven pass without unhandled errors. The hidden-only pagination fixture matched only a cursor, allowing a concurrent chat child-list query to consume its injected failure. A controlled child-first run reproduced CI’s exact nine-request/401-row/no-error signature; scoping interception and waits to the canonical sidebar query passes both existing cases without weakening error, row, or retry assertions. The original CI did not capture full request parameters, so this is controlled reproduction evidence rather than a claim to have observed its request identity.
Both repairs are test-only and independently reviewed. Full CI39926034459 then passed all browser E2E and real-Gateway shards, including pagination and main’s newer mobile-inset repair, but one WebKit unit case retained desktop dialog order after a resize. The test now waits for the test iframe’s actual width after the parent viewport command and uses the existing macOS WebKit Option-Tab convention. All six tests in that file pass locally, with independent review and UI types clean. The original Linux viewport timeout was not reproduced locally; the final full CI run 39929084044 is now green (45 passed, 25 intentionally skipped). No inherited-failure exception is used.
990eb44, green with the one-condition fixEarlier full CI identified and drove repairs to sidebar row ownership, tab-label registrations, and the cold tool placeholder. The original cold-tool failure was not classified as inherited. Review comment #4355412802 also exposed a real parked-header-menu focus gap: native opening focused a row that the parked commit removed. The final head permits the settled handoff to recover body focus while the menu remains open; the native-menu regression fails before the fix and all 26 tests pass after it. A separate mobile sidebar inset assertion now fails on main (6px measured versus an 8px test requirement); the final CI merge includes main’s repair and passes this case.
Measured changes
Guard and LOC rows compare this root PR against integrated main
bbc1e28e. The wider lane has 23 separately merged supporting PRs; these root-only deltas do not claim their work.getOwner/runWithOwnerflushTouched production: 6,056 → 6,030 lines (−26); tests/helpers: 3,333 → 3,410 (+77). Matched final build: startup 314,342 → 313,834 B (7 JS / 1 CSS); chat 1,344,660 → 1,343,974 B (22 JS / 3 CSS); New Session 822,297 → 821,574 B (16 JS / 3 CSS). Both sides use fixed build metadata and the same local machine/toolchain. The final CI merge independently passes strict performance against actual base
b3d46e895b103f8cd54a539595111bb41af7fc05: startup 310,744 → 310,706 B; chat 1,323,010 → 1,322,907 B; New Session 813,615 → 813,411 B, with the same request counts. CI checkout419cf0ca345fddb639b10af4e26e400fd2d312d0has the inspected ordered base/head parents and a tree that reconstructs exactly. The strict performance check passes; its existing largest-CSS warning reports 959 B of hard-cap headroom. No cap or baseline is raised.Before and after
Both inspected captures contain only synthetic session data and preserve the same visible layout and controls. Each passed the row-identity and cold-menu focus checks. Their PNG hashes differ; no byte-identity claim is made. Subsequent integration does not change this visual surface.