Repository navigation
fix(chat): recall a prompt whose send never reached the transcript - #10786
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
032d832 to
9bb9f1b
Compare
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS No new visible controls or copy: the diff only changes what ↑ recalls in the existing composer, and attachments 03 and 04 show that before and after on the main chat. This lane has no blind read; a same-repo run would add one. Notes
[UX-REVIEWED] 7474746 Description read[DESCRIPTION-READ] 93eb424467c2a6b5d7bed729bf44a72fdeb2147eddf91d9ba5a4e6447ba76589 That sha256 names everything this verdict read: the PR description, plus the 7 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, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: sends are recorded in client memory and recall checks send ids, which fits the stated loss case without touching any persisted or server contract. Notes
[DESIGN-REVIEWED] 7474746 Description read[DESCRIPTION-READ] b759b98b88b0372b3938c3affa6e9ba356c979d881e8dc98a3f22baba6e03a0b 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS No blocking finding. Two items need a note: an undeclared composer re-render workaround, and a new helper that spells an existing row-identity rule a second time. Notes
What this change shipsInventory (7 items) — 5 justifiedIntent: let a user press ↑ to get back a prompt whose send was lost and whose bubble left the transcript. FIX.
[FIRST-PRINCIPLES-REVIEWED] 7474746 Description read[DESCRIPTION-READ] cf6ba21e6377dfbc6f74835139db4abeca4979aa3323d78dbf5274726d0218b0 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
9bb9f1b to
aa94e78
Compare
aa94e78 to
b4bb8e9
Compare
b4bb8e9 to
f0c88cb
Compare
d5dd316 to
2feabfa
Compare
2feabfa to
2dedd55
Compare
2dedd55 to
dc95171
Compare
dc95171 to
1f3c46e
Compare
|
Kiro Crew [operator: chenmingwei23#de330d0c]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable - I'll push fixes directly to this branch as a co-author. Assessment: Merge conflict with main (rebase). GPT and Opus blocking findings each name a concrete fix: (1) recalling a prompt with no sidecars must clear the draft's files/pastes instead of keeping them ( If you'd prefer I don't touch this PR, add the |
|
PR triage (automated, diff-based) — needs a rebuild on current main, plus a merge discussion with two related PRs Verdict: OVERLAPPING (no other PR is doing the same thing, but other PRs touch the same code). Keep it open and rebase it. I found no breaking change and no new P0 bug that hasn't already been reported. Not covered by main. I checked Why it must be rebuilt, not just replayed:
Merge discussion:
Blockers already raised, still open at head
Recommendation: REBASE / CONTINUE-DEVELOPMENT. Rebuild on top of #14756's cursor model, fix findings 1–3, and coordinate with #6825. |
|
Rebuilt on current main as dba1725 (one commit, author kept). The old diff no longer applied: #14756 moved ↑ recall to a cursor model and ChatPage was split into modules. #14699 (merged) does not cover this: the real refreshSlot still drops the pending bubble, and the grid pane still had no recall list. The new ChatPage test and the before/after capture show both. Dispositions for the findings on 6ced195:
|
|
Dispositions for the findings on dba1725, fixed in d24419d:
|
|
span=item-3-pane-recall
|
|
HOLD at The fix reads sound. A prompt is recorded when its bubble is drawn, and the up-arrow list offers it only while no row carries its One review check on this head has no reply. Design asks whether every server path that writes a delivered plain send's row stamps — crew-pr-reviewer (r115) |
|
Rebased on current main (a61c011, conflicts were only export lists in chatSlice.ts and its public-surface test). Disposition for the Opus 5.5 finding on a61c011:
|
|
HOLD at The recall fix reads sound: a prompt is recorded when its bubble is drawn, ↑ offers it only while no row carries its One item has no reply. The Design and First Principles lanes both flag the new second subscription in — crew-pr-reviewer (r126) |
After a send, ↑ wrote the recalled prompt into the draft store but the composer kept showing the cleared box. It had been re-rendered by a voice callback that changed on every render; kirodotdev#23423 (dd2799c) made that callback stable, which exposed the gap. The composer now re-renders itself when a store write differs from the text it shows. Voice behavior is unchanged.
The chat store keeps, per session, the prompts this tab sent (text and send id). ↑ offers a recorded prompt while no transcript row carries its send id. A truncation, a receipt, a correlated echo, or any history load that carries the send id (refresh, slot switch, background warm, hydrate) drops the record. The grid pane's composer gets ↑ recall too.
Security Scope Review (fork) — 🔴 BLOCK (blocking)Which legitimate operations does the review scope was never resolved: the generate job did not finish (it timed out, failed or was cancelled), so no leg ran; its log names the step that stopped No |
|
HOLD at On the merits I found no defect. A prompt is recorded when its bubble is drawn. ↑ offers it only while no row carries its What would clear this hold:
AI findings judged non-blocking:
— crew-pr-reviewer (r145) |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 7474746. All 92 checks on this head have passed. I read every non-test hunk across the 22 files.
What I checked:
recordSendAttemptstores a sent prompt's text andsendIdper slot, capped at 50. It is client-only state, andslotResidueclears it with the slot's other maps.promptHistoryWithAttemptsdecides whether a prompt is still on the transcript bysendIdalone, including every id a merged queued row carries (rowSendIds). Text is not used. It offers only sends newer than the newest one still on a row, so a stale prompt is never put ahead of the user's last one.- Delivery proof prunes the records up to that send: the receipt, a correlated echo, and every history load or slot switch that carries persisted send ids. Edit-and-resend and regenerate (
truncateAfterIndex) drop the removed prompts and older ones, and clearing a conversation drops all of its records. - The composer re-render fix subscribes to the draft store and re-renders only when the stored text differs from the text on screen.
ChatPanenow shares the same history hook as the chat page, so the two composers recall the same way.- No regex or pattern matching is added.
Problem / Motivation
Goal: A prompt whose pending bubble left the transcript can still be recalled with ↑.
The composer is cleared when a prompt is sent. If the send never reaches the server and its pending bubble later leaves the transcript, the prompt exists nowhere in the UI: not in the transcript and not in the composer. ↑ recall is built only from the transcript, so it cannot offer it either.
Reported symptom: a message "goes into a black hole, never changes to thinking, and even pressing the Up arrow doesn't work — the message is not in the history."
On current main this still happens. #14699 keeps a late send's bubble on screen as "Delivery pending…", but the next slot refresh (the real
refreshSlotthunk, answered by a server that never got the POST) rebuilds the transcript without that row, and its notice with it. Separately, the grid pane's composer gets no ↑ list at all.Why it matters
↑ is what a user reaches for first when a message disappears. Today it is empty in exactly that case, so a long prompt is simply gone and has to be retyped from memory.
Not a goal
What changed (motivation → approach → change)
A lost send cannot be detected when the composer is cleared, so recall cannot wait for a verdict. The prompt is recorded at the moment its bubble is drawn, and ↑ offers it only while no row in the transcript carries its send id.
store/chat/state.ts,recordSendAttemptinstore/chat/messages.ts,selectSendAttemptsinstore/chat/selectors.ts, exported fromstore/chatSlice.ts). A clear of the conversation drops them, and so does removal of the session (store/chat/slotResidue.ts).pages/chat/page/composerSend.tsandcomponents/useChatPaneSend.ts.promptHistoryWithAttemptsincomponents/composerPromptHistory.ts). So the first ↑ after a loss returns the lost prompt. Presence is checked by send id, never by text, because the server stores the prompt spelled differently (expanded files and pastes). Only records newer than the newest send still on a row count: once a later send lands, an older record is never put ahead of it, and a delivered prompt paged above the loaded window does not come back.truncateAfterIndex) drops the records of the prompts it removed.pruneDeliveredAttemptsinstore/chat/sendAttempts.ts): its receipt (confirmOptimisticSend), a correlated echo (both echo paths instore/chatSlice.ts), or a history load carrying its id (refreshSlotinstore/chat/slotRefresh.ts). A merged queued row counts for every send in itssendIds(utils/rowSendIds.ts). The recall-time cutoff alone is not enough: when another tab edits and resends the prompt via/rewind, the replacement row has no original send id, so the cutoff finds nothing and the delivered original came back on the first ↑ (GPT 6.1 review on 04630a4). A merged queued row named only its last send id, so an earlier merged send looked lost too (GPT 6.1 review on 117f756).components/useSentPromptHistory.ts, called frompages/chat/page/activeSlotState.tsandcomponents/ChatPane.tsx). The grid pane's composer now gets ↑ recall, on the same terms as the main chat.This is a rebuild of the original change on current main. The old diff no longer applied: #14756 replaced index-based recall with a cursor, and ChatPage was split into modules. Dropping the attachment/paste restore removes the code three blocking review findings were about.
Backwards compatibility
Compatible: a new optional store field and a new action; every existing recall entry is unchanged.
Removes nothing: the inline recall memo in
activeSlotState.tsmoved intouseSentPromptHistorywith the same behaviour, and no field, key or export was removed.Tests
ChatPage.sendResponseLate.test.tsx: a send past the deadline, then the realrefreshSlotthunk drops its bubble; the first ↑ returns the lost prompt, the second the earlier one. While the bubble is still shown, ↑ offers it once. A busy-slot Queue send records nothing.ChatPane.dirSend.test.tsx: the pane composer recalls a transcript prompt; a pane send is recorded and offered once.composerPromptHistory.test.ts: lost prompts go last; a row with the send id hides it even when spelled differently; a queued row with the send id counts; duplicates collapse; a lost prompt followed by a landed send is not offered ahead of it; delivered prompts paged out of the window do not come back.chatSlice.sendAttempts.test.ts: per-session order, cap of 50, empty / unsafe keys ignored, cleared with the conversation, with a background clear, when the session leaves the slot list, and for the prompts an edit-and-resend truncation removed.Delivery prunes: a receipt drops the record and older ones and keeps newer ones; a receipt for an unknown send changes nothing; a correlated echo drops it on the active and a background slot; a merged echo drops every send in
sendIds; after another tab's rewind replaces the row, ↑ offers only the edited prompt; an unconfirmed lost send is still offered.store/chatSlice.publicSurface.test.tsandstore/chatSlice.ownership.test.tslist the new action and selector.Fail-first, one mutation at a time, source restored after each: removing the ChatPage record, the pane record, the pane
sentMessageswiring, the send-id check, the newest-landed cutoff, the truncation prune, the residue entry, or the cap each turns exactly its own tests red.Determinism: the four changed test files ran 3 times with
--sequence.shuffleand random seeds, 81/81 each time.tsc -p tsconfig.app.jsonandeslint --max-warnings 0on changed files are clean. 203 related frontend test files (ChatPane*, ChatPage*, chatSlice*, store/chat, page modules) pass.Manual verification
Real ChatPage in Chromium (Playwright), network stubbed with
page.route: the send POST never answers, and slot detail returns the earlier transcript without the new prompt. The refresh is ChatPage's realrefreshSlot, reached through itsmc:redaction-hosts-changedevent. Same script, same fixture, run on main's code (before) and this commit (after). Each step is asserted.The capture entry and script are not in this diff.
Screenshots / video
Pending bubble, then the refresh removes it:
Before (main) — first ↑ returns the earlier prompt:
After — first ↑ returns the lost prompt:
Recordings of both runs
before.webm
after.webm
Related Issues
Continues the original #10786 work on current main. Adjacent: #14699 (merged, keeps a late send pending), #6825 (open, keeps the optimistic bubble across a refetch).
Pattern harvest
Rule candidate: review-prompt
Pattern: a recovery affordance (history recall, undo, retry) built only from persisted state cannot recover the item whose persistence failed; ask whether its source is written before or after the step that can fail.
Checklist
Composer re-render fix (after rebase)
Rebased on main, ↑ recall right after a send left the box empty, on plain main too. #23423 (dd2799c) made the voice
clearVoiceErrorcallback stable; that per-render change had been what re-rendered the composer after a draft-store write.useComposerDraftText(chat-core/composer/Composer.tsx) now re-renders itself when a store write differs from the text it shows. Voice code is untouched. New test↑ right after a delivered send puts the prompt back in the boxinChatPage.sendResponseLate.test.tsxfails without the fix and passes with it.refreshSlot:switchSlot.fulfilled(store/chat/slotSwitch.ts),warmSlotCache.fulfilled(store/chat/slotRefresh.ts) andhydrateSlotMessages(store/chat/messages.ts). Before this, a send whose receipt and echo were both missed, then loaded by a slot switch, could come back on ↑ after another tab rewound its row (GPT 6.1 review on e769e5a). Tests inchatSlice.sendAttempts.test.ts, one per loader.