Repository navigation
fix(ui): stop per-message branch-list polling and unlatch transient branch failures - #124094
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 15, 2026, 4:20 AM ET / 08:20 UTC. ClawSweeper reviewWhat this changesThe PR reduces Control UI branch-list polling, retries branch metadata after failures, normalizes equivalent session keys, and returns an empty list for upstream-linked sessions. Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep open: both prior blocking findings remain on the current head. A failed structural refresh can retain a valid cache marker and suppress the retry, and checkpoint restoration is omitted from the new structural-reason gate. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI receives Gateway session events, refreshes selected-session history and branch metadata, and renders a branch dropdown. Gateway owns branch topology and emits mutation reasons; UI state uses those reasons to decide when cached branch metadata must reload. flowchart LR
A[Session mutation] --> B[Gateway change event]
B --> C[Control UI event handler]
C --> D{Branch topology changed?}
D -->|Yes| E[Branch-list request]
D -->|No| F[Keep cached metadata]
E --> G[Branch dropdown]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -2, Tests +39. Total +37 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Invalidate cached branch ownership under the existing request guard on failure, include checkpoint restoration in the structural branch-refresh contract, and cover both event paths with regressions. Do we have a high-confidence way to reproduce the issue? Yes, from source: a preloaded branch cache followed by a rejected refresh leaves the retry predicate false, and a checkpoint-restore event is excluded from the reload gate. No runtime test was run in this read-only review. Is this the best way to solve the issue? No. The owner-boundary direction is sound, but it must invalidate prior successful state after a failed refresh and handle Gateway's checkpoint-restore producer before it is merge-ready. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a4f61d135a48. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…ranch failures
Four coupled defects around the chat branch dropdown, fixed at their owners:
- Every persisted session.message and every sessions.changed triggered an
unconditional sessions.branches.list RPC per viewing client; the gateway
branch cache watermark is max(seq), so each message append made the next
list a full transcript rescan. Branch topology only changes on structural
mutations, and the producer already records the reason — the reload is now
gated on rewind/branch-switch/fork/reset/new.
- A transient listBranches failure recorded success (chatBranchesSessionKey
set with branches=[]), permanently hiding the branch dropdown for that
session+connection with no visible outcome. The catch no longer latches;
the next history load retries naturally.
- sessions.branches.list errored for upstream-linked sessions even though
"no local branches" is their truthful steady state; the fresh-session
sibling was already converted to {branches: []} for the same reason
(spurious gateway-log failures). Only mutating siblings fail closed now.
- Branch state was keyed by raw session-key spelling and strict-compared in
the header and history gate, blanking the dropdown across the legacy
main -> agent:main:main alias window (same class as #124020); both
compares use areUiSessionKeysEquivalent.
Riders per pathfinder rule: deleted the write-only chatBranchesLoading flag,
a duplicate activeLeafEntryId recompute, and two provably-no-op second
dropPreSessionStartAnnouncePairs passes in chat-history-pages.ts (the filter
is single-pass complete and its inputs were already filtered).
Production LOC +27/-34 (net -7); regression tests fail pre-fix.
8945727 to
0ab98e1
Compare
check-lint-core-4 flagged chat-pane-header.ts at 702 counted lines after the equivalence gate landed there. The branches-for-display decision belongs to the state owner anyway: displayedChatSessionBranches in chat-history.ts now owns it and the header render consumes the fact.
|
Merged via squash.
|
…ranch failures (openclaw#124094) * fix(ui): stop per-message branch-list polling and unlatch transient branch failures Four coupled defects around the chat branch dropdown, fixed at their owners: - Every persisted session.message and every sessions.changed triggered an unconditional sessions.branches.list RPC per viewing client; the gateway branch cache watermark is max(seq), so each message append made the next list a full transcript rescan. Branch topology only changes on structural mutations, and the producer already records the reason — the reload is now gated on rewind/branch-switch/fork/reset/new. - A transient listBranches failure recorded success (chatBranchesSessionKey set with branches=[]), permanently hiding the branch dropdown for that session+connection with no visible outcome. The catch no longer latches; the next history load retries naturally. - sessions.branches.list errored for upstream-linked sessions even though "no local branches" is their truthful steady state; the fresh-session sibling was already converted to {branches: []} for the same reason (spurious gateway-log failures). Only mutating siblings fail closed now. - Branch state was keyed by raw session-key spelling and strict-compared in the header and history gate, blanking the dropdown across the legacy main -> agent:main:main alias window (same class as openclaw#124020); both compares use areUiSessionKeysEquivalent. Riders per pathfinder rule: deleted the write-only chatBranchesLoading flag, a duplicate activeLeafEntryId recompute, and two provably-no-op second dropPreSessionStartAnnouncePairs passes in chat-history-pages.ts (the filter is single-pass complete and its inputs were already filtered). Production LOC +27/-34 (net -7); regression tests fail pre-fix. * refactor(ui): move branch-display ownership out of the header render check-lint-core-4 flagged chat-pane-header.ts at 702 counted lines after the equivalence gate landed there. The branches-for-display decision belongs to the state owner anyway: displayedChatSessionBranches in chat-history.ts now owns it and the header render consumes the fact.
…ranch failures (openclaw#124094) * fix(ui): stop per-message branch-list polling and unlatch transient branch failures Four coupled defects around the chat branch dropdown, fixed at their owners: - Every persisted session.message and every sessions.changed triggered an unconditional sessions.branches.list RPC per viewing client; the gateway branch cache watermark is max(seq), so each message append made the next list a full transcript rescan. Branch topology only changes on structural mutations, and the producer already records the reason — the reload is now gated on rewind/branch-switch/fork/reset/new. - A transient listBranches failure recorded success (chatBranchesSessionKey set with branches=[]), permanently hiding the branch dropdown for that session+connection with no visible outcome. The catch no longer latches; the next history load retries naturally. - sessions.branches.list errored for upstream-linked sessions even though "no local branches" is their truthful steady state; the fresh-session sibling was already converted to {branches: []} for the same reason (spurious gateway-log failures). Only mutating siblings fail closed now. - Branch state was keyed by raw session-key spelling and strict-compared in the header and history gate, blanking the dropdown across the legacy main -> agent:main:main alias window (same class as openclaw#124020); both compares use areUiSessionKeysEquivalent. Riders per pathfinder rule: deleted the write-only chatBranchesLoading flag, a duplicate activeLeafEntryId recompute, and two provably-no-op second dropPreSessionStartAnnouncePairs passes in chat-history-pages.ts (the filter is single-pass complete and its inputs were already filtered). Production LOC +27/-34 (net -7); regression tests fail pre-fix. * refactor(ui): move branch-display ownership out of the header render check-lint-core-4 flagged chat-pane-header.ts at 702 counted lines after the equivalence gate landed there. The branches-for-display decision belongs to the state owner anyway: displayedChatSessionBranches in chat-history.ts now owns it and the header render consumes the fact.
What Problem This Solves
Four coupled defects around the chat branch dropdown, found by round-5 web-UI QA:
session.messageand everysessions.changedmade each viewing Control UI client issue an unconditionalsessions.branches.listRPC. The gateway branch cache watermark ismax(seq)over transcript events, so every message append invalidated it and the miss path re-loaded and re-scanned the full transcript — to refresh a dropdown that renders only when more than one branch exists.chatBranchesSessionKeyset,branches=[]) on any error, so a single network/gateway hiccup hid the branch dropdown for that session+connection forever with no visible outcome and no recorded reason — the worst bug class per the Product Doctrine. (Landing fix 1 alone would have made this latch permanent, which is why they land together.)sessions.branches.listrespondedINVALID_REQUESTfor upstream-linked sessions even though "no local branches" is their truthful steady state. The fresh-session sibling was already converted from error to{branches: []}for exactly this reason (the inline comment documents the spurious gateway-log failures it fixed); only the mutating siblings (rewind/switch/fork) must fail closed.main→agent:main:maincanonicalization window — the same class fix(ui): use session-key equivalence for active-row lookups in model/thinking/fast-mode paths #124020 fixed at six sites two days ago; these two were missed.Why This Change Was Made
Branch topology changes are produced exclusively by the rewind/switch/fork mutations, which already record the reason on
sessions.changed— the recorded fact at the producer replaces polling at the consumer ("record facts where they happen; read them where they are needed"). Tradeoff named: the active branch'smessageCount/updatedAtin the rarely-open dropdown can go slightly stale between structural events.Pathfinder riders in the same files: deleted the write-only
chatBranchesLoadingflag, a duplicateactiveLeafEntryIdrecompute, and two provably no-op seconddropPreSessionStartAnnouncePairspasses inchat-history-pages.ts(the filter is single-pass complete and both inputs were already filtered).User Impact
Idle Control UI viewers stop generating one full-transcript gateway scan per incoming message; the branch dropdown recovers from transient failures instead of vanishing permanently; upstream-linked sessions stop producing spurious gateway error logs on every load; the dropdown no longer blanks during session-key canonicalization.
Evidence
{branches: []}while switch still rejects.node scripts/run-vitest.mjs run ui/src/pages/chat/chat-history.test.ts src/gateway/server-methods/sessions-rewind.test.ts src/gateway/server-methods/chat-history-pages.test.ts src/gateway/server-methods/chat-history-handler.test.ts— 60/60 green;ui/src/pages/chat/chat-state.test.ts+chat-send.test.ts— 344/344 green.pnpm tsgo,pnpm tsgo:ui,pnpm check:test-types, oxfmt/oxlint clean; autoreview clean (0.99).Production LOC +27/−34 (net −7); tests +51/−12.