Skip to content

fix(ui): settle mock Gateway session rows on session-only Stop - #160563

Merged
VACInc merged 3 commits into
mainfrom
fix/ui-stale-roster-row-keeps-stop-visible
Sep 28, 2026
Merged

VACInc merged 3 commits into
mainfrom
fix/ui-stale-roster-row-keeps-stop-visible

Conversation

@VACInc

@VACInc VACInc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

refreshes cached %s activity after a session-only mock-Gateway Stop in ui/src/e2e/chat-run-lifecycle.e2e.test.ts flaked in CI: Playwright timed out after 30s waiting for Stop generating to detach. The mock Gateway never recorded a session-only Stop (sessions.abort) against its session rows, so any sessions.describe / sessions.list / chat.history read 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 commit sessions.abort like a real Gateway, and moves the test's post-Stop chat.history data 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 for chat.abort (sessions.abortRuns). sessions.abort responses left the stored row unchanged: hasActiveRun: true (direct) or hasActiveSubagentRun: true (descendant), with the old updatedAt. Every later sessions.describe and sessions.list read served that stale active row. chat.history / chat.startup returned the static scenario sessionInfo override and ignored committed lifecycle writes too.
  • In the test, gateway.setMethodResponse("chat.history", …finished…) ran before Stop was clicked (chat-run-lifecycle.e2e.test.ts:663 on main). A startup read still in flight could get the post-Stop answer before the scenario's Stop happened.
  • Instrumented runs showed the stuck state. After the deferred sessions.abort resolved, the Control UI's late sessions.describe / sessions.list reads (including the SwarmRosterHydrator late-connect restage, ui/src/lib/sessions/swarm-roster.ts) got the pre-Stop active row back from the mock, so Stop generating never detached. We forced the ordering with a scratch harness that held reads. The natural CI interleaving did not reproduce in 60+ throttled local runs.
  • A real Gateway cannot serve this sequence. sessions.abort (src/gateway/server-methods/sessions-abort.ts) awaits handleChatAbortRequestWithLifecycle (with cascadeDescendants for session-wide Stop) and settleAbortPersistence before it responds. sessions.list / sessions.describe rows compute hasActiveRun from the live active-run projector (projectGatewaySessionActiveRun, src/gateway/session-utils-display.ts). They compute hasActiveSubagentRun from 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: new commitAbort(method, params, response) owns both abort receipts. chat.abort keeps its existing abortRuns behavior. sessions.abort with status aborted / no-active-run now settles the row: it clears activeRunIds, hasActiveRun, and hasActiveSubagentRun, sets status to killed (aborted) or done (from running), and advances updatedAt. 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 calls sessions.commitAbort. chat.history / chat.startup sessionInfo now goes through the same committed-field projection as sessions.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-Stop chat.history response after sessions.abort is observed. No waits or timeouts were added.
  • ui/src/test-helpers/control-ui-e2e.sessions.test.ts: regression settles %s activity for every later read after a session-only abort (direct and descendant). It asserts that describe, history, startup, and list reads after sessions.abort are idle with a newer updatedAt, 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]}), forced sessions.refreshList, deferred chat.history). With this fixture fix, those test-level workarounds are no longer needed for this case. Its openMockAbortableRun extraction 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

  • The regression fails on the original fixture. With only the two fixture files reverted to 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.
  • The target e2e test passed every run below (Flake validation).

What was not tested

  • The exact CI interleaving never reproduced naturally on this host. The stale read path was shown by instrumentation and a hold harness, and is now covered deterministically by the fixture regression.
  • Not run: UI e2e shards other than 3/9, beyond the 9 sibling files and 62 e2e files that pass a sessionInfo override (run once, see Verification).
  • check:changed stops at the repo-wide OPENCLAW_* env-var budget (484 > 483), which comes from main and 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 --check and run-oxlint.mjs on the 4 changed files: clean.
  • Sibling e2e files (9, 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.
  • The 62 other e2e files that pass a sessionInfo override (touched by the chat.history projection change) ran once as one parallel batch: 401/404 passed. The 3 failures were load-timing assertions: board-fixture snapshotAt differed by 30ms between two RPC reads, chat-flow.navigation-presentation:94 counted requests too early, and model-catalog-partial-refresh:232 read aria-disabled too early. On a rerun of those 3 files, both patched and unpatched main passed. The board-fixture case samples Date.now() for both reads, before and after this change, so it is not caused by this diff.
  • Merged main (ddec4c8) to resolve the chat-run-lifecycle.e2e.test.ts overlap with fix(ui): preview cards ignore external browser preference #160410: kept its shared openMockAbortableRun helper and the deferred-chat.history + forced sessions.refreshList race, dropped its setSessionsListResponse override because it pre-settled the canonical row and masked commitAbort (without that override, disabling the sessions.abort branch fails both session-only cases with Stop still visible). After the merge: pnpm test:ui:e2e ui/src/e2e/chat-run-lifecycle.e2e.test.ts 5/5 runs, 16/16 each; control-ui-e2e.sessions.test.ts 54/54; node scripts/check-changed.mjs clean.
  • Run-scoped sessions.abort (cc1387e): a receipt for { key, runId } now settles only that run and keeps siblings and descendant activity active, matching src/gateway/server-methods/sessions-abort.ts:616 (runId forwarded to the chat abort) and :680 (cascadeDescendants only without a runId); the no-runId case still clears all. New regression fails with the old cascade. Run lifecycle fixture tests moved to control-ui-e2e.sessions.runs.test.ts for the 1000-line cap (no coverage change). control-ui-e2e.sessions*.test.ts 55/55, chat-run-lifecycle.e2e.test.ts 3/3 runs at 16/16, check-changed clean.

Flake validation

  • Standalone, 20 runs: 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 sibling excludes 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).
  • Original CI shard 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 unrelated reply-less sibling failure.
  • The reply-less sibling flake is pre-existing and not caused by this diff. In an interleaved A/B of 20 main runs vs 20 patched runs (-t "reply-less"), it failed once on unpatched main (base-4, same :127 assertion) 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).

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:56 PM ET / 17:56 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: cc1387e7bd15bfa5b0803430bcf5138e6f08d154

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Repeated browser-path validation and a baseline-failing fixture regression support a focused repair, with no remaining actionable finding identified.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed owner is the mock Gateway session fixture; the reported browser E2E sends session-only Stop through the Control UI’s Gateway connection and observes the Stop control detach after subsequent reads. A focused regression reportedly fails on the original fixture and passes after the repair. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed owner is the mock Gateway session fixture; the reported browser E2E sends session-only Stop through the Control UI’s Gateway connection and observes the Stop control detach after subsequent reads. A focused regression reportedly fails on the original fixture and passes after the repair. No stored-data contract changes.
Evidence reviewed 7 items Current main still lacks the fixture repair: The main mock dispatch commits chat.abort through abortRuns but has no sessions.abort commit path; its session fixture has no commitAbort method.
Introduced fixture settlement: The introduced hunk commits session-only abort receipts and routes later history and startup session rows through committed fixture fields.
Previous finding addressed: The latest commit keeps a named-run abort on the targeted-run path, and the new regression checks that another run and descendant activity remain active.
Findings None None.
Security None None.

How this fits together

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

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +148. Total +148 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 469 321 +148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 469 321 +148

Review metrics

None.

Technical review

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed owner is the mock Gateway session fixture; the reported browser E2E sends session-only Stop through the Control UI’s Gateway connection and observes the Stop control detach after subsequent reads. A focused regression reportedly fails on the original fixture and passes after the repair. No stored-data contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded Control UI test-fixture reliability repair with no demonstrated production-user regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed owner is the mock Gateway session fixture; the reported browser E2E sends session-only Stop through the Control UI’s Gateway connection and observes the Stop control detach after subsequent reads. A focused regression reportedly fails on the original fixture and passes after the repair. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is the mock Gateway session fixture; the reported browser E2E sends session-only Stop through the Control UI’s Gateway connection and observes the Stop control detach after subsequent reads. A focused regression reportedly fails on the original fixture and passes after the repair. No stored-data contract changes.

Evidence

What I checked:

  • Current main still lacks the fixture repair: The main mock dispatch commits chat.abort through abortRuns but has no sessions.abort commit path; its session fixture has no commitAbort method. (ui/src/test-helpers/control-ui-e2e.ts:1572, 01747d9b2b11)
  • Introduced fixture settlement: The introduced hunk commits session-only abort receipts and routes later history and startup session rows through committed fixture fields. (ui/src/test-helpers/control-ui-session-fixtures.ts:365, cc1387e7bd15)
  • Previous finding addressed: The latest commit keeps a named-run abort on the targeted-run path, and the new regression checks that another run and descendant activity remain active. (ui/src/test-helpers/control-ui-e2e.sessions.runs.test.ts:351, cc1387e7bd15)
  • Gateway run-scope contract: The production handler forwards the requested run ID and enables descendant cascading only when no run ID was requested. The Gateway file has the same blob on main and the reviewed head. (src/gateway/server-methods/sessions-abort.ts:680, 01747d9b2b11)
  • Related merged work is narrower: The related PR merged, while current main still lacks the shared abort fixture repair. Its overlap is in the browser lifecycle scenario. (ui/src/e2e/chat-run-lifecycle.e2e.test.ts:615, 93a13da9a036)
  • Contributor runtime proof: The captured PR body reports that the fixture regression fails against the original helpers and passes with the patch, plus repeated Control UI browser runs through the mock Gateway after Stop. The exact natural CI interleaving was not observed. The prepared screenshots belong to the related browser-card PR and were not counted as proof for this change.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-28T16:56:52.840Z sha ef5d162 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T17:32:45.072Z sha ddec4c8 :: blocked before merge. :: [P2] Preserve sibling runs for run-targeted session aborts

…ow-keeps-stop-visible

# Conflicts:
#	ui/src/e2e/chat-run-lifecycle.e2e.test.ts
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

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 commitAbort repair, committed lifecycle-state projection, or direct/descendant regressions across describe, history, startup, and list reads. That owner-level repair remains distinct. The overlapping cached-activity test hunk needs reconciliation against merged main, but this PR is not superseded and should remain open.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
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.
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@VACInc
VACInc merged commit d0be054 into main Sep 28, 2026
112 of 113 checks passed
@VACInc
VACInc deleted the fix/ui-stale-roster-row-keeps-stop-visible branch September 28, 2026 18:07
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…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]>
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant