Skip to content

refactor(ui): share ref lifetimes and settle menu focus - #181189

Merged
steipete merged 14 commits into
mainfrom
solid2/w-zero-lifecycle
Oct 23, 2026
Merged

steipete merged 14 commits into
mainfrom
solid2/w-zero-lifecycle

Conversation

@steipete

@steipete steipete commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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 elementRef primitive for element registrations and PluginSurface for 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 SessionBody through 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 main bbc1e28e76dfb4d31f63e0ea3640e5a294e7077d, 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.

Check Result
Header-menu parked row 26/26 pass; new real native-menu regression is red on 990eb44, green with the one-condition fix
Palette/input custody 38/38 existing pinned-runtime tests pass
Ref and lazy menu integration 9/9 tests pass; preserved unchanged-source proof
Panel-toggle fixture 7/7 pass, zero unhandled errors; original fixture reproduced seven ownership errors
Hidden-only pagination fixture Both cases pass; controlled child-first ordering fails before query scoping and passes after
Dialog viewport fixture 6/6 WebKit pass; actual iframe-width readiness and platform-native keyboard gesture; original Linux timeout not locally reproduced
UI types, controller guard, whitespace Pass; final test-only repairs also typecheck
Production Knip Pass, no ignores added
Independent review Pass: complete-context review of all 30 original changed files plus focused reviews of the header-menu and three fixture repairs; no actionable P0–P2 findings
Production browser flow Inspected synthetic before/after: sidebar row survives title update; held cold menu shows loading; first-item and End focus; zero page errors
Matched base/head builds Pass: startup −508 B, chat −686 B, New Session −723 B; request counts unchanged
Full CI 39929084044: 45 passed, 25 intentionally skipped; all UI unit, browser E2E, real-Gateway, security, and strict performance checks pass

Earlier 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.

Metric Base Head Delta
Guarded cleanup calls 64 50 −14
Guarded manual imports 65 64 −1
getOwner / runWithOwner 7 / 11 6 / 10 −1 / −1
Production flush 3 0 −3

Touched 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 checkout 419cf0ca345fddb639b10af4e26e400fd2d312d0 has 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.

Lifecycle exact-base before

Lifecycle reviewed-head after

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.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T09:08:13.862495Z c92a86f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This 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.

  • Before: The reported baseline probe retained 2 registrations after replacement and 1 after disposal.
  • After: The shared ref owner retains 1 registration after replacement and 0 after disposal.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful consolidation with production UI evidence and an attributed inherited CI failure, but one source-confirmed keyboard-focus regression remains.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected production before/after captures show the synthetic sidebar and composer menu focused on Manage plugins; the supplied production-run results cover held-import keyboard opening, ready focus, End navigation, and sidebar row retention, supported by the reported baseline/head ref probe and exact-head UI checks.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Rendered-control replacement can leave stale registrations, while duplicated lifecycle wiring makes focus and DOM retention harder to preserve.
Reason: The maintainer-authored direction consolidates existing owners without adding configuration, persistence, or public APIs.

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
Reviewed head: 4fd4a42b909431fe636f4793c2e4fc070e94add9

Before merge

  • Recover focus when a parked header-menu row disappears (P2) - After this menu has opened once, close it and change its props so its previously first row disappears, such as removing the leading pane action while another action remains. Reopening with ArrowDown still lets native admission focus the parked old row synchronously, because setOpen(true) has not committed. Solid then removes that row and focus falls to document.body. The scheduled focusReady rejects this state because openingFocus is the still-connected trigger, leaving the open menu without keyboard focus. Preserve the pre-open synchronous commit or make the handoff recognize the removed initial target without stealing newer focus, and cover the warm-reopen case.

Findings

  • [P2] Recover focus when a parked header-menu row disappears — ui/src/pages/chat/components/chat-header-session-menu.tsx:247-249
Agent review details

How this fits together

Control 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]
Loading

Technical review

Best 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:

  • [P2] Recover focus when a parked header-menu row disappears — ui/src/pages/chat/components/chat-header-session-menu.tsx:247-249
    After this menu has opened once, close it and change its props so its previously first row disappears, such as removing the leading pane action while another action remains. Reopening with ArrowDown still lets native admission focus the parked old row synchronously, because setOpen(true) has not committed. Solid then removes that row and focus falls to document.body. The scheduled focusReady rejects this state because openingFocus is the still-connected trigger, leaving the open menu without keyboard focus. Preserve the pre-open synchronous commit or make the handoff recognize the removed initial target without stealing newer focus, and cover the warm-reopen case.
    Confidence: 0.96
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89a423050f6f.

Provenance checked

  • Shared DOM-ref lifetime keeps the original intent (6a67da3: Provide renderer-owned element registrations and immediate disposal under the existing Solid owner.)
  • Embedded menu-control registration keeps the original intent (d08bb76: Replace DOM discovery with rendering-owner registrations while preserving keyboard navigation and lazy behavior.)
  • File-preview and option-card registrations keeps the original intent (3a70852: Keep actual control refs with their rendering owners and navigate in committed DOM order.)
  • Sidebar plugin fallback keeps the original intent (e80558a: Preserve the single shell-owned sidebar and existing plugin replacement behavior through the Solid migration.)
  • Composer menu cold-import boundary keeps the original intent (353db54: Keep the trigger and native overlay eager while loading entry builders on accepted opening with loading, retry, and focus preservation.)
  • Parked header-menu opening changes intended behavior with a stated reason (5e5ce57: Park closed-menu dependencies and reconcile retained rows before synchronous native admission and initial focus.)
  • Position-rail focus timing changes intended behavior with a stated reason (d6240f0: Commit distant virtualized marker targets before focusing them while keeping transcript reader-position authority unchanged.)
  • Settings health-read lifetime keeps the original intent (f73e63d: Keep health-read presentation at page lifetime while retaining connection-scoped retirement and result checks.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/pages/chat/components/chat-header-session-menu.test.ts ui/src/pages/chat/components/chat-header-session-menu-loading.test.tsx ui/src/pages/chat/components/chat-header-session-menu-mobile.test.tsx
  • pnpm tsgo:ui
  • pnpm check:control-ui-controllers
  • git diff --check
  • Verify warm header-menu reopening in the production browser after removing its previously first or last parked action, preserving newer external focus.

What I checked:

Likely related people:

  • Vyctor H. Brzezowski: Raw commit d84e193 adds ui/src/pages/chat/components/chat-header-session-menu.tsx:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d84e193fcc3b; files: ui/src/pages/chat/components/chat-header-session-menu.tsx)

PR surface

Source -28, Tests +40, Other -20. Total -8 across 34 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 24 292 320 -28
Tests 5 71 31 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 5 0 20 -20
Total 34 363 371 -8

Labels

Label changes:

  • add P2: The useful lifecycle cleanup has a limited keyboard-focus regression on reopening a changed header menu.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The useful lifecycle cleanup has a limited keyboard-focus regression on reopening a changed header menu.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 22, 2026, 11:47 PM ET / October 23, 2026, 03:47 UTC.

@steipete
steipete enabled auto-merge (squash) October 23, 2026 07:02
@steipete
steipete disabled auto-merge October 23, 2026 07:13
@steipete
steipete merged commit 2e6e86c into main Oct 23, 2026
108 of 110 checks passed
@steipete
steipete deleted the solid2/w-zero-lifecycle branch October 23, 2026 09:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
)

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant