Skip to content

fix(ui): refresh managed sessions on terminal events - #125040

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-sessions-terminal-managed-refresh
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-sessions-terminal-managed-refresh

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes follow-up from #125018

What Problem This Solves

Fixes an issue where users viewing Sessions could continue to see a run as active after it had finished when the Gateway delivered a terminal session.message without a later sessions.changed event.

Why This Change Was Made

Terminal session messages already pass the authoritative event gate and refresh the canonical roster. This change removes the obsolete event-type switch that stopped there, so the same event also invalidates matching managed session-list queries while preserving agent scoping and the early return for non-terminal messages. It does not restore page-local loading or canonical-revision reloads.

User Impact

The Sessions page now adopts terminal status and server ordering promptly after a run finishes. There is no visual styling delta; this is a terminal-state freshness correction.

AI-assisted: yes.

Evidence

  • Pre-fix regression: the focused owner test failed because the canonical row changed to done while the Sessions-style managed snapshot remained running.
  • Post-fix owner/sibling proof: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs ui/src/lib/sessions/index.test.ts ui/src/lib/sessions/index-list.test.ts ui/src/lib/sessions/index.event-refresh.test.ts ui/src/pages/sessions/sessions-page.roster.test.ts — 62/62 passed.
  • Mocked browser proof: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-list-filter.e2e.test.ts — 4/4 passed.
  • The new regression proves one canonical refresh, exactly one matching managed-list refresh, active-to-done snapshot replacement, and no refresh for another known agent's scoped query.
  • Targeted oxfmt, targeted oxlint, and git diff --check passed.
  • Remote changed gate: direct AWS Crabbox run run_88bf32570a1a on lease cbx_782424ed3adb passed with exit 0 after Blacksmith was unavailable: https://crabbox.openclaw.ai/portal/runs/run_88bf32570a1a
  • Fresh uncommitted Codex autoreview: clean, no accepted/actionable findings.
  • Production LOC: +2/-6 (net -4). Tests: +82/-0.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 17, 2026 04:33
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 17, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 12:39 AM ET / 04:39 UTC.

ClawSweeper review

What this changes

The PR makes terminal Gateway session events refresh matching managed Sessions-page query snapshots.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No code-level blocking finding: the patch restores managed Sessions-list refresh at the shared roster owner after terminal events. Keep it open for exact-head CI completion and live UI proof.

Priority: P1
Reviewed head: 125aaa69dcf286a03cbb6753f413b1f0972ed8ef

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 7 items Shared owner boundary: The PR removes the event-type exclusion after the terminal-message gate, so each authoritative terminal event reaches the common roster scheduler.
Scoped invalidation: The roster schedules every matching managed query while retaining agent scoping; global queries refresh and a different agent-specific query does not.
Sessions-page consumer: The Sessions route deliberately creates a managed query with title/message enrichment disabled, and the page subscribes to that snapshot; it cannot rely on the canonical roster alone.
Findings None None.
Security None None.

How this fits together

The Control UI receives Gateway session events, refreshes its canonical roster, and serves scoped managed snapshots to the Sessions page. A terminal event must update both paths so a completed run no longer remains displayed as active.

flowchart LR
  A[Gateway terminal event] --> B[Session event gate]
  B --> C[Canonical roster refresh]
  B --> D[Matching managed lists]
  C --> E[Session state]
  D --> F[Sessions page]
  E --> F
Loading

Before merge

  • Resolve merge risk (P1) - The branch changes event-driven session-state invalidation; merge should retain the demonstrated same-agent scope behavior and confirm it in the running Sessions page.
  • Resolve merge risk (P1) - Only mock-Gateway/Vitest evidence is attached for the visible running-to-done transition; a sanitized browser recording or screenshots from the built Control UI are still absent.
  • Resolve merge risk (P1) - The current lint failure and remaining checks were not inspectable because GitHub DNS was unavailable; partial-clone history operations requiring promisor fetches were likewise unavailable.
  • Complete next step (P2) - No mechanical repair is indicated; human review should confirm visible UI proof and the unresolved exact-head CI state.
Agent review details

Security

None.

PR surface

Source -4, Tests +82. Total +78 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 6 -4
Tests 1 82 0 +82
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 84 6 +78

Review metrics

Metric Value Why it matters
Production versus test LOC production +2/-6 (net -4); tests +82/-0 The bug fix removes the obsolete filter branch while adding focused regression coverage.

Stored data model

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

Root-cause cluster

Relationship: canonical
Canonical: #125040
Summary: This PR is the canonical repair for a terminal-event gap left at the managed-list boundary by the recently merged Sessions query refactor.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify the visible terminal transition (recommended)
    Capture a sanitized built-Control-UI running-to-done Sessions refresh and resolve the exact-head lint failure before merging.
  2. Accept mock-only proof
    Maintainers may merge based on the focused owner test and mocked browser coverage while accepting the missing live UI confirmation.

Technical review

Best possible solution:

Keep the shared roster scheduler as the single refresh owner, attach a sanitized real Sessions-page terminal-state transition, and merge only after the exact head is green.

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

Yes, from source: current main passes a terminal session.message through canonical refresh but marks it unfiltered, preventing managed Sessions queries from scheduling. Tests were not run because this is a read-only review.

Is this the best way to solve the issue?

Yes. Updating the shared roster scheduler is the best fix because the Sessions page consumes managed snapshots; a page-local reload would recreate the duplicate refresh ownership removed by the preceding refactor.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A newly introduced default Sessions-page path can continue to show a finished run as active until another event arrives.
  • add merge-risk: 🚨 session-state: The change alters which terminal events refresh scoped session snapshots, so an incorrect scope would present stale or mis-associated session state.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Label justifications:

  • P1: A newly introduced default Sessions-page path can continue to show a finished run as active until another event arrives.
  • merge-risk: 🚨 session-state: The change alters which terminal events refresh scoped session snapshots, so an incorrect scope would present stale or mis-associated session state.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged managed-session query refactor and is the dominant recent contributor across the affected session roster and page-query history. (role: recent Sessions/UI contributor; confidence: high; commits: 77ececee5410, 89f6ab109b2e; files: ui/src/lib/sessions/index.ts, ui/src/lib/sessions/session-roster-refresh.ts, ui/src/pages/sessions/route.ts)

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.

@steipete
steipete force-pushed the steipete/fix-sessions-terminal-managed-refresh branch from 125aaa6 to d9ba79c Compare August 17, 2026 04:51
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head d9ba79ce9e6549303c6df54b4002687913b63f8a.

The terminal-event acceptance criterion from #125018 is now satisfied: after the existing non-terminal session.message early return, an authoritative terminal message schedules both the canonical roster and every matching managed list. The focused regression seeds the Sessions-style query (includeDerivedTitles: false, includeLastMessage: false, includeUnknown: false), proves active-to-done replacement, proves exactly one matching managed refresh, and proves another known agent's scoped query is not refreshed.

Proof:

  • Pre-fix owner regression failed because canonical state reached done while the managed Sessions snapshot remained running.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs ui/src/lib/sessions/index.test.ts ui/src/lib/sessions/index-list.test.ts ui/src/lib/sessions/index.event-refresh.test.ts ui/src/pages/sessions/sessions-page.roster.test.ts — 62/62 passed.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-list-filter.e2e.test.ts — 4/4 passed.
  • Post-rebase focused owner proof: node scripts/run-vitest.mjs ui/src/lib/sessions/index.event-refresh.test.ts — 15/15 passed.
  • Targeted oxfmt, targeted oxlint, and git diff --check passed.
  • Blacksmith was unavailable. The required direct AWS fallback passed on Crabbox lease cbx_782424ed3adb, run run_88bf32570a1a, exit 0: https://crabbox.openclaw.ai/portal/runs/run_88bf32570a1a
  • Fresh uncommitted Codex autoreview was clean with no accepted/actionable findings.
  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/31995876415
  • Production LOC: +2/-6 (net -4). Tests: +82/-0.

ClawSweeper review resolution: #125040 (comment) reports no code-level or security finding and calls the shared roster owner the best fix. It has no explicit Rank-up moves section. The same-agent scope item is covered by the regression above. Its observed lint failure was an unrelated stale main max-lines failure, repaired by f48d9b1c; this exact-head CI run is green against that baseline. A separate sanitized running-to-done recording is intentionally skipped: this PR has no visual styling delta, and the requested focused correction is already exercised through the owner boundary plus the mocked-Gateway real-browser E2E. No page-local load or canonical-revision fallback was added.

@steipete
steipete merged commit 1606969 into main Aug 17, 2026
143 checks passed
@steipete
steipete deleted the steipete/fix-sessions-terminal-managed-refresh branch August 17, 2026 05:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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