Skip to content

refactor(ui): detach chat state ownership from pane controllers - #174021

Merged
steipete merged 3 commits into
mainfrom
solid2/w-idiom-chat-state
Oct 16, 2026
Merged

steipete merged 3 commits into
mainfrom
solid2/w-idiom-chat-state

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The chat state owner is still registered as a pane controller even though it owns synchronous session resources rather than UI presentation.

User Impact

Draft persistence, scrolling, queued-edit recovery, attachment handoff, and late callback cancellation keep their existing behavior. There is no markup, style, route, selector, or lazy-loading change.

Why This Change Was Made

A plain createChatState factory replaces the controller class and registration. Its narrow renderer contract retains requestUpdate and updateComplete, including the existing runtime identity used by opt-in diagnostics. The pane explicitly disposes the owner after composer and attachment handoff; reconnect creates a fresh owner. Persistence flushes before session state is released, and transferred attachment reads retain their new custodian. The enclosing Solid pane owns lifecycle, so this synchronous resource owner needs no additional reactive root or mirrored lifecycle flag.

The shared pane host remains for transcript, progress-card, locale, polling, and subscription controllers owned outside this lane. Removing it also intersects the active presentation port.

Evidence

Proof Result
Codemod dry runs Complete for changed consumers
Open-lane overlap No competing changes in the original ten paths at publication; new E2E path also clear among twelve open Solid PRs
UI typecheck Passed on repaired production code
Chat test-type graph Passed after correcting the new cleanup callback’s return type
State lifecycle 128 cases passed; only two affected cases reran after restoring their dynamic commit getter
Scroll ownership 7 passed on repaired interface
Attachment handoff 24 passed; unchanged custody logic and fixture assertions
Actual mounted pane Regression failed before repair, then passed: runtime owner and native DOM notifications remain distinct; draft/focus behavior stays intact
Scoped lint / format Passed
Production Knip Passed on repaired production code; no new ignores
Independent review Original cutover and repair clean through P2; no actionable findings
Sidebar assignment outcome One changed case passed in 14.69 s; existing public keyboard submenu helper; all assignment/rejection assertions retained
Full CI Passed on final head: all 68 jobs succeeded or were skipped
Strict performance Passed on final head
Visual surface Existing DOM and styling preserved; no visual change

The first full CI run caught an omitted diagnostic contract: E2E’s pane adapter discovers the runtime through its existing notifications. Removing those notifications left private probes such as pane.state undefined, causing hydration and scroll-probe failures. The repair restores notifications at their original admission/commit boundaries through the real renderer; it adds no public state getter, controller registration, or new diagnostic hook. The mounted regression exercises actual production notifications instead of manually supplying one. Existing Solid diagnostics in unchanged background/details views remain unsuppressed.

That run also saw unrelated Codex test-type errors introduced by main cleanup #173951, where three calls retained names whose imports had been aliased. The PR’s original base and head have identical valid source; CI’s advanced main contains the broken source. Main fix 89dbe8fb corrects those exact three calls. The final CI merge includes that fix and passes the type checks.

Final-head performance (621f932) passed: startup JavaScript 339,180 B gzip / 7 requests, startup CSS 38,786 B / 1 request. Chat boot JavaScript 1,654,477 → 1,654,246 B gzip (−231) with 31 requests unchanged; Chat boot CSS 130,736 B gzip / 8 requests, unchanged.

The replacement CI run passed every nonaggregate job except session-owner-assignment.e2e.test.ts > keeps rejected owner assignments visible from the sidebar, retrying a failed header directory. It timed out waiting for “Me” after right-click/hover, before the assignment RPC. The exact case passed on scheduled main and in one local replay, so no inherited-failure claim is made. The outcome scenario now opens the submenu through its existing public keyboard helper and waits for expansion. Dedicated sidebar pointer tests retain hover coverage; all owner selection, RPC, rejection-alert, and avatar assertions remain. The changed case passed once locally; lint, formatting, and fresh isolated review through P2 passed. The timeout was not deterministically reproduced locally. The final full CI run passes the repaired shard and both real-Gateway shards.

Render preparation now runs when Solid renders. A parked pane may allow one already-scheduled producer frame instead of consuming it during a non-rendering host publication. Persistence and scroll ownership are captured at invalidation; hiding the document still cancels stream frames immediately. This bounded scheduling difference adds no observed state-loss path.

Production LOC across the two changed production files: 1,354 → 1,351 (−3). Test/support LOC across ten files: 7,405 → 7,398 (−7). Controller-pattern references 13 → 10; createEffect 0 → 0; untrack 0 → 0; native listener registrations 2 → 2. The class and its controller lifecycle are gone; remaining update calls serve the retained pane renderer. Three scroll flags are one pending intent, preserving force/content-change coalescing.

No dependency change, new dead-code ignore, local E2E battery, or repeated green suite was added. PR CI owns broad and performance proof.

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 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 16, 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-16T09:05:34.045123Z d8da52c 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces the chat state controller with a plain factory whose disposal and render hooks are called by the pane.

Example: Leave Home while report.txt is being prepared, then open the Home dock.

  • Before: The registered controller transfers attachment custody before disconnecting.
  • After: The pane transfers attachment custody before explicitly disposing the state owner, preserving the intended behavior.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful ownership simplification, but the incomplete instrumentation cutover breaks browser validation.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor proof gate; supplied evidence covers owner tests, while browser CI exposes the discovery defect recorded above.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No new user-facing behavior is intended; the change simplifies lifecycle ownership while preserving drafts, attachments, scrolling, and recovery.
Reason: The maintainer-directed change follows the plain synchronous owner contract and reduces production code.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-directed refactor is useful, but removing runtime notifications breaks existing browser-test discovery.

Priority: P2
Reviewed head: eb9a8ab848c840db83e2a59e687df634ec817a0d

Before merge

  • Preserve runtime discovery when removing controller notifications (P2) - Removing notifyRenderLifecycleForTest(this.host, ...) eliminates the only notifications carrying the ChatPaneRuntime object. The remaining Solid lifecycle reports runtime.element, while installControlUiPaneRuntimeTestAdapter registers owners only for non-HTMLElement hosts. Consequently pane.state, pane.chatState, and taskSuggestions are never forwarded. Exact-head CI confirms the consequence: stream reconciliation times out at line 263 waiting for pane.state.chatLoading, and task suggestions reads 0 instead of 1. Preserve runtime registration at the pane/render boundary and cover discovery through the actual mounted path; the adapter unit test currently injects the notification manually and misses this regression.
  • Explain or restore the original intent of Runtime discovery instrumentation - 5dd456a: The Solid pane migration retained private browser probes through runtime-bearing render notifications; this PR removes those notifications without migrating that consumer.

Findings

  • [P2] Preserve runtime discovery when removing controller notifications — ui/src/pages/chat/chat-state-controller.ts:439-441

Provenance

  • Runtime discovery instrumentation changes intended behavior without addressing why it exists (5dd456a: The Solid pane migration retained private browser probes through runtime-bearing render notifications; this PR removes those notifications without migrating that consumer.)

Tests

  • Missing end-to-end proof: The adapted owner tests do not exercise automatic runtime discovery through a mounted pane, which existing browser consumers now fail.
Agent review details

How this fits together

The Control UI chat owner receives session state and composer events, manages persistence and resource cleanup, and requests rendering through the pane.

flowchart LR
  A[Composer and Gateway events] --> B[Chat state factory]
  B --> C[Draft persistence and attachment reads]
  B --> D[Pane renderer contract]
  D --> E[Solid pane rendering]
  E --> F[Commit and disposal hooks]
  F --> B
Loading

Technical review

Best possible solution:

Keep the plain state factory and preserve runtime discovery at the pane/render boundary without restoring controller registration.

Do we have a high-confidence way to reproduce the issue?

Source tracing establishes the missing runtime registration, and exact-head CI annotations show matching undefined-state errors and probe timeouts; no local reproduction was run.

Is this the best way to solve the issue?

The factory and explicit disposal fit the synchronous ownership contract, but the renderer cutover must preserve the existing browser adapter’s runtime identity.

Full review comments:

  • [P2] Preserve runtime discovery when removing controller notifications — ui/src/pages/chat/chat-state-controller.ts:439-441
    Removing notifyRenderLifecycleForTest(this.host, ...) eliminates the only notifications carrying the ChatPaneRuntime object. The remaining Solid lifecycle reports runtime.element, while installControlUiPaneRuntimeTestAdapter registers owners only for non-HTMLElement hosts. Consequently pane.state, pane.chatState, and taskSuggestions are never forwarded. Exact-head CI confirms the consequence: stream reconciliation times out at line 263 waiting for pane.state.chatLoading, and task suggestions reads 0 instead of 1. Preserve runtime registration at the pane/render boundary and cover discovery through the actual mounted path; the adapter unit test currently injects the notification manually and misses this regression.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Chat state ownership keeps the original intent (8b5337c: refactor(ui): split chat state container #113780 split the state container while preserving lifecycle and public facade behavior.)
  • Render preparation scheduling changes intended behavior with a stated reason (08c29eb: Background publications were coalesced while persistence, scrolling, and commit-dependent effects retained their timing; this PR explicitly explains the bounded parked-pane scheduling change.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/test-helpers/control-ui-pane-runtime.test.ts ui/src/pages/chat/chat-state.test.ts --maxWorkers=1
  • pnpm test ui/src/e2e/chat-flow.stream-reconciliation.e2e.test.ts ui/src/e2e/chat-flow.task-suggestions.e2e.test.ts --maxWorkers=1
  • pnpm tsgo:ui
  • git diff --check

What I checked:

PR surface

Source -11, Tests -25. Total -36 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 324 335 -11
Tests 8 90 115 -25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 414 450 -36

Review metrics

Metric Value Why it matters
Production versus test/support LOC Production +324/-335; tests/support +90/-115 Both surfaces shrink while replacing controller lifecycle plumbing.

Labels

Label changes:

  • add P2: The refactor introduces a concrete browser-validation regression with a focused repair.
  • add merge-risk: 🚨 automation: Removing the only runtime-bearing notifications prevents browser probes from discovering pane owners and breaks existing E2E checks.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The refactor introduces a concrete browser-validation regression with a focused repair.
  • merge-risk: 🚨 automation: Removing the only runtime-bearing notifications prevents browser probes from discovering pane owners and breaks existing E2E checks.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 16, 2026, 4:46 AM ET / 08:46 UTC.

@steipete
steipete merged commit 6385bae into main Oct 16, 2026
107 of 108 checks passed
@steipete
steipete deleted the solid2/w-idiom-chat-state branch October 16, 2026 10: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 17, 2026
…claw#174021)

* refactor(ui): detach chat state ownership from pane controllers

* fix(ui): retain chat runtime lifecycle diagnostics

* test(ui): open assignment submenu through its keyboard path
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. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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