Repository navigation
refactor(ui): centralize gateway page lifecycle - #118243
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 1:21 AM ET / 05:21 UTC. ClawSweeper reviewWhat this changesThis PR replaces nine Control UI pages’ separate Gateway subscription, reconnect, and stale-request handling with a shared Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain The shared controller follows the existing connection-epoch contract and the changed pages retain targeted stale-request and source-replacement coverage; no discrete patch defect was found. This PR remains necessary because current Priority: P2 Review scores
Verification
How this fits togetherControl UI data pages consume an application Gateway source that can reconnect or be replaced while a page has requests in flight. The new controller converts Gateway snapshots into a shared connection epoch and then lets each page refresh, clear state, or ignore stale results using that common lifecycle boundary. flowchart LR
A[Application Gateway source] --> B[Gateway snapshot]
B --> C[Gateway page controller]
C --> D[Connection epoch and request scope]
C --> E[Page-specific refresh policy]
D --> F[Data requests and subscriptions]
E --> F
F --> G[Control UI page state]
G --> H[Rendered dashboard page]
Decision needed
Why: The patch is a broad shared availability boundary and is protected with the Before merge
Agent review detailsSecurityNone. PR surfaceSource -144, Tests +224. Total +80 across 21 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical Gateway lifecycle controller, then add a redacted browser recording or runtime trace that visibly exercises a migrated page through same-client reconnect and Gateway-source replacement without stale data winning. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect report: this PR is a refactor. The changed reconnect and source-replacement paths are source-testable, but a high-confidence real browser reproduction/proof has not been supplied in the PR materials. Is this the best way to solve the issue? Yes, conditionally: centralizing the already-established connection-epoch invariant is more maintainable than preserving nine drifting copies, provided browser proof confirms the migrated pages preserve their lifecycle behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 05100271568b. LabelsLabel 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
HistoryReview history (3 earlier review cycles) |
1c397d6 to
538acf4
Compare
|
Land-ready refresh on rebased head The rebase preserves both sides of the overlapping UI work:
Proof:
ClawSweeper's runtime-recording rank-up move is intentionally skipped: this is a behavior-neutral lifecycle refactor, the focused suites directly exercise disconnect/reconnect/source replacement and stale async confirmation, and the full hosted UI matrix passed. |
|
Merged via squash.
|
* refactor(ui): centralize gateway page lifecycle * fix(ui): align gateway controller state types * fix(ui): satisfy lifecycle lint boundaries * fix(ui): keep usage refresh reason private * test(ui): cover usage refresh policy surface
What Problem This Solves
Control UI pages independently owned the same gateway subscription, reconnect identity, request-generation, route-provenance, and initial-load lifecycle. The repeated implementations had already drifted in naming and made same-client reconnect/source-replacement correctness page-specific.
Why This Change Was Made
This promotes the proven Usage page binding design into
GatewayPageController, composed with the existing non-LitcreateGatewayConnectionLifecycleepoch primitive. Nine pages now share the controller: Usage, Nodes, Skills, Tasks, Worktrees, Channels, Cron, Agents, and Plugins.The controller owns exact gateway source binding, separate source/client identity versus connection transitions, request capture/currentness, exact route-data provenance, reusable detach/reattach behavior, and optional focus/visibility activation. Usage keeps its TTL and interrupted-refresh policy page-local. Page-specific identity signals such as channel pairing auth and plugin icon auth remain with their owners.
The migration also replaces Tasks, Cron, Usage, and Sessions scope-observer copies with one persistent
watchAgentScope, moves Nodes' repeated server-field resets onto a connection-owned state object, and removes local agent loading/error mirrors from Skills and Agents.User Impact
No rendering or RPC behavior changes are intended. Reconnects, provider-source replacement, agent scope changes, route preloads, and stale async completions retain their existing behavior through one lifecycle vocabulary. Production code is net 144 lines smaller; tests are counted separately.
Evidence
OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs ui/src/lit/gateway-page-controller.test.ts ui/src/lib/agents/watch-agent-scope.test.ts ui/src/lib/gateway-connection-lifecycle.test.ts ui/src/pages/usage/usage-page.test.ts ui/src/pages/usage/refresh-policy.test.ts ui/src/pages/tasks/tasks-page.test.ts ui/src/pages/worktrees/worktrees-page.test.ts ui/src/pages/nodes/nodes-page.test.ts ui/src/pages/channels/channels-page.test.ts ui/src/pages/cron/cron-page.test.ts ui/src/pages/agents/agents-page.test.ts ui/src/pages/plugins/plugins-page.test.ts ui/src/pages/plugins/plugins-page.routing.test.ts ui/src/pages/sessions/sessions-page.test.ts ui/src/pages/gateway-source-replacement.test.ts— 15 files, 172 tests passed on exact head.git diff --check origin/main...HEAD— passed.oxlinton Nodes and Usage lifecycle surfaces — passed with warnings denied..agents/skills/autoreview/scripts/autoreview --mode uncommitted— final Codex review clean; no accepted/actionable findings.