Repository navigation
fix(ui): avoid duplicate session refreshes during startup - #114764
vincentkoc merged 6 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 3:06 AM ET / 07:06 UTC. ClawSweeper reviewWhat this changesThe PR stops same-connection Gateway metadata snapshots from triggering duplicate Control UI Merge readiness⛔ Blocked until stronger real behavior proof is added - 3 items remain The PR has a narrow, plausible fix for redundant Control UI session hydration and no remaining line-level correctness finding from the reviewed diff. It should stay open because the submitted real-browser evidence is tied explicitly to commit Priority: P2 Review scores
Verification
How this fits togetherThe Control UI session sidebar listens to Gateway connection snapshots and session events, then requests the Gateway session list to hydrate its visible rows. Gateway metadata changes can publish additional snapshots on an unchanged connection, so the session capability must distinguish connection transitions from non-session metadata updates. flowchart LR
A[Gateway connection] --> B[Gateway snapshot]
B --> C{Connection changed?}
C -->|Yes| D[Session hydration]
C -->|No: metadata only| E[Keep current session list]
D --> F[sessions.list request]
F --> G[Control UI session sidebar]
H[Session events and mutations] --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +113. Total +113 across 3 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep connection transitions, session events, and explicit mutations as the authoritative refresh owners, then attach one redacted current-head trace or recording that shows metadata-only snapshots do not add a request while reconnect still hydrates the sidebar. Do we have a high-confidence way to reproduce the issue? No high-confidence fresh reproduction was established in this review. The source and focused tests make the duplicate path reproducible in principle, while the PR body supplies prior live evidence for an earlier verified head. Is this the best way to solve the issue? Unclear. Restricting hydration to connection transitions is the narrowest maintainable design if the refreshed proof confirms that session-relevant reconnect and event paths remain authoritative. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c903ca8158d7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
7bab767 to
425baad
Compare
b8bb37a to
f957790
Compare
f957790 to
08dbd18
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
ca3ed85 to
9deaed8
Compare
|
Maintainer repair/proof update for
The fix is narrow and removes obsolete test expectations instead of adding fallback behavior. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Final exact-head CI update: all checks have settled with zero failures and zero pending jobs, including Control UI unit tests, Control UI E2E, and |
|
Maintainer proof reconciliation for current head The live browser + Gateway proof was captured at So the current-head production behavior is exactly the behavior exercised by the live one-request trace. The final test adjustment aligns reconnect expectations with the single authoritative hydration path; exact-head focused tests, lint, autoreview, and remote proof are already clean. The unrelated UI E2E rerun is still settling. This explicitly addresses the prior rank-up request rather than silently skipping it: duplicating the live Gateway capture would exercise unchanged production bytes. @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Exact-head CI follow-up at
This preserves @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Landing-gate follow-up: fixed the unrelated packed-shard order dependency exposed by exact-head CI. Proof on
Exact-head CI is now the combined packed-shard proof. @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
* origin/main: test(codex): de-flake attempt turn-watch timing tests (#115258) fix: preserve retryable ACPX lease ownership (#115247) fix: serialize ACPX lease ownership transitions fix: retain ACPX leases across wrapper reconnects refactor: parse ACPX lease command identity fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752) refactor(config): retire compaction truncateAfterCompaction gate (#115206) improve(ui): reduce duplicate chat startup work (#114743) fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221) perf(pr): cache complete small file lists (#115199) perf(sqlite): skip no-op automatic schema repair (#115193) docs(browser): correct Docker sandbox setup (#115254) fix(ui): avoid duplicate session refreshes during startup (#114764) # Conflicts: # ui/src/pages/agents/panels-tools-skills.browser.test.ts
* origin/main: test(codex): de-flake attempt turn-watch timing tests (#115258) fix: preserve retryable ACPX lease ownership (#115247) fix: serialize ACPX lease ownership transitions fix: retain ACPX leases across wrapper reconnects refactor: parse ACPX lease command identity fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752) refactor(config): retire compaction truncateAfterCompaction gate (#115206) improve(ui): reduce duplicate chat startup work (#114743) fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221) perf(pr): cache complete small file lists (#115199) perf(sqlite): skip no-op automatic schema repair (#115193) docs(browser): correct Docker sandbox setup (#115254) fix(ui): avoid duplicate session refreshes during startup (#114764)
…14764) * fix(ui): avoid duplicate startup session refreshes * fix(ui): remove redundant hydration return * test(ui): prove session hydration reconnect ownership * test(ui): align reconnect proof with single hydration * test(ui): wait explicitly for catalog startup * test(ui): isolate tool anchor navigation state --------- Co-authored-by: scotthuang <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
Related: #114693
What Problem This Solves
Fixes an issue where users refreshing the Control UI would trigger a second identical
sessions.listrequest during startup. Recovery-scope and Canvas metadata publish additional Gateway snapshots on the same connection; the sessions capability treated each snapshot as a reason to queue another list refresh, adding redundant Gateway work and extending the startup tail.Why This Change Was Made
Only Gateway connection transitions now own connection hydration. Same-client, same-phase snapshot updates no longer refresh the session list; reconnects, client replacements, session events, and explicit mutations keep their existing authoritative refresh paths.
This is intentionally scoped to the snapshot trigger rather than adding request caches or hydration handoff state.
User Impact
Control UI startup now sends one session-list request instead of two in the reproduced refresh path. This removes 50% of the
sessions.listrequest count and avoids one redundant tail request per refresh.Evidence
Measured against base
d3026c3b9038f8fdd8a444ad1b0f70bd0e35e8f9(2026-07-27T15:40:04-06:00). No session keys, message content, connection IDs, or credentials are included.Live browser + Gateway proof
A rebuilt Control UI was served from the exact PR branch while Playwright connected to the live local Gateway. Three page starts used the same browser context.
sessions.listrequests per page start582 ms, mean605 ms(range521–735 ms)The deterministic comparison is request count: 2 → 1 (-50%). The duplicate-duration figures summarize the baseline request that no longer occurs after this change.
Primary-request timings are retained only as diagnostic context. The baseline Gateway durations were
3298 ms,3158 ms,2426 ms, and3214 ms; the exact-branch browser-observed durations are shown below. They are not a valid latency A/B comparison because the captures had different Gateway load, request workloads, and timing boundaries.Redacted exact-branch output (diagnostic only):
Focused tests
The regression test holds the initial hydration request open, publishes two same-client metadata snapshots, then proves no queued second list request is issued.
Build and static checks
Review
AI-assisted: yes. I reviewed the final two-file diff, the Gateway snapshot lifecycle, event-owned refresh paths, focused regression proof, and live request-count evidence.
Maintainer exact-head verification
Verified head:
08dbd1827da0b21b860d4e50b85468b6d7aa8720on reviewed basecb167acf5e4.Sanitized direct AWS proof used a fresh public-network lease with no Tailscale, no instance role, no hydration, and the trusted untrusted-source bootstrap. The bootstrap verified the exact PR head before executing repository code.
git diff --check: passed.The removed fallback was not a general session-state freshness owner: after a list existed it was already a no-op, and during an in-flight hydration it only queued an unscoped duplicate. Real disconnect/reconnect transitions still clear state and enter the authoritative connection hydration path, now covered explicitly.