Skip to content

fix(ui): clear stale sidebar run state after chat final#101293

Merged
fuller-stack-dev merged 3 commits into
openclaw:mainfrom
fuller-stack-dev:fix/sidebar-terminal-run-reconciliation
Jul 7, 2026
Merged

fix(ui): clear stale sidebar run state after chat final#101293
fuller-stack-dev merged 3 commits into
openclaw:mainfrom
fuller-stack-dev:fix/sidebar-terminal-run-reconciliation

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Summary

  • reconcile terminal chat events into the shared session capability so sidebar subscribers clear the completed run immediately
  • retain completed-run identity across duplicate stale session publications while preserving newer, unidentified, embedded, and canonical-global activity
  • add capability, lifecycle, alias, and Playwright coverage for the final-before-sessions.changed race

Root cause

The composer lifecycle fix cleared the chat pane's local session projection, but the sidebar reads the shared SessionCapability cache. When a final chat event arrived before the terminal session publication, the composer could become idle while the shared sidebar row remained active. A duplicate stale session publication could also revive the completed run after the local terminal projection.

This change publishes the owned terminal run through both projections and keeps its identity as a tombstone until the Gateway reports terminal state or a different run. Active rows are only cleared when their advertised run ID matches the terminal event.

Testing

  • pnpm tsgo:test:ui
  • node scripts/run-oxlint.mjs ui/src/e2e/chat-run-lifecycle.e2e.test.ts ui/src/lib/sessions/index.test.ts ui/src/lib/sessions/index.ts ui/src/pages/chat/run-lifecycle.test.ts ui/src/pages/chat/run-lifecycle.ts
  • pnpm test ui/src/lib/sessions/index.test.ts ui/src/pages/chat/run-lifecycle.test.ts ui/src/e2e/chat-run-lifecycle.e2e.test.ts -- --reporter=verbose
  • autoreview: clean, no accepted/actionable findings

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 1:32 AM ET / 05:32 UTC.

Summary
The PR adds run-id-aware terminal reconciliation to the Control UI SessionCapability and chat run lifecycle, plus unit and Playwright coverage for stale sidebar activity after a chat final event.

PR surface: Source +91, Tests +244. Total +335 across 6 files.

Reproducibility: yes. source-reproducible: current main lets the chat pane clear local run state while the sidebar continues to render shared SessionCapability active-run state. I did not run a live browser repro in this read-only review.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: ui/src/lib/sessions/index.test.ts, serialized state: ui/src/lib/sessions/index.ts, unknown-data-model-change: ui/src/lib/sessions/index.test.ts, unknown-data-model-change: ui/src/lib/sessions/index.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #101293
Summary: This PR is the live candidate for the sidebar/shared-state remainder of the stale active-row race; the earlier merged PR fixed the selected chat-pane/composer half.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Mantis proof suggestion
A short web UI chat proof could visibly confirm the sidebar spinner clears after a completed chat turn and stays cleared after a stale session update. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web ui chat proof: verify that after a completed chat turn the active sidebar session spinner clears and does not reappear after a stale sessions.changed update.

Risk before merge

  • [P1] Merging changes shared session-state projection: if the run-id ownership guard is wrong, UI state could either hide a real active run or keep a completed run active. The patch has focused guards and tests for matching, different, unidentified, alias, and duplicate stale publications.

Maintainer options:

  1. Land guarded session-state reconciliation (recommended)
    Accept the remaining session-state risk after normal merge gating because the patch terminalizes only matching run IDs and preserves different or unidentified active rows.
  2. Pause for additional web UI proof
    Ask for a short browser proof if maintainers want visual confirmation that the sidebar spinner clears and does not reappear on a stale session update.

Next step before merge

  • [P2] Protected maintainer PR has no actionable repair findings; the remaining action is maintainer acceptance and landing through normal merge gates.

Maintainer decision needed

  • Question: Should maintainers accept the shared SessionCapability run-terminal reconciliation as the landing path for stale sidebar activity after chat final events?
  • Rationale: The patch intentionally changes shared session-state projection for a user-visible race; code review found it guarded and tested, but final race-tolerance and landing acceptance belong to maintainers.
  • Likely owner: steipete — Peter is the clearest current-surface owner from blame on the imported UI session lifecycle, SessionCapability, and sidebar code.
  • Options:
    • Land the guarded reconciliation (recommended): Accept the limited session-state risk because the PR only terminalizes matching run IDs and preserves different or unidentified active rows.
    • Ask for more visual proof: Pause landing for an extra web UI chat proof if maintainers want to see the sidebar spinner race demonstrated before merge.

Security
Cleared: The diff is limited to Control UI TypeScript and tests, with no dependency, workflow, lockfile, secret, package, or downloaded-code surface changes.

Review details

Best possible solution:

Land the shared SessionCapability terminal reconciliation with the run-id ownership guards and exact-head merge checks, keeping the sidebar and chat pane driven by the same terminal event.

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

Yes, source-reproducible: current main lets the chat pane clear local run state while the sidebar continues to render shared SessionCapability active-run state. I did not run a live browser repro in this read-only review.

Is this the best way to solve the issue?

Yes: publishing terminal state through SessionCapability is the right boundary because sidebar subscribers read that cache. A local-only chat-pane fix misses the sidebar, while clearing active rows without run-id ownership would risk hiding genuine recovered runs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5d7a451b1532.

Label changes

Label changes:

  • add merge-risk: 🚨 session-state: The PR changes shared session active-run reconciliation, so an incorrect guard could stale or misclassify chat/sidebar session state.

Label justifications:

  • P2: This is a bounded Control UI bug fix for stale visible run state with limited blast radius.
  • merge-risk: 🚨 session-state: The PR changes shared session active-run reconciliation, so an incorrect guard could stale or misclassify chat/sidebar session state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable because the live PR author association is MEMBER and the PR has the maintainer label; the PR still includes targeted test commands and a Crabbox focused-test comment.
Evidence reviewed

PR surface:

Source +91, Tests +244. Total +335 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 128 37 +91
Tests 4 259 15 +244
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 387 52 +335

What I checked:

  • Repository policy read: Root AGENTS.md and ui/AGENTS.md were read fully; the review policy requires whole-path review and protected maintainer PRs stay open for explicit handling. (AGENTS.md:24, 5d7a451b1532)
  • Live PR state: Live GitHub data shows this PR is open, authored by a MEMBER, labeled maintainer, mergeable but behind, and exact-head CI checks are green at ee1ff70. (ee1ff70de43b)
  • Current-main sidebar dependency: The sidebar subscribes to context.sessions.state and renders hasActiveRun from shared session rows, so a chat-pane-only terminal projection can leave the sidebar spinner stale. (ui/src/components/app-sidebar.ts:221, 5d7a451b1532)
  • Current-main local-only projection: Current main reconciles terminal chat state only into host.sessionsResult inside run-lifecycle; it has no shared SessionCapability terminal publication path for sidebar subscribers. (ui/src/pages/chat/run-lifecycle.ts:227, 5d7a451b1532)
  • PR shared reconciliation: The PR adds reconcileSessionRunTerminal and SessionCapability.reconcileRunTerminal, terminalizing active rows only when the completed run id owns one of the row activeRunIds and preserving different or unidentified active rows. (ui/src/lib/sessions/index.ts:496, ee1ff70de43b)
  • PR caller boundary: The chat lifecycle now gathers equivalent selected-session row keys, updates the local projection, and publishes the same terminal event to host.sessions.reconcileRunTerminal. (ui/src/pages/chat/run-lifecycle.ts:226, ee1ff70de43b)

Likely related people:

  • steipete: Current-main blame on the run lifecycle, shared SessionCapability, and sidebar subscription/rendering surfaces points to the 6540298 UI import/snapshot commit under Peter Steinberger's authorship. (role: recent current-surface contributor; confidence: medium; commits: 654029892dcb; files: ui/src/pages/chat/run-lifecycle.ts, ui/src/lib/sessions/index.ts, ui/src/components/app-sidebar.ts)
  • MukundaKatta: Merged PR fix(webchat): suppress stale active session row racing a completed turn (#87875) #87962 added the earlier WebChat stale active-row composer fix that this PR extends into shared sidebar state. (role: prior same-root-cause fix author; confidence: medium; commits: 7159c958befb, e452d16ceaa5; files: ui/src/ui/chat/run-lifecycle.ts, ui/src/ui/controllers/chat.ts)
  • vincentkoc: Vincent provided maintainer refresh and real-behavior/Testbox proof on the merged prior stale-active row PR, making them useful context for this same bug family. (role: prior reviewer and proof owner; confidence: medium; commits: 7159c958befb; files: ui/src/ui/chat/run-lifecycle.ts, ui/src/ui/controllers/chat.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T03:45:40.947Z sha 23330ee :: needs maintainer review before merge. :: none

@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. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Jul 7, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Updated the branch at ee1ff70de43b to fix the branch-owned CI fixture: the cached active session row now identifies run-1, matching the terminal reconciliation ownership guard.

Proof:

  • Sanitized AWS Crabbox cbx_fbaf02a467e1, run run_cdc12be22238: pnpm test ui/src/pages/chat/chat-gateway.test.ts ui/src/pages/chat/run-lifecycle.test.ts ui/src/lib/sessions/index.test.ts — 159 tests passed.
  • Trusted brokered autoreview: clean, no accepted/actionable findings.
  • Exact-head GitHub CI is running; no current failed checks.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jul 7, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@openclaw-mantis web ui chat proof: verify that after a completed chat turn the active sidebar session spinner clears and does not reappear after a stale sessions.changed update.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Land-ready review complete.

  • Canonical-fix verdict: this is the best-fit shared-cache fix for the stale sidebar run state. It terminalizes only the completed run across chat and SessionCapability projections, preserves newer/unidentified activity, and blocks stale duplicate publication. PR fix(ui): bind stale run state to run identity #100527 is the run-identity prerequisite; fix(ui): scope sidebar session active state to chat #100918 is a route-styling change, not an overlapping fix.
  • Prepared head: 32a33eb4cd11c898b8f5f298ead3bfa0cae88580. The bounded correction adds canonical global alias publication before the local session list loads. It was pushed as a plain fast-forward from ee1ff70de43b007d61aceaac382d3b11a69721bd; no rebase or history rewrite.
  • Focused unit proof: node scripts/run-vitest.mjs ui/src/pages/chat/run-lifecycle.test.ts ui/src/lib/sessions/index.test.ts ui/src/pages/chat/chat-gateway.test.ts — 160 tests passed.
  • Deterministic browser proof: node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-run-lifecycle.e2e.test.ts — 1 Chromium E2E passed. Active, final, and repeated-stale states were screenshot/video verified; proof artifacts were not committed.
  • Review gates: fresh autoreview reported no accepted/actionable findings; git diff --check, formatting, local build, and local check passed. The broad local pnpm test fanout was intentionally stopped after expanding across unrelated tooling/plugin suites, with no relevant failure; exact-head hosted CI is the broad authority.
  • Hosted CI: exact-head run 28847534635 passed all build, check, QA smoke, and test shards. Exact-head Workflow Sanity, Dependency Guard, Security Sensitive Guard, iOS Periphery, and Real behavior proof also passed.
  • Current-main proof: after refreshing origin/main to cb9de7d361a86968789d57e8107b108a2be80a87, git merge-tree --write-tree completed without conflicts.
  • Known proof gap: the requested Mantis run did not produce a remote artifact; the deterministic local Chromium recording and exact-head hosted CI cover the affected Control UI path.

@fuller-stack-dev
fuller-stack-dev merged commit 521bf99 into openclaw:main Jul 7, 2026
75 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @fuller-stack-dev!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
)

Merged via squash.

Prepared head SHA: 32a33eb
Co-authored-by: fuller-stack-dev <[email protected]>
Reviewed-by: @fuller-stack-dev
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
)

Merged via squash.

Prepared head SHA: 32a33eb
Co-authored-by: fuller-stack-dev <[email protected]>
Reviewed-by: @fuller-stack-dev
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
)

Merged via squash.

Prepared head SHA: 32a33eb
Co-authored-by: fuller-stack-dev <[email protected]>
Reviewed-by: @fuller-stack-dev
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 maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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