Skip to content

fix: keep paste chip content when up/down recalls a prompt - #31488

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/29722-recall-paste-chips
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/29722-recall-paste-chips

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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

  • Changing how pastes collapse, expand or render in the transcript.
  • The edit-last-message shortcut and the queued-message editor, which already carry their blocks.

What changed (motivation → approach → change)

Up/Down lands on Before After
a sent prompt in the transcript tokens, no content tokens plus the row's meta.pastes blocks
a sent prompt whose row left the transcript tokens, no content tokens plus the blocks kept on its send record
the draft, coming back draft tokens, no content draft tokens plus the draft's own blocks

A 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 in composerPromptHistory.ts carried 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 by SendAttempt in store/chat/state.ts) stores them, and both writers (the main chat's composerSend.ts and the split pane's useChatPaneSend.ts) pass them. The browse cursor keeps the draft's blocks as well. Both composers, the textarea (draftHistory.ts, wired through keyboard.ts and ChatInput.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 (pastes on a history entry, a history step and a send record, draftPastes on 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).
  • Same file, "↓ back to the draft restores its paste blocks with it, so its chip still expands": a draft holding a chip survives Up then Down and sends its pasted lines.
  • 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.shuffle and 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 main the posted message was Why 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.

Light Dark
Before before, light before, dark
After after, light after, dark

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

  • 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.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 15:21
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 15:21
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f1b3407d9757c8ee057b66e88bae262eb5a67298 — 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

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

  • Item 5 — rides along: pasteBlocksRef: React.RefObject<readonly PasteBlock[]> → React.RefObject<PasteBlock[]>. This widens a type the description never mentions, and the change only needs it to pass the ref into recall. Subtraction: keep readonly PasteBlock[] and make blocks/composerPastes/draftPastes take readonly PasteBlock[] instead of loosening the ref.

What this change ships

Inventory (5 items) — 4 justified

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

  1. Pressing Up on a prompt still in the transcript brings its paste chips back, and resending carries the pasted lines. — justified
  2. Pressing Up on a sent prompt whose row has left the transcript also brings back its pastes, from the send record. — justified
  3. Pressing Down back to the draft restores the draft's paste chips. — justified
  4. In the rich editor, a recalled entry with no pastes clears the chips from the previous entry. — justified
  5. The composer's paste-blocks ref is typed mutable instead of readonly. — rides along, undeclared

[FIRST-PRINCIPLES-REVIEWED] f1b3407

Description read

[DESCRIPTION-READ] 8d069feef57dc640b00745a959444ebc42086ba4b56f4b3b2b429a9cc0d5860d

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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

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

  • The blind reader said the square brackets "sit outside the tinted area" of the chip (shots 3 and 4). That's a pre-existing look issue, not something this PR adds.

[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 .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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

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 .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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f1b3407

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

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f1b3407

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 15:43
@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 Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/29722-recall-paste-chips branch from ca18895 to fe6ff53 Compare November 6, 2026 17:52
@bolichen97

Copy link
Copy Markdown
Contributor Author

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]

@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 Nov 6, 2026
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
@bolichen97
bolichen97 force-pushed the fix/29722-recall-paste-chips branch from fe6ff53 to f1b3407 Compare November 6, 2026 23:33
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention 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 Nov 6, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved for the on-call. Review lanes pass on f1b3407, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 1eb1d21 into main Nov 7, 2026
97 of 103 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/29722-recall-paste-chips branch November 7, 2026 01:57
cruisercohen added a commit that referenced this pull request Nov 7, 2026
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. Builds on #31488, whose paste-block restore path is kept unchanged.

Fixes #31851
cruisercohen added a commit that referenced this pull request Nov 7, 2026
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
bolichen97 added a commit that referenced this pull request Nov 9, 2026
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.
cruisercohen added a commit that referenced this pull request Nov 13, 2026
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
cruisercohen added a commit that referenced this pull request Nov 16, 2026
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
bolichen97 pushed a commit that referenced this pull request Nov 16, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste chips recalled with Up are sent as literal "[ Paste #N · M lines ]" text

2 participants