Repository navigation
fix(ui): settle mock Gateway session rows on session-only Stop - #160563
Conversation
|
🦞👀 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: needs maintainer review before merge. Reviewed September 28, 2026, 1:56 PM ET / 17:56 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch makes the Control UI mock Gateway commit session Stop results to subsequent session reads and updates browser and fixture regressions for that behavior. Merge readiness✅ Ready for maintainer review Current main still serves stale mock session activity after a session-only Stop. The merged related PR corrected an overlapping browser test, but did not repair the shared fixture. The previous run-targeted abort finding is addressed in this head. Priority: P2 Review scores
Verification
How this fits togetherControl UI browser tests send Gateway requests to a mock WebSocket server. Its session fixture turns Stop receipts into rows returned by session list, description, and chat reads, which determine whether the UI still shows an active run. flowchart LR
A[Browser Stop action] --> B[Mock Gateway request]
B --> C[Abort receipt]
C --> D[Session fixture commit]
D --> E[Session and chat reads]
E --> F[Control UI activity state]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +148. Total +148 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep committed mock session lifecycle state authoritative across list, description, history, and startup reads while preserving the Gateway’s distinction between session-wide and named-run Stop. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source leaves session-only Stop out of the mock commit path, and the contributor reports a focused regression failing on those original helpers; the exact natural CI interleaving was not reproduced. Is this the best way to solve the issue? Yes. The patch repairs the mock session fixture that owns committed test state and makes later reads consume it, without changing product session reconciliation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 01747d9b2b11. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…ow-keeps-stop-visible # Conflicts: # ui/src/e2e/chat-run-lifecycle.e2e.test.ts
|
PR #160410 has merged with an overlapping lifecycle-test correction: that scenario explicitly supplies a finished session row and forces an intervening read while Stop's history response is deferred. It does not include this PR's shared mock-Gateway |
A sessions.abort naming a runId settles only that run, matching the Gateway, which cascades to sibling runs and descendants only without a runId. Run lifecycle fixture tests move to a sibling file for the line cap.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…law#160563) * fix(ui): settle mock Gateway session rows on session-only Stop * fix(ui): scope mock sessions.abort settlement to the requested run A sessions.abort naming a runId settles only that run, matching the Gateway, which cascades to sibling runs and descendants only without a runId. Run lifecycle fixture tests move to a sibling file for the line cap. --------- Co-authored-by: VACInc <[email protected]>
Summary
High Level TLDR
refreshes cached %s activity after a session-only mock-Gateway Stopinui/src/e2e/chat-run-lifecycle.e2e.test.tsflaked in CI: Playwright timed out after 30s waiting forStop generatingto detach. The mock Gateway never recorded a session-only Stop (sessions.abort) against its session rows, so anysessions.describe/sessions.list/chat.historyread issued after Stop could still serve the pre-Stop active row. A real Gateway derives activity at read time and cannot do that. This PR makes the mock commitsessions.abortlike a real Gateway, and moves the test's post-Stopchat.historydata so it is published after Stop, not before.Classification: fixture defect (mock Gateway owner) plus a scenario-ordering bug in the test. Not a product race.
Root Cause
Before (current
main):ui/src/test-helpers/control-ui-e2e.ts(installControlUiMockGateway, around line 1584) wrote committed lifecycle state only forchat.abort(sessions.abortRuns).sessions.abortresponses left the stored row unchanged:hasActiveRun: true(direct) orhasActiveSubagentRun: true(descendant), with the oldupdatedAt. Every latersessions.describeandsessions.listread served that stale active row.chat.history/chat.startupreturned the static scenariosessionInfooverride and ignored committed lifecycle writes too.gateway.setMethodResponse("chat.history", …finished…)ran before Stop was clicked (chat-run-lifecycle.e2e.test.ts:663on main). A startup read still in flight could get the post-Stop answer before the scenario's Stop happened.sessions.abortresolved, the Control UI's latesessions.describe/sessions.listreads (including the SwarmRosterHydrator late-connect restage,ui/src/lib/sessions/swarm-roster.ts) got the pre-Stop active row back from the mock, soStop generatingnever detached. We forced the ordering with a scratch harness that held reads. The natural CI interleaving did not reproduce in 60+ throttled local runs.sessions.abort(src/gateway/server-methods/sessions-abort.ts) awaitshandleChatAbortRequestWithLifecycle(withcascadeDescendantsfor session-wide Stop) andsettleAbortPersistencebefore it responds.sessions.list/sessions.describerows computehasActiveRunfrom the live active-run projector (projectGatewaySessionActiveRun,src/gateway/session-utils-display.ts). They computehasActiveSubagentRunfrom the subagent registry and projected runs at read time (projectGatewaySessionRunState, same file). No cached pre-Stop activity survives a read issued after the abort response. So the product's session reconciliation was not changed.Exact change
ui/src/test-helpers/control-ui-session-fixtures.ts: newcommitAbort(method, params, response)owns both abort receipts.chat.abortkeeps its existingabortRunsbehavior.sessions.abortwith statusaborted/no-active-runnow settles the row: it clearsactiveRunIds,hasActiveRun, andhasActiveSubagentRun, sets status tokilled(aborted) ordone(from running), and advancesupdatedAt. It also marks those fields as committed so static wire fixtures cannot resurrect them.ui/src/test-helpers/control-ui-e2e.ts: the RPC dispatch callssessions.commitAbort.chat.history/chat.startupsessionInfonow goes through the same committed-field projection assessions.list, so committed lifecycle writes outrank the static scenario row.ui/src/e2e/chat-run-lifecycle.e2e.test.ts: the cached-activity scenario publishes its post-Stopchat.historyresponse aftersessions.abortis observed. No waits or timeouts were added.ui/src/test-helpers/control-ui-e2e.sessions.test.ts: regressionsettles %s activity for every later read after a session-only abort(direct and descendant). It asserts that describe, history, startup, and list reads aftersessions.abortare idle with a newerupdatedAt, and that an unrelated running session stays running.Overlap: #160410 edits the same cached-activity hunk to work around the stale mock inside the test (
setSessionsListResponse({sessions:[finishedSession]}), forcedsessions.refreshList, deferredchat.history). With this fixture fix, those test-level workarounds are no longer needed for this case. ItsopenMockAbortableRunextraction is orthogonal. Whichever PR lands second needs a small textual conflict resolution in that hunk. This PR fixes the owner, so the cached-activity edits in #160410 can be dropped.Real behavior proof
main,node scripts/run-vitest.mjs run ui/src/test-helpers/control-ui-e2e.sessions.test.ts -t "session-only abort"gives× settles direct activity…and× settles descendant activity…(AssertionError: expected {…} to deeply equal ObjectContaining{…}). With the fix:2 passed.What was not tested
sessionInfooverride (run once, see Verification).check:changedstops at the repo-wideOPENCLAW_*env-var budget (484 > 483), which comes frommainand not from this diff.Verification
node scripts/run-vitest.mjs run ui/src/test-helpers/control-ui-e2e.sessions.test.ts --maxWorkers=1: 54 passed, wall 3.55s. The two new cases take about 23ms each.node scripts/run-tsgo.mjs -p tsconfig.ui.json: clean.oxfmt --checkandrun-oxlint.mjson the 4 changed files: clean.chat-flow.messaging,chat-active-turn-recovery,sidebar-outbox,chat-outbox-recovery,session-shortcuts,session-management.archive,session-management.archive-batch,new-session-page.cloud-dispatch,chat-swarm-history): 56/56 passed.sessionInfooverride (touched by thechat.historyprojection change) ran once as one parallel batch: 401/404 passed. The 3 failures were load-timing assertions:board-fixturesnapshotAtdiffered by 30ms between two RPC reads,chat-flow.navigation-presentation:94counted requests too early, andmodel-catalog-partial-refresh:232readaria-disabledtoo early. On a rerun of those 3 files, both patched and unpatchedmainpassed. Theboard-fixturecase samplesDate.now()for both reads, before and after this change, so it is not caused by this diff.main(ddec4c8) to resolve thechat-run-lifecycle.e2e.test.tsoverlap with fix(ui): preview cards ignore external browser preference #160410: kept its sharedopenMockAbortableRunhelper and the deferred-chat.history+ forcedsessions.refreshListrace, dropped itssetSessionsListResponseoverride because it pre-settled the canonical row and maskedcommitAbort(without that override, disabling thesessions.abortbranch fails both session-only cases with Stop still visible). After the merge:pnpm test:ui:e2e ui/src/e2e/chat-run-lifecycle.e2e.test.ts5/5 runs, 16/16 each;control-ui-e2e.sessions.test.ts54/54;node scripts/check-changed.mjsclean.sessions.abort(cc1387e): a receipt for{ key, runId }now settles only that run and keeps siblings and descendant activity active, matchingsrc/gateway/server-methods/sessions-abort.ts:616(runId forwarded to the chat abort) and:680(cascadeDescendantsonly without a runId); the no-runId case still clears all. New regression fails with the old cascade. Run lifecycle fixture tests moved tocontrol-ui-e2e.sessions.runs.test.tsfor the 1000-line cap (no coverage change).control-ui-e2e.sessions*.test.ts55/55,chat-run-lifecycle.e2e.test.ts3/3 runs at 16/16,check-changedclean.Flake validation
pnpm test:ui:e2e ui/src/e2e/chat-run-lifecycle.e2e.test.ts. The target cases (direct + descendant) passed 40/40. 19/20 file runs were fully green. One run failed the unrelated siblingexcludes a reply-less failed turn's idle time from the next successful turn(chat-run-lifecycle.e2e.test.ts:127,expected 1 to be +0, a transient assistant group read right after the error alert).checks-ui-e2e (3/9), 78 files in CI order (this file is 3rd), 3 runs: the target cases passed 3/3. Runs 2 and 3 were fully green (350/350). Run 1 hit the same unrelatedreply-lesssibling failure.reply-lesssibling flake is pre-existing and not caused by this diff. In an interleaved A/B of 20mainruns vs 20 patched runs (-t "reply-less"), it failed once on unpatchedmain(base-4, same:127assertion) and once patched. It sends no abort and gets byte-identical mock responses under this change. It is left for a separate fix (one bug per PR).