Repository navigation
perf(ui): reduce automatic session list refetches - #155705
Conversation
Batch session event invalidations over fixed five-second windows and preserve explicit navigation refreshes. Keep cached selected-session lineage from invalidating managed child lists while retaining fresh-read and Gateway-event invalidation.
|
🦞👀 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 22, 2026, 9:27 AM ET / 13:27 UTC (Revision 4). ClawSweeper reviewWhat this changesThe Control UI batches automatic session-list reads into fixed five-second windows, avoids redundant reads when reusing cached ancestry, and updates documentation and timing tests. Merge readiness✅ Ready for maintainer review The optimization remains useful: current main retains the older refresh policy. The previous timing finding is addressed, and this review found no blocking correctness defect. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI consumes Gateway session events to update sidebar, roster, and Activity views. A shared coordinator paces necessary background reads while reconciliation applies already-known session facts. flowchart TD
A[Gateway session events] --> B[Session reconciliation]
B --> C[Immediate row updates]
B --> D[Required list invalidation]
D --> E[Shared refresh coordinator]
E --> F[Gateway session list reads]
G[Navigation and explicit refresh] --> F
F --> H[Sidebar roster and Activity views]
C --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +217, Docs +5. Total +223 across 55 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep automatic pacing in the existing coordinator and cached-lineage handling in the reconciler, preserving immediate explicit reads and authoritative membership checks. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the redundant cached-lineage invalidation path, and the supplied request-budget regression targets the old coordinator; this review did not execute a reproduction. Is this the best way to solve the issue? Yes, the patch extends the existing owners without adding a cache or response-revision protocol, and retains fresh-read, lifecycle, and explicit-refresh behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4502cad0a1f4. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Advance controlled test clocks through the five-second refresh boundary, preserve pre-boundary no-request assertions, and await decoded attachment readiness before opening the recovery account picker.
* commit '739e2410702e0b1ad1d17a6dac07ddc0ab6dbebb': (140 commits) fix(ui): pause passive polling in hidden tabs (#155617) improve(android): keep chat photos outside text bubbles (#155338) fix(ui): preserve saved project after discovery failure (#155619) feat: compare Kitchen Sink Gateway resource costs (#155734) test(gateway): arm clock-jump claim after readiness (#155748) chore(ui): refresh control ui locales (#155700) fix(ci): join archive placement fixtures before teardown (#155751) fix(matrix): keep bot discovery off the Gateway thread (#152122) fix(agents): reconcile late requester recovery receipts (#155357) test(gateway): guard embeddings HTTP fixture lifetimes fix: isolate triage fixture acquisition and cleanup (#155736) refactor(sessions): hydrate saved transcripts off thread (#153325) fix: Claude MCP turns abort before tool timeout (#155663) fix(goals): pause terminal failures and clarify goal states (#155694) fix(test): preserve watcher errors when diagnostic capture fails (#155383) ci: move native runtime proofs to release validation (#155606) fix(auth): decouple compaction from profile rotation (#155204) fix(agents): admit compaction outside retired plugin generations (#151232) perf(ui): reduce automatic session list refetches (#155705) test: avoid unused source repos in release input fixtures (#155733) ...
* perf(ui): reduce automatic session list refetches Batch session event invalidations over fixed five-second windows and preserve explicit navigation refreshes. Keep cached selected-session lineage from invalidating managed child lists while retaining fresh-read and Gateway-event invalidation. * perf(ui): align browser and gateway refresh proof Advance controlled test clocks through the five-second refresh boundary, preserve pre-boundary no-request assertions, and await decoded attachment readiness before opening the recovery account picker. * perf(ui): cover paced refreshes in gateway event tests * perf(ui): keep undo available during queued refresh proof
What Problem This Solves
Busy gateways receive redundant
sessions.listreads from frequent Control UI invalidations and from re-adopting cached ancestry for the selected session.Related: #146410
User Impact
Automatic list refreshes collect events for five seconds and retain the existing latency-based cooldown, now bounded between five and 15 seconds. Locally reconciled row updates remain immediate; navigation, explicit refreshes, and reconnects bypass the event delay. Membership changes that need a server read can appear up to five seconds later when idle.
Why This Change Was Made
Use the existing event-refresh coordinator for a fixed window that continuous events cannot postpone. This removes the sliding deadline and repeated timer replacement. The reconciliation owner also distinguishes fresh reads from cached lineage re-adoption, so reusing an already-held selected-child row does not invalidate its child window. Net production change: +1 line, with no new configuration or cache. Query owners retain their existing scope, lifecycle, pagination, and trailing-invalidation behavior.
Current sidebar/roster code already avoids list reads for reconciled message and row snapshots. Activity and authoritative fallback queries still need pacing. Tests update their fake clocks to the new policy. Keeping one continuous fake clock exposed the cached-lineage loop previously hidden by real timers armed before the fixture switched clocks; the existing sidebar regression now catches it. Fresh descriptor reads still trigger membership checks, and later Gateway events still refresh the child window.
The proposed Gateway
revision/unchangedshortcut is deliberately excluded. The resident projection revision is not a response revision: runner availability, permission state, access, status expiry, child retention, active-window membership, and live runtimes can change independently. Returningunchangedfrom that token would retain stale results. Unchanged-answer share: not applicable; no conditional-response protocol was added.Evidence
A deterministic rig uses two independent viewers, three streaming sessions, and three simulated minutes through the real sidebar, roster, and Activity owners with a stubbed Gateway transport. Each viewer produced the same counts:
session.message, one minuteThat is 79% fewer total reads and 80% fewer event-driven reads. A subsequent person-route change issues its request immediately and absorbs the queued event refresh. The budget regression fails on the original coordinator (
60 > 12) and passes on the candidate. The selected-child regression also failed before the reconciliation repair (3reads instead of the settled-startup2) and passes afterward without loosening its no-refetch assertion. This is synthetic request-volume evidence, not a production deployment or CPU measurement; the three distinct queries are paced independently.Final pushed head
92592560e33f5cc4347f9fbf8850140339b4a0c0: CI run 35732725254 completed successfully with 72 passing jobs, including all 13 browser E2E shards, and no failed or pending checks in the PR rollup. Final UI job walls: 311/338/350 s; the shard covering the Undo correction passed in 569 s.Independent Codex review: scoped-clean through P2 on the final diff and ownership context.
All heavy validation ran through
crabboxusing blacksmith-testbox / openclaw-check. Task-owned leases were stopped after use.tbx_01m348qk4v8g43yfvq4m1hry2a,node scripts/run-vitest.mjs ui/src/lib/sessions/session-refetch-volume.test.ts --maxWorkers=1. Baseline 243 reads/viewer; restoring the original coordinator makes the new budget fail as intended.sessions-read-cache.test.ts, seven selected tests passed, demonstrating independent live/clock/access response inputs.node scripts/check-changed.mjs --base 41f119f66004c2944a79e1aaede0bc77dd35c4d2passed ontbx_01m349j4v3nmptmfyejf51zjvybefore the final cached-lineage correction, including all 25 core-test type graphs. The base is pinned because the advancing remote main otherwise introduces unrelated reverse diffs.tbx_01m34d544e4j8zhycxzkr79zs7: UI production types, all UI test type graphs and shared declarations, lint of 47 changed UI files, and the line-cap check passed.pnpm test ui/src/lib/sessions/session-refetch-volume.test.ts --maxWorkers=1 --reporter=default: 175 ms test execution, 918 ms Vitest wall, 1.77 s test-wrapper wall, and the same 51 reads/viewer.tbx_01m34cr47h8kk595t7pxy2vfgx: 69/69 passed across the selected-child, supplemental-reconciliation, and row-observation owners. Intermediate fixture diagnostics usedtbx_01m34c68tk73dr0yfajt1hgtp2.The first published head exposed four CI jobs requiring follow-up. The Gateway-to-UI fallback test still used 200 ms; the Activity browser clock still advanced one second; and the ownership browser assertion raced the five-second batching boundary. Those fixtures now use the defined five-second boundary, including no-request assertions at 4,999 ms. On
tbx_01m34g76q39rz59pn4245a48dv, Gateway fallback proof passed 5/5 (307 ms execution; 25.86 s cold-worker Vitest wall), the original unchanged E2E shard1/12passed 177/177, and the updated three E2E files passed 25/25 (30.31 s wall). Changed-file lint and line-cap checks passed.The cloud recovery picker failed once in CI before the cloud action, while selecting an account immediately after asynchronous paste. Its unchanged shard replay passed, so the exact lost-click cause remains unconfirmed. The fixture now waits for the decoded attachment and verifies the model menu opened, retaining all account, attachment, and recovery assertions. This is a bounded readiness correction, not a claim that a passing replay proves the original race fixed. Focused single-worker file execution: Activity 5.149 s, ownership 19.321 s, cloud recovery 10.783 s. The initial CI UI checks passed in 316/382/385 s; the follow-up head is tracked by its current checks.
The follow-up CI head passed all 13 UI E2E shards and exposed two remaining 200 ms waits in the Gateway event consumer fixture. Those now use the same five-second UI window, preserving the slow-read cooldown and held-generation churn assertions; the Gateway publisher timing is unchanged. On
tbx_01m34j27j7wywb8zygb0bm1xsx,node scripts/run-vitest.mjs src/gateway/server-methods/session-change-event.test.ts src/gateway/server-methods/session-change-event.fallback.test.ts src/gateway/session-row-event-ancestor-placement.test.ts --maxWorkers=1 --reporter=defaultpassed 41/41 (36.91 s cold-worker Vitest wall; 38.90 s wrapper wall). File execution: 1.713 s, 0.213 s, and 2.479 s respectively. Changed-file lint and the line-cap check passed, and independent review of the final two-line correction was scoped-clean through P2. The task-owned lease was stopped. A source audit of the remaining Gateway/UI consumers found no additional clocks requiring changes.A later CI head passed every selected check except the queued cross-agent Undo browser case. Its five-second automatic-read wait nearly exhausted the six-second Undo toast before agent switching. The fixture now hovers Undo during that deliberate wait, using the existing pause-on-hover behavior and preserving the real click, queued response, pagination, pin, and ownership assertions. Independent review of this one-line correction was scoped-clean through P2. On
tbx_01m34k9t7gqg01nw58p8z0rf5h, the correctedsession-management.archive-undo.e2e.test.tspassed 7/7 withnode scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-management.archive-undo.e2e.test.ts --maxWorkers=1: 20.297 s file execution, 33.04 s Vitest wall. Changed-file lint reported zero warnings/errors and the line-cap check passed; the complete remote invocation took 217.749 s, including shared declaration preparation. The lease was stopped afterward. The preceding shard replay selected a different weighted inventory and hit seven missing-Playwright-ffmpeg setup errors; it is not claimed as a passing or exact reproduction. The helper was installed before the focused run. The original CI failure and source-owned six-second toast lifetime establish the fixture timing conflict; no production toast policy changed.Validation recovery included native sync timeouts resolved with replacement leases. A quiet JSON reporter also tripped the runner's no-output watchdog; the normal progress reporter completed the wide run. Existing timing fixtures were corrected using fake time. The final error fixture proves the newer child is visible before sending a field-free Gateway invalidation, then preserves its exact rejection/error/membership assertions.
Measured changed-test costs
File execution time from single-worker focused runs; helper changes are measured through their existing catalog/session aggregators. The new regression's standalone wrapper wall is reported above. The existing 147-case session aggregator remains below the 30 s exception threshold.
components/app-sidebar.bootstrap-race.test.tscomponents/app-sidebar.catalog-discovery.test.tscomponents/app-sidebar.catalog-events.test.tscomponents/app-sidebar.catalog-hidden-pages.test.tscomponents/app-sidebar.catalog.test.tscomponents/app-sidebar.child-snapshot-freshness.test.tscomponents/app-sidebar.event-lineage.test.tscomponents/app-sidebar.lineage-freshness.test.tscomponents/app-sidebar.lineage-successor.test.tscomponents/app-sidebar.sessions.test.tscomponents/session-data-controller.event-refresh.test.tslib/agents/roster-activity-store.test.tslib/agents/roster-activity-store.transport.test.tslib/sessions/connection-hydration.test.tslib/sessions/event-refresh-coordinator.test.tslib/sessions/index-list.test.tslib/sessions/index-supplemental-reconcile.test.tslib/sessions/index.activity-summary.test.tslib/sessions/index.child-event-refresh.test.tslib/sessions/index.event-refresh.test.tslib/sessions/index.test.tslib/sessions/index.tree-snapshots.test.tslib/sessions/owner-first-roster.test.tslib/sessions/selection-hydration.test.tslib/sessions/session-delete-mutations.test.tslib/sessions/session-mutation-selection.test.tslib/sessions/session-pin-mutations.test.tslib/sessions/session-refetch-volume.test.tslib/sessions/session-roster-refresh.events.test.tslib/sessions/session-roster-refresh.test.tslib/sessions/swarm-activity.integration.test.tslib/sessions/swarm-roster.test.tspages/activity/current-work.test.tspages/activity/session-activity-controller.test.tspages/agents-home/agents-home-page.test.tspages/chat/chat-metadata-session-facts.test.tspages/chat/components/chat-swarm-progress.test.tspages/sessions/sessions-page.typing.test.ts