Repository navigation
fix(chat): keep a send made during a slot refresh and its run state - #25630
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The change is limited to the chat store's refresh logic and its tests. It adds or changes no control, copy or layout, so the missing blind read leaves no evidence gap. [UX-REVIEWED] 7577614 Description read[DESCRIPTION-READ] 010af05289e42a37155eba41e8dbc814b80c8fdf118a0e69c30b4885f6cce7d7 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Mechanism-level fix with linked issue #19267 and tests that fail on main; every item serves the Goal. What this change shipsInventory (5 items) — 5 justifiedIntent: a message the user sends while the open slot is refreshing stays on screen, and the slot stays busy with that turn. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 7577614 Description read[DESCRIPTION-READ] 5219238cf70debfcb12b668cf02468b9670f55620b3bc917e66cbc6303817056 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it applies the existing Notes
[DESIGN-REVIEWED] 7577614 Description read[DESCRIPTION-READ] 535b7555ed0b29b31740339846eb1ac95f985b2baa0d152ea1a15735aae3b340 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
3edb6f1 to
43aced2
Compare
43aced2 to
359b920
Compare
359b920 to
120a2e7
Compare
120a2e7 to
53acaa2
Compare
refreshSlot fires on socket reconnect and on chat_done and rebuilds the
open transcript from a page read before a send made during the fetch, so
the user's row vanished until the next refresh, and the page's
running: false idled the slot under the turn the send opened ("user row
last, slot idle", which offers Resume).
The thunk now records the sendIds on screen at dispatch; the reducer
keeps user rows with a newer sendId that the page does not carry, after
the page and ahead of queued bubbles, and then skips the page's idle
verdict (slotRunning, pendingTurnSlot, stream settle, chunk floor), the
pagePredatesLiveSend guard switchSlot.fulfilled already applies.
Fixes #19267
53acaa2 to
7577614
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Approve at 7577614cb310d02e6a7c5d87f4d92c14787c9db0.
The refresh now captures row identities before its first await and, when the fetched page predates a send, puts the user's row back after the page (above the permission card or live reasoning its turn raised) and keeps the local run state. The thunk already declines when the slot is not active at dispatch (slotRefresh.ts#L112-L125), and the idle page's recordEndedTurn only records the pre-send turn, so the next running page for the new turn still lands (runState.ts#L91-L115). Every state write the guard skips is gated on pagePredatesLiveSend alone, so a refresh with no live send behaves as before. The new reducer tests cover the cases the description lists. All AI lanes are clean on this head and CI is green.
AI findings judged non-blocking
- Design Review (Note): the live-send guard is duplicated in
slotRefresh.tsandslotSwitch.ts; a shared helper is suggested. Does not block: a maintainability suggestion with no behaviour impact; the two copies match today (slotSwitch.ts#L683-L708).
— crew-pr-reviewer (r135)
Problem / Motivation
Goal: a message sent while the open slot is being refreshed stays on screen, and the slot stays busy with the turn it opened.
refreshSlot.fulfilled(website/src/store/chat/slotRefresh.ts) rebuilds the active transcript from a fetched page and copies that page's run verdict. The refresh fires on socket reconnect and onchat_done. A send made while the fetch is in flight is in neither half of the page:running: falseidles the slot under the turn the send opened.Why it matters
The user's own message disappears right after they send it, and "user row last, slot idle" is the shape
selectContinuableoffers Resume on, so the composer swaps to the interrupted-turn placeholder until the first chunk arrives. #19263 fixed the same shape for the deep-link open (switchSlot).Not a goal
warmSlotCache(background panes) andswitchSlot, which already handle this.Intended? / Repro
Intended? No. The issue is the deferred First Principles finding on #19263;
switchSlot.fulfilledalready keeps these rows and run state (website/src/store/chat/slotSwitch.ts:601-604,:683-690).Repro (read on current main):
slotRefresh.ts:381-570(refreshSlot.fulfilled) buildsstate.messagesfromolderHead + page + preserved permissions/thinking/queueand nothing else, then setsstate.slotRunning = running(:534) andstate.pendingTurnSlot = null(:556) unconditionally. A user row appended after the refresh was dispatched (an optimistic bubble, or its echo) is not in the page, so it is dropped; the slot goes idle under the new turn. TheliveFrameSeqcheck guards onlyslotState.What changed (motivation → approach → change)
Symptom: the sent row vanishes and the slot idles. Cause: no dispatch-time baseline. Change: the
switchSlotguard, applied to the refresh.idsAtDispatch, the identities (rowIdentities:midandsendId) of the rows on screen before the first await. By id, not row index, because rows can be added or removed during the round trip.liveSendsSince(rows, idsAtDispatch, rebuilt, queue): user rows below the last row that was on screen at dispatch, whosesendIdis not in that baseline, not in the page'squeue, and not already in the rebuilt transcript by identity (tailNotInPage). The position cut keeps older history paged in during the round trip (prepended above the dispatch rows, withsendIds the baseline never saw) from being read as new sends.refreshSlot.fulfilled: puts those rows back after the page, ahead of any queued bubbles, in send order, and above every kept row that followed them on screen (matched byrowIdentities, the permission/elicitation key, or a live reasoning row'sclientTs), so a permission card the send's turn raised stays below its send and the approval bar still finds it, and the turn's live reasoning stays under its own prompt. When there are such rows and the page reports idle (pagePredatesLiveSend), it keeps the local run state:slotRunning,slotStopping,pendingTurnSlot, the stream-state settle and the chunk floor are left as the send set them. A page that caught the send, or reports running, lands as before.Screenshots / video
Why no screenshot: no layout, copy or style changes. A row the refresh used to drop stays where the send put it, and the composer keeps the placeholder it already showed, the same class of fix as #19263. The race needs a send inside a refresh's round trip; the reducer tests below pin it.
Backwards compatibility
Compatible. A refresh with no send during its fetch behaves exactly as before (empty
liveSends).Removes nothing: no key, field or error path is removed.
Tests
website/src/test/chatSlice.refreshSlotLiveSend.test.ts(new, in the style ofchatSlice.switchSlotLiveSend.test.ts):mid;queue, or a queued send that drained while the page was in flight;selectSlotPendingApprovalstill returns it;loadOlderMessagesduring the round trip as a send: it stays once, as the older head, and the idle verdict lands;slotRunningandpendingTurnSlot, and no Resume offer, when an idle page predates the send (fails on main);Proof: not provable -- other: this host runs no local tests; CI runs them
Manual verification
N/A: a timing race. Static gates run locally:
tsc --noEmit, eslint.Related Issues
Fixes #19267
Sibling sweep
Swept: git grep -n "pagePredatesLiveSend|liveSends" -- website/src/store
Sibling: website/src/store/chat/slotSwitch.ts -- not affected (already has the guard)
Sibling: website/src/store/chat/slotRefresh.ts
warmSlotCache-- not affected (a background pane; it keeps tail rows through its owntailNotInPagecut)Pattern harvest
Not generalizable: the second of two slot-page reducers given the same guard.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.