Skip to content

fix(chat): keep a send made during a slot refresh and its run state - #25630

Merged
iamwhatever merged 1 commit into
mainfrom
fix/refresh-slot-live-send-19267
Oct 29, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/refresh-slot-live-send-19267

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 on chat_done. A send made while the fetch is in flight is in neither half of the page:

  • Rows: the refresh has no baseline, so the user's row is dropped from the view until the next refresh.
  • Run state: the page was read before the send, so running: false idles 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 selectContinuable offers 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) and switchSlot, which already handle this.
  • Keeping a streaming reply that started during the fetch (the refresh's existing live-frame guard covers the stream state).

Intended? / Repro

Intended? No. The issue is the deferred First Principles finding on #19263; switchSlot.fulfilled already 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) builds state.messages from olderHead + page + preserved permissions/thinking/queue and nothing else, then sets state.slotRunning = running (:534) and state.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. The liveFrameSeq check guards only slotState.

What changed (motivation → approach → change)

Symptom: the sent row vanishes and the slot idles. Cause: no dispatch-time baseline. Change: the switchSlot guard, applied to the refresh.

  • Thunk: records idsAtDispatch, the identities (rowIdentities: mid and sendId) 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, whose sendId is not in that baseline, not in the page's queue, 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, with sendIds 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 by rowIdentities, the permission/elicitation key, or a live reasoning row's clientTs), 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 of chatSlice.switchSlotLiveSend.test.ts):

  • keeps the optimistic bubble when the page predates the send (fails on main);
  • keeps the echoed bubble with its server mid;
  • does not double a send the page caught;
  • does not rescue a row that was already on screen at dispatch;
  • does not double a send the page lists in its queue, or a queued send that drained while the page was in flight;
  • keeps the rescued send above the permission card its turn raised, so selectSlotPendingApproval still returns it;
  • keeps the rescued send above the live reasoning its turn streamed;
  • does not treat older history paged in by loadOlderMessages during the round trip as a send: it stays once, as the older head, and the idle verdict lands;
  • keeps slotRunning and pendingTurnSlot, and no Resume offer, when an idle page predates the send (fails on main);
  • takes the idle verdict when no send happened, and when the page caught the send.

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 own tailNotInPage cut)

Pattern harvest

Not generalizable: the second of two slot-page reducers given the same guard.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 29, 2026 03:52
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 7577614cb310d02e6a7c5d87f4d92c14787c9db0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7577614cb310d02e6a7c5d87f4d92c14787c9db0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 ships

Inventory (5 items) — 5 justified

Intent: 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.

  1. A send made during a refresh's round trip no longer vanishes from the transcript — justified
  2. The slot stays running after an idle page that predates the send, so no Resume placeholder appears — justified
  3. The rescued send stays above the permission card and live reasoning its turn raised — justified
  4. Older history paged in during the fetch is not mistaken for a new send — justified
  5. The chunk floor and pending-turn marker survive an idle page that predates the send — justified

[FIRST-PRINCIPLES-REVIEWED] 7577614

Description read

[DESCRIPTION-READ] 5219238cf70debfcb12b668cf02468b9670f55620b3bc917e66cbc6303817056

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7577614cb310d02e6a7c5d87f4d92c14787c9db0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: it applies the existing switchSlot live-send guard to refreshSlot in the same reducer layer, the new tests cover the race, and it removes nothing.

Notes

  • liveSendsSince and the pagePredatesLiveSend gating now exist in both slotRefresh.ts and slotSwitch.ts. If the guard changes again, a shared helper in transcript.ts would stop the two reducers drifting apart, which hydrateQueuedBubbles was already introduced to prevent.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7577614cb310d02e6a7c5d87f4d92c14787c9db0 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7577614

Verdict parsed from the review's SHA-scoped output markers for commit 7577614cb310d02e6a7c5d87f4d92c14787c9db0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7577614cb310d02e6a7c5d87f4d92c14787c9db0 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7577614cb310d02e6a7c5d87f4d92c14787c9db0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7577614

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7577614cb310d02e6a7c5d87f4d92c14787c9db0 false-positive: <reason, 20 to 500 characters>

@CrysisDeu
CrysisDeu force-pushed the fix/refresh-slot-live-send-19267 branch from 3edb6f1 to 43aced2 Compare October 29, 2026 04:01
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/refresh-slot-live-send-19267 branch from 43aced2 to 359b920 Compare October 29, 2026 11:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/refresh-slot-live-send-19267 branch from 359b920 to 120a2e7 Compare October 29, 2026 11:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/refresh-slot-live-send-19267 branch from 120a2e7 to 53acaa2 Compare October 29, 2026 12:27
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 29, 2026
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
@CrysisDeu
CrysisDeu force-pushed the fix/refresh-slot-live-send-19267 branch from 53acaa2 to 7577614 Compare October 29, 2026 12:59
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts and slotSwitch.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)

@iamwhatever
iamwhatever merged commit ae1289c into main Oct 29, 2026
93 checks passed
@iamwhatever
iamwhatever deleted the fix/refresh-slot-live-send-19267 branch October 29, 2026 16:53
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refreshSlot.fulfilled drops a send made during the refresh fetch and idles the slot under its turn (reconnect / chat_done sibling of #19263)

2 participants