Repository navigation
fix(chat): keep a send made during a refresh fetch and leave its run state - #19570
mbriones98 wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] d85dedd Description read[DESCRIPTION-READ] 3fe45cdb0be82d610f93a3c96f8ac57a02c1989b686d3fc94409499d453c52d3 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check the [DESIGN-REVIEWED] d85dedd Description read[DESCRIPTION-READ] 1cd6a3891392544a3e4845f57fade8353ee8b0cebfa7723348996a56553ca02a 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 |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The refresh fix is justified by #19267, but it also quietly changes Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: a message sent as a chat reconnects or a turn ends stays on screen, and its turn keeps running instead of offering Resume. FIX.
[FIRST-PRINCIPLES-REVIEWED] d85dedd Description read[DESCRIPTION-READ] 0ba68471e11b26a16b38c40eb29cc2cd7f2c31590bd8519f30765062c41b234a That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
c2f298a to
b707f39
Compare
|
self-added: yes
|
|
self-added: yes
|
…state refreshSlot.fulfilled rebuilt the transcript from a count-matched page and kept only the head above the page's first row (olderHeadAbovePage), then copied the page's run verdict. A send made while the fetch was in flight (the refresh fires on socket reconnect and on chat_done) is newer than the page, so the rebuild dropped the user's row, and the page -- read before the send -- idled the slot (slotRunning, pendingTurnSlot) under the turn the send opened, offering Resume on a running turn. The liveFrameSeq guard protected only slotState. Give refreshSlot a dispatch-time baseline (liveFromAtDispatch), keep the user rows past it with a sendId the page does not carry (tailNotInPage), and skip the page's idle run verdict when such rows exist -- the pagePredatesLiveSend guard switchSlot.fulfilled already uses (#18658 / #19263). Fixes #19267
b707f39 to
d85dedd
Compare
|
self-added: yes
|
|
Closing this draft: the issue is owned and being worked by its assignee, so this is withdrawn to avoid duplicate effort. The branch is left in place if any of it is useful. |
Problem / Motivation
Goal: A message you send right as a chat reconnects (or right as a turn ends) stays on screen, and the slot keeps running the turn you just started instead of offering Resume.
Send a message at the moment the socket reconnects or a turn finishes, and your row vanishes and the slot goes idle under the turn you just opened — the composer briefly shows the interrupted-turn placeholder and offers Resume, until the reply's first chunk arrives.
Why it matters
The refresh that drops the send fires on every socket reconnect (phone lock/unlock, flaky network) and after every agent turn (
chat_done), so this hits normal use, not an edge case. For those seconds the user sees their own message disappear and a Resume button on a turn that is actually running — they can re-send or hit Resume and double the turn.Not a goal
What changed (motivation → approach → change)
The slot refresh rebuilds the on-screen transcript from a freshly fetched page and keeps only the history sitting above that page's first row. A message sent while the fetch is in flight is newer than the page, so that merge never keeps it, and the page — read before the send — reports the slot idle, which the reducer copied over the running turn the send opened.
switchSlotalready solved this exact race for the deep-link open (#18658 / #19263): it marks a baseline when the fetch goes out and keeps the user's own sends past it, and it skips a stale idle page's run verdict when such a send exists.This gives
refreshSlotthe same two pieces: a dispatch-time row-count baseline (liveFromAtDispatch), the user'ssendIdrows past it that the page does not already carry (tailNotInPage), and apagePredatesLiveSendguard that leavesslotRunning/pendingTurnSlot/ the stream state alone when the idle page predates a live send. The pre-existingliveFrameSeqguard only ever protectedslotState, which is why the run state leaked through before.Backwards compatibility
Compatible: adds one optional payload field (
liveFromAtDispatch) and only adds rows / skips a stale write; a payload without the field falls back to the current row count, i.e. no live sends. Removes nothing.Tests
website/src/test/chatSlice.refreshSlotLiveSend.test.ts(new, 10 cases): a still-optimistic bubble and an echoed one survive a stale page; a send the page caught is not doubled; a row already on screen at dispatch is not rescued; the slot stays running (and off Resume) under an idle page, whether the turn was confirmed by a local start or a serverslotsframe; the chunk floor a reply raised during the fetch is kept; a turn the send failed to open is not revived; a page that caught the send, and a running page, land their verdict as before. Reverting the production change fails 5 of the 10.Manual verification
N/A — the regression is a reducer-level state race fully covered by unit tests; it has no manual repro that the tests do not already assert.
Pattern harvest
Rule candidate: the three slot-detail reducers that rebuild
messagesfrom a fetched page —switchSlot.fulfilled,refreshSlot.fulfilled,warmSlotCache.fulfilled— must share the same baseline-and-guard contract for rows that arrive while the fetch is in flight.switchSlotgrew the live-send baseline and thepagePredatesLiveSendrun-verdict guard (#18658 / #19263) whilerefreshSlotcarried neither, which is this bug. A lint/review check that flags a page-replacing reducer inwebsite/src/store/chat/lacking the live-send baseline +pagePredatesLiveSendguard would catch the family drifting apart again.Screenshots / video
Why no screenshot: This changes only Redux store reconciliation in
website/src/store/chat/slotRefresh.ts; it renders no new or changed UI, so a before/after would be identical.Related Issues
Fixes #19267