Repository navigation
fix(chat): never resend reply comments after another tab moves the pane mid-send - #2741
Conversation
…s are acknowledged (#2356)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…age, keep move records until they lapse
|
Review round on d54847a: omo CLEAR; Codex Terra (xhigh) BLOCK with 1 HIGH + 4 MEDIUM, all five reproduced with its scratch tests and fixed in the new head:
Each case is now a test in |
|
Re-review on 9a3ecc0: omo CLEAR; Codex Terra (xhigh) found no HIGH. It confirmed the five earlier cases are fixed and reported these, left unfixed here (fix rounds are capped at one, and each needs cross-tab timing within one storage write or a herdr replacement that reuses the pane ID):
CodeRabbit skipped this PR (no review ran); the omo and Codex reviews above stand in. |
|
Merge note: merged on the omo review (CLEAR at 9a3ecc0), Codex Terra (round-1 HIGH and MEDIUMs reproduced and fixed with tests; round 2 has no HIGH, its narrow-race MEDIUMs are listed above) and green checks. CodeRabbit skipped this head. The agent-only mark race from the issue's last comment is not covered here. |
Fixes #2356.
What was wrong
With two tabs of one browser on the same pane, moving the pane to another workspace from one tab while the other tab's message carrying reply comments was on its way left those comments for the next message:
ReplyCommentStore.forwards, in memory). The sending tab acknowledged under the old pane ID, found nothing there, and the sent comments stayed under the new ID.#2709 (cross-tab send lock) already stops two tabs claiming the same draft, and
carryPaneStateruns inside that lock, so the moving tab sees the other tab's send lease. This builds on it.What changes
src/lib/paneMove.ts: inside the old ID's send lock, the move reads the old draft's send lease from storage (sendLease, from any tab) and passes it toReplyCommentStore.move.src/lib/replyComments.ts:heldFor: { draft, at }, the lease it waits for. Every tab'sunreservedleaves it out while the lease in storage still has thatat, so the hold ends with that exact send (acknowledged, refused, or lapsed afterSEND_LEASE_MS). A comment already held for an earlier send keeps that hold when it moves again.{ movedTo, at }under the old comments key (it reads as no comments, and the prefix is already under the herdr fence ofpaneLifetime.ts).removeSentfollows these records as well as this tab's own; a record older thanSEND_LEASE_MSis not followed. A move of comments still held for an earlier send is recorded too, so a chain of moves is followed to the end. Records are not removed on acknowledgement, since another send may need the same record; they lapse.refreshmakesunreservedreaders read again; the moving tab refreshes them when the lease it moved under ends there.src/lib/composerDraft.ts: the lease parsing moved into the exportedsendLease(unchanged behaviour), plusisSendLeaseKey.Validation
src/lib/paneMove.test.tsmodels each tab as its ownComposerDraftStore+ReplyCommentStoreover one shared storage (the issue's steps). On main it leaves["carried", "for the next message"]under the new ID; with the fix only["for the next message"].bun testpaneMove, replyComments, composerDraft, composerDraftAgentOnly, paneLifetime, diffLineNotes and the Composer tests: 83 pass, 0 fail.bun run check fast: green (typecheck, build, unit 11052 pass / 0 fail).check full, a real two-tab Chromium run.Not covered
ovis:composer-agent-only:<pane>cleared in a separate storage operation from the draft) is a draft-format change and is not touched here.