Repository navigation
fix(chat): draw a paste chip only on the row the paste was sent as - #36230
Conversation
Code change approver recommendation: A person should decideWhy: 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):
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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of 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
[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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: binding each side-table entry to the Notes
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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 shipsInventory (6 items) — 6 justifiedIntent: a message shows as a paste chip only on the row where it was actually sent as a paste (#36149). This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 7589be5 Description read[DESCRIPTION-READ] e5a5fe44e528f3046b242df00146e09159dba0736974b043d0350bec5b68cbcb That sha256 names the PR description this verdict read. 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: |
b7313e8 to
fcbb0cb
Compare
fcbb0cb to
616ec64
Compare
|
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. |
616ec64 to
7589be5
Compare
bolichen97
left a comment
There was a problem hiding this comment.
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.saveStoredPastenow records thesendIdthat saved an entry (up toSTORE_SEND_IDS_CAP, newest kept), and every reader goes throughreadStoredPasteForSend, which needs both the text and a matching stringsendId. That coversmergePreservedPasteson both its paths,queueEntryPasteson hydration andqueue_push, and the edited-queue path. - Every send path now mints the
sendIdbefore storing: ChatPage, the split pane, ChatEmbed and an edited queue entry reusing its ownmeta.sendId. IncomposerSend.tsthe mint moves up and the later duplicate is removed, so the row'smeta.sendIdis 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.
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
What changed (motivation → approach → change)
Symptom: a row nobody pasted renders as a paste chip in another chat.
Cause: the paste side table in
localStorageis keyed only by the message's expanded text. On reload or chat switch,mergePreservedPastes(route 3) andqueueEntryPasteslook 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 ownmeta.sendIdto be one of them (readStoredPasteForSend). The gateway keepssendIdon the user row it persists, so a reload still finds the owning row, and a row with nosendId(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, throughstoreSentPastes) mints it before saving, and a queued-card edit (QueueStack.tsx) passes the card's ownsendId.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 whosesendIdsaved 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 whosesendIddid 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:storeSentPastescall 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'ssendId.Proof: not provable -- frontend test (prove.py runs Python only)
By hand: with
readStoredPasteForSendreverted 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
mergePreservedPastesandqueueEntryPastes, 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