Skip to content

fix(chat): draw a paste chip only on the row the paste was sent as - #36230

Merged
bolichen97 merged 1 commit into
mainfrom
fix/paste-store-cross-tab-match
Nov 13, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/paste-store-cross-tab-match

Conversation

@rnoack1

@rnoack1 rnoack1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A message is drawn as a paste chip only in the chat, and on the row, where it was actually sent as a paste.

After you paste a block into one chat, any later user row in any chat with exactly the same text is drawn as [ Paste #1 · N lines ]. A scheduled job that injects one fixed message into many chats shows it as a paste in nearly every chat, once that text was pasted by hand anywhere.

Why it matters

The chip tells the reader a person pasted that block. Here it is false: the row was injected, typed, or sent by automation. It also hides the message body behind a collapsed chip in every affected chat, for up to 30 days.

Not a goal

  • Changing how pastes collapse in the composer, or the token format.
  • Making paste chips survive on another browser or device. The side table is still per browser.
  • Changing what the agent receives. That was always the plain text.

What changed (motivation → approach → change)

Symptom: a row nobody pasted renders as a paste chip in another chat.

Cause: the paste side table in localStorage is keyed only by the message's expanded text. On reload or chat switch, mergePreservedPastes (route 3) and queueEntryPastes look every row up by its text, so any row with the same text in any chat claims the entry.

Change: each entry now records the sendIds of the sends that saved it, and both readers require the row's own meta.sendId to be one of them (readStoredPasteForSend). The gateway keeps sendId on the user row it persists, so a reload still finds the owning row, and a row with no sendId (injected, scheduled) or another send's id never does. Every save site now passes its id: the composer send (composerSend.ts, useChatPaneSend.ts, ChatEmbed.tsx, through storeSentPastes) mints it before saving, and a queued-card edit (QueueStack.tsx) passes the card's own sendId.

Backwards compatibility

Compatible: nothing is rejected or renamed. Entries written before this change carry no sendIds, so after a reload their rows show as plain text until the entries age out (30 days). The chip still shows in the session that sent it.

Removes nothing: every send that saves an entry now records its id, so its own row keeps the chip; only rows that never owned the entry stop matching.

Tests

  • pasteTokens.test.ts › "side table claims only the rows its send saved": a matching row from another chat stays expanded; a reload re-collapses the row whose sendId saved the entry and not rows with another id or none; an entry saved with no id matches nothing; repeated sends of the same text keep the newest 20 ids; two sends of the same text with different block ids both re-collapse after a reload; a sendId-matched row takes the side-table display only from its own send; a missing or non-string id reads nothing.
  • chatSlice.queuePastes.test.ts: a queue entry or hydrated card whose sendId did not save the entry gets no pastes even when its text matches; the existing cases save and read with the same id.
  • composerPastes.test.tsx: storeSentPastes call sites pass an id.
  • ChatEmbed.longPaste.test.tsx: the embed's optimistic queued card for a paste send draws the collapsed paste, because the card carries its send's sendId.

Proof: not provable -- frontend test (prove.py runs Python only)

By hand: with readStoredPasteForSend reverted to a text-only lookup, the cross-row tests fail.

Manual verification

N/A — unit coverage sufficient: the change is a pure lookup rule in mergePreservedPastes and queueEntryPastes, both covered at the reducer boundary.

Screenshots / video

Why no screenshot: the chip itself is unchanged; this only stops it from being drawn on rows that were never pasted.

Related Issues

Closes #36149

Sibling sweep

Swept: git grep -nE "readStoredPaste(|saveStoredPaste(|storeSentPastes(" -- website/src
Sibling: website/src/utils/pasteTokens.ts -- changed here
Sibling: website/src/store/chat/wire.ts -- changed here
Sibling: website/src/chat-core/composer/composerPastes.ts -- changed here
Sibling: website/src/pages/chat/page/composerSend.ts -- changed here
Sibling: website/src/components/useChatPaneSend.ts -- changed here
Sibling: website/src/app-sdk/ChatEmbed.tsx -- changed here
Sibling: website/src/components/QueueStack.tsx -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: a client cache keyed by content alone is read back for rows it was not written for

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners November 12, 2026 23:52
@rnoack1
rnoack1 requested a review from mbriones98 November 12, 2026 23:52
@KiroCrewCaptain

KiroCrewCaptain commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider raised 1 possible problem and estimates a 60% chance that this change introduces a defect; a person should check it.

The ownership-by-sendId fix is sound on the main chat paths. It breaks the paste chip on the embed's temporary queue card, which builds its entry without a sendId: that card now shows the full pasted text, where on main it showed the chip. The fix is one line, but as it stands this regresses a sibling path that shares the changed lookup, and no test covers it.

Things to check (possible problems the decider raised; at this confidence many turn out to be fine):

  • In the embed, a paste sent while the chat is busy gets a temporary queue card. On main that card found its pastes by text and showed the [ Paste #N ] chip. Now its sendId is undefined, so the lookup fails and the card shows the full pasted text until the server's queue entry replaces it. If the host (website/src/app-sdk/ChatEmbed.tsx, low)

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 616ec64764 · 177 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks. The diff adds or restyles no control or string. It only stops the existing paste chip from showing on rows nobody pasted, so the missing screenshot leaves nothing unreviewed.

Notes

  • Paste rows sent before this change will show as full plain text after a reload, for up to 30 days. Users may notice old long pastes expanding in chat history. The PR description covers this, but a user could read it as a bug, so it is worth a line in the release notes.

[UX-REVIEWED] 7589be5

Description read

[DESCRIPTION-READ] 3d1f123022ef221aad6715335a66e2157774c0b7733bc119ab38367d59b1f6e2

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: binding each side-table entry to the sendIds that saved it is the smallest change that fixes the root cause. The cause was a cache keyed by content alone.

Notes

  • Entries saved before this change have no sendIds, so after a reload their rows lose the chip for up to 30 days. Since the old matching was the bug, this one-time loss is acceptable and reverses itself when the entries expire.

[DESIGN-REVIEWED] 7589be5

Description read

[DESCRIPTION-READ] 51fbf16f32b324d0f24aca65b4df90b237f002e9660afc7447ed9dd18889395d

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 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7589be5fbd2163e79a3e940f0c2e12417e4d63f1 — 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 cause: the side table was keyed by text alone. All three production readers and all four save sites now go through the send id, so no unfixed siblings remain.

What this change ships

Inventory (6 items) — 6 justified

Intent: a message shows as a paste chip only on the row where it was actually sent as a paste (#36149). This is a FIX.

  1. A row in another chat whose text happens to match a paste you made now shows as plain text, not a chip. — justified
  2. After a reload, a row you pasted still collapses back to its chip, because it carries its own sendId. — justified
  3. A queued card, from a live push or from hydration, gets pastes only when its sendId saved the entry. — justified
  4. The embed's optimistic queued card for a busy paste send now shows the chip. — justified
  5. Entries saved before this change no longer collapse after a reload (declared; they age out within 30 days). — justified
  6. Each side-table entry keeps the ids of the sends that saved it, capped at the newest 20 (STORE_SEND_IDS_CAP). — justified

[FIRST-PRINCIPLES-REVIEWED] 7589be5

Description read

[DESCRIPTION-READ] e5a5fe44e528f3046b242df00146e09159dba0736974b043d0350bec5b68cbcb

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 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7589be5

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

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7589be5

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

@rnoack1
rnoack1 force-pushed the fix/paste-store-cross-tab-match branch from b7313e8 to fcbb0cb Compare November 13, 2026 01:03
@rnoack1

rnoack1 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/components/RecordingElapsed.tsx, website/src/components/VoiceDictationPanel.tsx, website/src/components/VoiceStatusBar.tsx and website/src/utils/previewFlags.ts (same-dir overlap) since this head went green (b2aac45 -> 82d7af1); CI re-running.

@rnoack1
rnoack1 force-pushed the fix/paste-store-cross-tab-match branch from fcbb0cb to 616ec64 Compare November 13, 2026 01:23
@rnoack1

rnoack1 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Opus finding span=59b85885af78 on head fcbb0cb: fixed in 616ec64. I removed the reset, so saving the same text again keeps its earlier sendIds and adds the new one (no duplicates, at most 20). Each send of the same paste keeps its chip after a reload. Regression test: two sends of the same text with different block ids, then a reload; both rows re-collapse. It fails with the reset put back.

@rnoack1

rnoack1 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 8) red here is main's: test_reply_format_once.py::...::test_the_table_names_every_selectable_harness fails on main since #24732 (no mimocode row). Tracked in #36279, fix in #36290.

@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 13, 2026
@rnoack1
rnoack1 force-pushed the fix/paste-store-cross-tab-match branch from 616ec64 to 7589be5 Compare November 13, 2026 03: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 13, 2026

@bolichen97 bolichen97 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.

Approving. I read the full diff at 7589be5.

  • The paste side table was keyed on the expanded text alone, so any row with the same text (an injected message, another chat's row) drew this browser's [ Paste #N ] chip. saveStoredPaste now records the sendId that saved an entry (up to STORE_SEND_IDS_CAP, newest kept), and every reader goes through readStoredPasteForSend, which needs both the text and a matching string sendId. That covers mergePreservedPastes on both its paths, queueEntryPastes on hydration and queue_push, and the edited-queue path.
  • Every send path now mints the sendId before storing: ChatPage, the split pane, ChatEmbed and an edited queue entry reusing its own meta.sendId. In composerSend.ts the mint moves up and the later duplicate is removed, so the row's meta.sendId is still that same id.
  • The tests cover a same-text row from another chat staying expanded, a reload re-collapsing only its own send, two sends of the same text, the cap and eviction order, a missing or non-string id, and the ChatEmbed queued card.
  • No regex. Display only, so nothing is refused.

Non-blocking: entries saved before this change carry no sendIds, so after an upgrade a row this browser sent earlier, whose chip came only from the side table, shows its expanded text on reload until it is re-sent. That reads as the safe direction, but it may be worth a line in the PR notes.

Not checked: I ran no tests locally and relied on CI (97 green). I did not open the page.

@bolichen97
bolichen97 merged commit 2f8704c into main Nov 13, 2026
155 of 160 checks passed
@bolichen97
bolichen97 deleted the fix/paste-store-cross-tab-match branch November 13, 2026 17:08
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 chip appears on a message that was never pasted when its text matches a paste from another tab

3 participants