Repository navigation
fix: keep paste chip content when up/down recalls a prompt - #31488
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix works at the mechanism level: history entries now keep the paste blocks the row and send record already store. Every caller of the history step is wired to it, and the tests fail on base for #29722. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: A user who presses Up to resend a prompt, or Down to return to a draft, should send the pasted content and not the placeholder tokens. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] f1b3407 Description read[DESCRIPTION-READ] 8d069feef57dc640b00745a959444ebc42086ba4b56f4b3b2b429a9cc0d5860d That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the fix adds no new control or copy, and it brings back the existing paste-chip look on recalled prompts, which the after screenshots show in both themes. Notes
[UX-REVIEWED] f1b3407 Description read[DESCRIPTION-READ] 588f95032ed284aeaa25378b1980e641b6607669706e286e56dc8717ff1e8c45 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) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: each history entry now carries the paste blocks it already has, all fields are optional, and the send record stays in memory, capped and pruned. [DESIGN-REVIEWED] f1b3407 Description read[DESCRIPTION-READ] 22557fcd73f6b6c9bf859a95724314b4c1236dde7a4d0e7d36c926491bb08375 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: |
ca18895 to
fe6ff53
Compare
|
Rebased: main moved in website/src/components/ChatInput.tsx, website/src/components/chat-input/keyboard.ts, website/src/components/useChatPaneSend.ts and test/test_security_gate_liveness.py since this head went green (b3c17ad -> 689d1e6); CI re-running. The two red Backend Tests shards were the security package line-budget test, which failed on main at the time and is fixed there by #31469; the patch is unchanged, and the related frontend tests (91 files) and the app typecheck pass on the new base. [operator: bolichen97] |
Up-arrow recall put a sent prompt's [ Paste #N ] tokens back in the composer without the blocks behind them, so the resend carried the literal token text instead of the pasted lines. Down-arrow back to the draft lost the draft's own blocks the same way. Each history entry now carries the blocks its row (or its send record) already holds, the browse cursor keeps the draft's blocks, and both composers install them with the recalled text. Closes #29722
fe6ff53 to
f1b3407
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on f1b3407, no conflict, no open change request.
Up recalls a sent prompt only from an empty composer. With a draft (typed text or a paste chip), Up only moves the caret and stops at the top line, so pressing it past the first line no longer replaces the draft. The Recall Sent Messages with Arrow Keys hint no longer promises recall with the cursor at the start of a draft. Builds on #31488, whose paste-block restore path is kept unchanged. Fixes #31851
Up-arrow recall put a sent prompt's [ Paste #N ] tokens back in the composer without the blocks behind them, so the resend carried the literal token text instead of the pasted lines. Down-arrow back to the draft lost the draft's own blocks the same way. Each history entry now carries the blocks its row (or its send record) already holds, the browse cursor keeps the draft's blocks, and both composers install them with the recalled text. Closes #29722 (cherry picked from commit 1eb1d21) Backport note: ChatInput.tsx keeps release's fireComposer argument (main's sendOrOptimize is not on release) and adds only onPasteBlocksChange to useComposerKeyDown. messages.ts keeps release's imports (main's toolReturned import is not on release) and adds only type SendAttempt.
Up recalls a sent prompt only from an empty composer. With a draft (typed text or a paste chip), Up only moves the caret and stops at the top line, so pressing it past the first line no longer replaces the draft. The Recall Sent Messages with Arrow Keys hint no longer promises recall with the cursor at the start of a draft. Builds on #31488, whose paste-block restore path is kept unchanged. Fixes #31851
Up recalls a sent prompt only from an empty composer. With a draft (typed text or a paste chip), Up only moves the caret and stops at the top line, so pressing it past the first line no longer replaces the draft. The Recall Sent Messages with Arrow Keys hint no longer promises recall with the cursor at the start of a draft. Builds on #31488, whose paste-block restore path is kept unchanged. Fixes #31851
…ts (#31852) Up recalls a sent prompt only from an empty composer. With a draft (typed text or a paste chip), Up only moves the caret and stops at the top line, so pressing it past the first line no longer replaces the draft. The Recall Sent Messages with Arrow Keys hint no longer promises recall with the cursor at the start of a draft. Builds on #31488, whose paste-block restore path is kept unchanged. Fixes #31851
Problem / Motivation
Goal: A prompt brought back with Up, or a draft brought back with Down, keeps its paste chips' content, so sending it delivers the pasted lines.
Paste a 6-line block, type " and ", paste an 8-line block, send, press Up on the empty composer and send again: the second message reached the model as the literal text
[ Paste #1 · 6 lines ]/[ Paste #2 · 8 lines ], with none of the pasted lines, and the recalled chips showed as plain text. A draft's chips died the same way after Up and then Down back to the draft.Why it matters
Resending a recent prompt with Up is a habit. When that prompt held a large paste (code, logs, a query result), the agent silently gets placeholder text instead of the content and answers about nothing; the user sees no error.
Not a goal
What changed (motivation → approach → change)
meta.pastesblocksA sent prompt's text holds
[ Paste #N ]tokens whose content lives in paste blocks beside the text, and a send clears those blocks from the composer. The prompt-history list incomposerPromptHistory.tscarried only text, so a recall wrote the tokens back with nothing behind them: dead text, sent verbatim.Each history entry now carries the blocks its row already stores on
meta.pastes, or that its send record keeps:recordSendAttempt(store/chat/messages.ts, typed bySendAttemptinstore/chat/state.ts) stores them, and both writers (the main chat'scomposerSend.tsand the split pane'suseChatPaneSend.ts) pass them. The browse cursor keeps the draft's blocks as well. Both composers, the textarea (draftHistory.ts, wired throughkeyboard.tsandChatInput.tsx) and the rich editor (LexicalComposerInput.tsx), install a step's blocks together with its text (none for an entry that has none), so the token is a chip again and the send expands it.Backwards compatibility
Compatible: every new field (
pasteson a history entry, a history step and a send record,draftPasteson the cursor) is optional, and nothing that is accepted today is refused.Removes nothing: the diff only adds optional fields and passes existing blocks along; no key, record, path or export is taken away.
Tests
website/src/test/ChatPane.pasteSidecar.test.tsx, "↑ recalls a sent prompt with its paste blocks, so the resend carries the pasted lines": the real pane, two pastes, send, Up, send; the resend's wire text equals the first send's (both pastes' lines, no token).website/src/test/LexicalComposerInput.test.tsx, "recalls a sent prompt with its paste blocks, so its token comes back as a chip": the rich editor shows the recalled token as a chip and holds its block, and an older entry with no pastes leaves none behind.website/src/test/chatSlice.sendAttempts.test.ts, "a lost send is offered with its paste blocks, so ↑ recalls a token that still expands": the send record keeps the blocks and the history entry carries them.With the production hunks reverted all four fail (4 failed, 76 passed in those three files); with them, all pass. Determinism: the three files 20 times, each with
--sequence.shuffleand a fresh--sequence.seed: 20/20 green. The frontend related set (91 files, 1314 tests),tsc -p tsconfig.app.json, eslint on the changed files, jscpd and the repository semgrep rules on the diff are green; the backend cross-surface set is left to CI.Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
The real built dashboard, served on loopback with every API call stubbed, opened on a chat whose sent prompt carries two pastes; Up in the empty composer, then Enter, in both themes. On
mainthe posted message wasWhy do these jobs stay stuck? Query:\n[ Paste #1 · 6 lines ]\n and the result:\n[ Paste #2 · 8 lines ]. On this branch it carried all 14 pasted lines and no token, and the composer showed both tokens as chips.Screenshots / video
The composer right after Up. Before (main): the tokens are plain text with nothing behind them. After: both are chips again.
Related Issues
Closes #29722
Sibling sweep
Swept: git grep -nE "stepPromptHistory(|recordSendAttempt(" -- website/src
Sibling: website/src/components/chat-input/draftHistory.ts -- changed here
Sibling: website/src/components/LexicalComposerInput.tsx -- changed here
Sibling: website/src/pages/chat/page/composerSend.ts -- changed here
Sibling: website/src/components/useChatPaneSend.ts -- changed here
Sibling: website/src/pages/chat/page/transcriptPins.ts -- not affected -- the edit-last shortcut edits the bubble in place, which expands meta.pastes itself
Sibling: website/src/components/QueueStack.tsx -- not affected -- the queued-message editor folds its own paste blocks back in
Pattern harvest
Rule candidate: review-prompt
Pattern: composer text restored from a stored prompt or draft without the paste blocks its tokens name
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.