Repository navigation
perf(ui): stop read acknowledgement storms during gateway drains - #167020
Conversation
Keep automatic read acknowledgements pending through optimistic rollback, and pace transient retries with the Gateway hint and exponential jitter. Share that guard with hidden-run acknowledgements and pause automatic read and identity refresh work during restart or suspension. Synthetic real-Gateway drain proof reduced rejected patches from 1127 to 3 with a missed lifecycle event, and from 1518 to zero with the event delivered. Resume and actual process restart/reconnect both preserved acknowledgements.
|
🦞👀 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 changes before merge. Reviewed October 8, 2026, 3:24 AM ET / 07:24 UTC. ClawSweeper reviewWhat this changesThe PR keeps automatic read acknowledgements pending through optimistic rollback, backs off rejected requests, and pauses acknowledgements and identity refreshes during Gateway unavailability. Example: An open chat encounters a three-second Gateway drain without receiving the lifecycle event
Review scores
ProductKind: Bug fix · Worth it: Yes Merge readiness⛔ Needs changes before merge - 3 items remain This PR addresses a proven request storm, but its reconnect reset can erase a user's manual unread reminder. One focused correction is needed. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe Control UI acknowledges viewed conversations through the Gateway's session API. Its acknowledgement guard coordinates optimistic unread updates, request settlement, and retries while the Gateway retains authoritative session state. flowchart TD
A[Visible chat and session updates] --> B[Gateway availability check]
B -->|Unavailable| C[Pause automatic requests]
B -->|Available| D[Read acknowledgement guard]
D -->|Eligible| E[Gateway session patch]
E --> F[Optimistic update and authoritative result]
F --> D
G[Connection changes] --> D
Technical reviewBest possible solution: Retire connection-scoped pending requests and retry state while preserving the visible chat's activation-marker history until genuine navigation or presentation changes. Do we have a high-confidence way to reproduce the issue? Yes: the supplied baseline regression and real-Gateway drain results establish the request storm. Source also establishes the introduced failure path: mark an already-open chat unread, reconnect without navigating, and let automatic acknowledgement resume. Is this the best way to solve the issue? No, not fully: sharing pending settlement and existing backoff is appropriate, but connection retirement must not create a new user activation that clears a manual reminder. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 017842386a7f. Provenance checked
TestingProof path: shipped entry point. Added test files: 3. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +27, Tests +155, Docs +2. Total +184 across 8 files. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment |
…nclaw#167020) Keep automatic read acknowledgements pending through optimistic rollback, and pace transient retries with the Gateway hint and exponential jitter. Share that guard with hidden-run acknowledgements and pause automatic read and identity refresh work during restart or suspension. Synthetic real-Gateway drain proof reduced rejected patches from 1127 to 3 with a missed lifecycle event, and from 1518 to zero with the event delivered. Resume and actual process restart/reconnect both preserved acknowledgements.
What Problem This Solves
Fixes automatic Control UI read acknowledgements repeatedly issuing
sessions.patchwhile the Gateway drains for a restart or suspension.User Impact
Open chats stop flooding a draining Gateway with read acknowledgements. Identity refreshes and secondary chat reads also pause while the Gateway reports unavailable. Existing manual unread markers and optimistic read feedback are preserved.
Why This Change Was Made
An optimistic
unread=falsepublication cleared the acknowledgement guard before the request settled. A rejected patch restoredunread=truesynchronously, which could send the next patch before the first rejection handler ran. The guard now distinguishes pending work from a confirmed read and applies the server's minimum retry delay with exponential backoff and jitter. Hidden-run acknowledgements use that same guard instead of separate retry handling. Connection changes retire pending acknowledgement state; availability recovery rechecks the visible chat.Production LOC delta: +27. The growth records previously missing pending-request settlement, retry deadlines, and availability recovery; it replaces the hidden-run retry policy rather than adding a competing path. No schema, protocol, configuration, or dependency changes.
Evidence
tbx_01m4cxwhg55q8bf7gvvaya0dw4: the real session store's optimistic rollback produced 2 patches instead of 1. The other 29 read-marker tests passed.node scripts/run-vitest.mjs ui/src/pages/chat/chat-pane.read-marker.test.ts ui/src/lib/sessions/unread.test.ts ui/src/lib/sessions/session-unread-mutations.test.ts ui/src/lib/agents/identity.test.ts --maxWorkers=1passed (7.77 s wrapper wall time; read-marker file 3.01 s wall, approximately 0.66 s test time).ui/src/lib/agents,ui/src/lib/sessions, andui/src/pages/chatpassed withnode scripts/run-vitest.mjs <sibling files> --maxWorkers=2: 5,584 tests passed, two existing benchmark cases skipped, 761.64 s wrapper wall time.tbx_01m4d485g4artqnvn1n2t5yc2n: verified all eight source hashes, staged those exact files in the transport checkout, and rannode scripts/check-changed.mjs --staged --timed(11m 4.658s). All eight test typecheck graphs, UI types, lint, i18n, ratchets, formatting, declaration guard, and dead-export scans passed.pnpm test ui/src/pages/chat/chat-pane.read-marker.test.ts --maxWorkers=1: 34 tests passed, 6.17s wall time, 0.517s summed test execution (CI test cost).node --import ./scripts/tsx.mjs scripts/build-all.mts sourcePerformance; the temporary jsdom rig ran withnode scripts/run-node-package-bin.mts vitest run --config .local/lane617/rig.vitest.config.ts.This is a request-lifecycle change with no visual changes. Validation uses synthetic state and does not require browser automation.
The first shared-rig gate and runtime build were killed by host-wide memory pressure. The runtime build passed with the supported 6 GiB heap setting; the complete gate passed on the dedicated Testbox. Two replacement leases queued/expired before the final runner became available. An initial Testbox
--stagedinvocation selected no paths because native sync does not copy staging; only the explicitly staged eight-file gate above counts as gate evidence.