Repository navigation
refactor(ui): split chat state container - #113780
Conversation
7683e6d to
20e405a
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 1:58 PM ET / 17:58 UTC. ClawSweeper reviewWhat this changesThis PR splits OpenClaw Control UI chat state responsibilities—routing, refreshes, page setup, Gateway-event reconciliation, rendering, and lifecycle control—into focused modules while retaining Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 5 items remain Keep this PR open for maintainer review. It is a broad, behavior-preserving Control UI refactor with substantial automated validation, but its protected Priority: P3 Review scores
Verification
How this fits togetherThe Control UI chat page receives route changes and Gateway events, restores composer and session state, reconciles queued sends and streamed responses, then schedules Lit rendering. This refactor reorganizes that orchestration without changing the public chat-page facade used by existing callers. flowchart LR
A[Chat route and composer state] --> C[Chat state facade]
B[Gateway session and run events] --> C
C --> D[Route, refresh, page, and event modules]
D --> E[Chat state host]
E --> F[Lifecycle and render controller]
F --> G[Control UI chat page]
D --> H[Queue and session reconciliation]
Decision needed
Why: The Before merge
Agent review detailsSecurityNone. PR surfaceSource -25, Other -1. Total -26 across 9 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Land only after the current-base review confirms the facade preserves all existing chat lifecycle contracts and the remaining required CI checks finish successfully. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors existing Control UI internals rather than fixing a separately reported user-facing defect. The supplied validation names focused chat-state and chat-send tests as the relevant behavioral coverage. Is this the best way to solve the issue? Yes, conditionally: retaining AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0ff2c8203330. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* refactor(ui): split chat state container * refactor(ui): keep lightbox helper private
What Problem This Solves
The Control UI chat state container mixed route/composer restoration, metadata refresh, page construction, Gateway event reconciliation, render scheduling, and Lit controller lifecycle in one 2,091-line module. That made changes to the heavily evolving chat surface harder to review and kept the file on the max-lines baseline.
Why This Change Was Made
Split the container into focused host-contract, route, refresh, page, event, render, and controller modules while keeping
chat-state.tsas the stable facade for existing callers. The refactor preserves current runtime behavior, public facade exports, and lifecycle/invariant comments. This is an AI-assisted maintainer-commissioned refactor.Beyond the split
chatAvatarSourceto its declared null state instead of relying on the final object cast.ChatPageHostcontract for state helpers because every caller already supplies the full host, deleting verbose partial-host signatures that did not protect a real call site.User Impact
No user-visible behavior change. Maintainers get purpose-specific chat state modules, all below 430 lines, and the
ui/src/pages/chat/chat-state.tsmax-lines baseline entry is removed.Evidence
+2066/-2091(net-25); tests+0/-0; baseline+0/-1; total+2066/-2092(net-26).node scripts/run-vitest.mjs ui/src/pages/chat/chat-state.test.ts ui/src/pages/chat/chat-send.test.ts— 2 files, 277 tests passed.node scripts/check-changed.mjs -- config/max-lines-baseline.txt ui/src/pages/chat/chat-state.ts ui/src/pages/chat/chat-state-controller.ts ui/src/pages/chat/chat-state-events.ts ui/src/pages/chat/chat-state-host.ts ui/src/pages/chat/chat-state-page.ts ui/src/pages/chat/chat-state-refresh.ts ui/src/pages/chat/chat-state-render.ts ui/src/pages/chat/chat-state-route.ts— passed on Blacksmith Testboxtbx_01kyd4a8pjsnn7x3mb56n2jctx; includes core-test/UI typechecks, formatting, max-lines ratchet, Control UI i18n, lint, and repository guards.node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json --shell -- "pnpm build"— passed on Blacksmith Testboxtbx_01kyd4temh1c9nf3msb2p990q3; Control UI bundle and performance budgets passed with no ineffective dynamic-import warning.pnpm deadcode:dependencies && pnpm deadcode:exports— passed on Blacksmith Testboxtbx_01kyd5zy4r3se1aefe8efbh085after making the same-module lightbox helper private.30168276275— passed on7683e6d368a42e9f7280471fb654fe0fab3b1e9f; the final rebase is patch-identical andprepare-runaccepted that hosted evidence..agents/skills/autoreview/scripts/autoreview --mode uncommitted --engine codex --model gpt-5.6-sol --thinking high --stream-engine-output— clean, no accepted/actionable findings (0.98 confidence).git diff --check— passed.Bugs Found
None.
Placement Findings
None. The extracted responsibilities remain inside the Control UI chat owner boundary.
Baseline
Removed
ui/src/pages/chat/chat-state.tsfromconfig/max-lines-baseline.txt; every resulting production file is below the max-lines budget.ClawSweeper Rank-up Moves
6f1950ec1a1b1fac6744fc6779aa2c81a1b71217, the focused 277-test proof passed again, and repo-native preparation accepted the patch-identical hosted CI evidence.