Skip to content

fix(ui): stop duplicate Sessions page queries - #125018

Merged
steipete merged 1 commit into
mainfrom
steipete/laughing-easley-d7942d
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/laughing-easley-d7942d

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #124968

AI-assisted: yes

What Problem This Solves

The Sessions route, page, and canonical session state multiplied one roster demand into two identical page requests before startup hydration completed and a third request afterward. That caused avoidable Gateway work and allowed late canonical completion to trigger another page reload even though the exact Sessions query had already completed.

Why This Change Was Made

The shared session capability now owns one exact managed query for the page. The route seeds that query, the page subscribes to its snapshot, and filter changes, mutation tails, and reconnects refresh the same owner. The old raw page load and canonical-invalidation reload machinery is removed rather than retained as a compatibility path.

User Impact

Sessions now loads and refreshes once per exact query, keeps last-good rows visible when a refresh fails, and preserves active-minutes/limit/global/unknown/status filters, deep links, selected/all-agent scope, local search/sort/pagination, transcript search, destructive archived pagination, mutation ordering, stale-request retirement, and checkpoint reconciliation. There is no visual design change.

Evidence

  • Before: direct /sessions startup issued two identical exact page queries before canonical startup completion, then a third after completion (2 -> 3).
  • After: the exact page-query count is one before canonical completion and remains one afterward (1 -> 1).
  • Focused UI tests: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs ui/src/lib/sessions/index-list.test.ts ui/src/pages/sessions/route.test.ts ui/src/pages/sessions/sessions-page.test.ts ui/src/pages/sessions/sessions-page.roster.test.ts ui/src/pages/sessions/sessions-page.archived.test.ts ui/src/pages/sessions/agent-scope.test.ts — 6 files across 2 shards, 62 tests passed.
  • Browser request-count proof: 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 — 1 file, 4 tests passed.
  • Browser agent-scope proof: node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agent-page-scope.e2e.test.ts — 1 file, 4 tests passed.
  • Formatting/whitespace: node_modules/.bin/oxfmt --check over all 11 changed paths and git diff --check origin/main...HEAD — clean.
  • Fresh branch autoreview: AGENTS_HOME="$HOME/.claude" "$HOME/.claude/skills/autoreview/scripts/autoreview" --mode branch --base origin/main — clean, no accepted/actionable findings; patch-correct score 0.97.
  • Full changed gate: direct AWS Crabbox run run_5edb94ba28d6 on stopped lease cbx_4d3e65ef283e — https://crabbox.openclaw.ai/portal/runs/run_5edb94ba28d6. The earlier Blacksmith Testbox preflight did not execute remote code because the blacksmith binary was missing; AWS was the successful fallback.
  • Patch identity: rebased head 8b7cc0e6dcca5e04cad1278a8ef92c0bb2bc5263 has the same stable patch ID as reviewed source commit 9d98a69574e0fc7ef46a0ae3ebbab416dcc7c070.
  • LOC: production +215/-222 (net -7); tests/support +685/-114.

Visual parity (sanitized mocked Gateway data; same Writer-scoped Sessions UI before and after):

Before

After

Make the Sessions route and page share the managed session-list owner so startup hydration, reconnects, filters, and mutations cannot schedule duplicate raw roster requests. Preserve last-good rows and retire stale query epochs.
@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.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 03:43
@steipete steipete closed this Aug 17, 2026
@steipete steipete reopened this 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: 🦐 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 16, 2026, 11:51 PM ET / August 17, 2026, 03:51 UTC.

ClawSweeper review

What this changes

The PR routes the Sessions page through a shared managed session-list query to eliminate duplicate Gateway requests during startup and refreshes.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-owned PR open: the new managed Sessions query is not refreshed after a terminal session.message, so active-session status and ordering can remain stale. Likely related people: steipete (high confidence).

Priority: P1
Reviewed head: 8b7cc0e6dcca5e04cad1278a8ef92c0bb2bc5263

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The managed-query refactor has strong targeted coverage, but the P1 terminal-event regression must be repaired before it is merge-ready.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated browser request-count proof covers startup duplication but not the terminal-event regression found here.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated browser request-count proof covers startup duplication but not the terminal-event regression found here.
Evidence reviewed 5 items New non-primary subscription: The PR explicitly treats a Sessions query with disabled enrichment as non-primary, then subscribes the page to that managed query.
Terminal-event refresh gap: Current event handling recognizes terminal session messages but marks every non-sessions.changed event as excluded from managed-list refresh; the managed-list owner returns immediately for that flag.
Existing terminal-state contract: Current regression coverage requires a terminal session.message to issue a second list request and replace an active row with its done state.
Findings 1 actionable finding [P1] Refresh managed lists on terminal session messages
Security None None.

How this fits together

The Control UI fetches session rosters from the Gateway through a shared session capability. The Sessions route seeds its exact query and the page subscribes to updates while Gateway events refresh matching lists.

flowchart LR
  A[Gateway session events] --> B[Session capability]
  B --> C[Canonical roster]
  B --> D[Managed Sessions query]
  E[Sessions route] --> D
  D --> F[Sessions page]
  C --> G[Sidebar and other consumers]
Loading

Before merge

  • Refresh managed lists on terminal session messages (P1) - This new subscription makes Sessions consume a non-primary managed list, but terminal session.message events are passed to scheduleEvent with filtered: false; that method refreshes only the canonical list. Existing coverage requires a terminal message to refresh stale active rows, so Sessions now stays stale until another event or manual refresh. Schedule the matching managed query for terminal messages and add a regression for this page-style query.
  • Resolve merge risk (P1) - Merging leaves the Sessions page subscribed to a managed snapshot that does not refresh when an active run ends via session.message, so users can see stale status or ordering until another event or manual refresh.
  • Complete next step (P2) - A focused owner-boundary repair can restore terminal managed-list refresh without changing product direction.

Findings

  • [P1] Refresh managed lists on terminal session messages — ui/src/pages/sessions/sessions-page.ts:492
Agent review details

Security

None.

PR surface

Source +53, Tests +511. Total +564 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 4 279 226 +53
Tests 7 621 110 +511
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 900 336 +564

Review metrics

Metric Value Why it matters
Production versus test LOC production +215/-222 (net -7); tests/test support +685/-114 The owner-boundary refactor is net-negative in production while adding focused route, lifecycle, and browser coverage.

Stored data model

Persistent data-model change detected: serialized state: ui/src/e2e/session-list-filter.e2e.test.ts, serialized state: ui/src/lib/sessions/index-list.test.ts, serialized state: ui/src/pages/sessions/route.test.ts, serialized state: ui/src/pages/sessions/route.ts, serialized state: ui/src/pages/sessions/sessions-page.roster.test.ts, serialized state: ui/src/pages/sessions/sessions-page.test-support.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh managed lists after terminal messages (recommended)
    Schedule matching managed session queries when a terminal session.message is received and prove the Sessions-style query receives the updated row.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Refresh subscribed managed session queries after terminal session.message events and add a focused regression covering the Sessions query; do not restore page-local raw roster loading.

Technical review

Best possible solution:

Extend the session-event owner so terminal messages schedule matching subscribed managed lists, then add a regression for the Sessions-style query without restoring page-local raw loads or canonical-revision reloads.

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

Yes, from source: load a Sessions-style managed query, emit a terminal session.message without sessions.changed, and observe that its snapshot is not refreshed; current coverage proves the terminal event must refresh the canonical roster.

Is this the best way to solve the issue?

No: sharing the managed query is the right direction, but the event owner must refresh that managed query on terminal messages before this can replace the prior canonical-completion reload.

Full review comments:

  • [P1] Refresh managed lists on terminal session messages — ui/src/pages/sessions/sessions-page.ts:492
    This new subscription makes Sessions consume a non-primary managed list, but terminal session.message events are passed to scheduleEvent with filtered: false; that method refreshes only the canonical list. Existing coverage requires a terminal message to refresh stale active rows, so Sessions now stays stale until another event or manual refresh. Schedule the matching managed query for terminal messages and add a regression for this page-style query.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The patch regresses current Sessions-page terminal-state updates for active runs, leaving user-visible session state stale.
  • add merge-risk: 🚨 session-state: The new managed query can retain stale active/done state when terminal messages do not trigger its refresh.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated browser request-count proof covers startup duplication but not the terminal-event regression found here.

Label justifications:

  • P1: The patch regresses current Sessions-page terminal-state updates for active runs, leaving user-visible session state stale.
  • merge-risk: 🚨 session-state: The new managed query can retain stale active/done state when terminal messages do not trigger its refresh.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated browser request-count proof covers startup duplication but not the terminal-event regression found here.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs ui/src/lib/sessions/index.test.ts ui/src/lib/sessions/index-list.test.ts ui/src/pages/sessions/sessions-page.roster.test.ts.
  • [P1] 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.

What I checked:

Likely related people:

  • steipete: Authored the merged dashboard managed-query implementation and this Sessions extension. (role: recent managed-query feature owner; confidence: high; commits: 89f6ab109b2e, 8b7cc0e6dcca; files: ui/src/lib/sessions/session-roster-refresh.ts, ui/src/pages/dashboards/route.ts, ui/src/pages/sessions/route.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the matching managed query after terminal session.message events.
  • Add a focused regression that proves the Sessions-style query updates from active to terminal state.

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

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 8b7cc0e6dcca5e04cad1278a8ef92c0bb2bc5263:

  • Focused UI proof: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs ui/src/lib/sessions/index-list.test.ts ui/src/pages/sessions/route.test.ts ui/src/pages/sessions/sessions-page.test.ts ui/src/pages/sessions/sessions-page.roster.test.ts ui/src/pages/sessions/sessions-page.archived.test.ts ui/src/pages/sessions/agent-scope.test.ts — 6 files across 2 shards, 62 tests passed.
  • Browser request-count proof: ui/src/e2e/session-list-filter.e2e.test.ts — 4/4 passed; the exact Sessions page query was 2 -> 3 before the repair and remains 1 -> 1 across canonical startup completion after it.
  • Browser agent-scope proof: ui/src/e2e/agent-page-scope.e2e.test.ts — 4/4 passed.
  • Full changed gate: direct AWS Crabbox run run_5edb94ba28d6 on stopped lease cbx_4d3e65ef283e: https://crabbox.openclaw.ai/portal/runs/run_5edb94ba28d6. The earlier Blacksmith Testbox preflight executed no remote code because the blacksmith binary was missing; AWS was the successful fallback.
  • Exact-head CI: run 31992183067 completed successfully for this head: https://github.com/openclaw/openclaw/actions/runs/31992183067.
  • Fresh branch autoreview against origin/main: clean, no accepted/actionable findings, patch-correct score 0.97.
  • Formatting/whitespace: oxfmt across all 11 changed paths and git diff --check are clean.
  • LOC: production +215/-222 (net -7); tests/support +685/-114.
  • Visual parity, sanitized mocked Gateway data: Before / After. No visual design change.
  • ClawSweeper handling: the latest comment is the exact-head review-started placeholder at fix(ui): stop duplicate Sessions page queries #125018 (comment) and contains no Rank-up moves:. There are therefore no published moves to apply or skip; this was rechecked immediately before posting this proof.

Root cause and owner boundary: the route/page raw loader and canonical-state invalidation bridge independently reloaded one roster demand. The repair makes the shared session capability the single keyed listSnapshot / subscribeList / refreshList owner for route seed, page subscription, filters, reconnects, and mutation tails, and removes the old raw reload path.

@steipete
steipete merged commit 77ecece into main Aug 17, 2026
213 of 250 checks passed
@steipete
steipete deleted the steipete/laughing-easley-d7942d branch August 17, 2026 03:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
Make the Sessions route and page share the managed session-list owner so startup hydration, reconnects, filters, and mutations cannot schedule duplicate raw roster requests. Preserve last-good rows and retire stale query epochs.
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant