Repository navigation
fix(chat): re-serve the reply a link card allowed or revoked - #17634
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Allow and Undo on an old reply in a long chat were never tried in a running app. Someone should check that the reply's chip actually becomes a link and back again. [UX-REVIEWED] 10df195 Description read[DESCRIPTION-READ] 4c87c5b5a757475e22bf909a9fe2f787980d99098fd132a5f120cdbced69db4a 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 Check what happens when Allow/Undo is clicked during a streaming turn: the walk returns [DESIGN-REVIEWED] 10df195 Description read[DESCRIPTION-READ] ce8bdee97203a2108192669ec2ffc3645ee0cfa7846c36b0c346ffed834d4368 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 Not yet confirmed in a real long chat: Allow on an old reply swapping the chip for a link. The description says manual verification was "Not done on a live pod." What this change shipsInventory (5 items) — 5 justifiedIntent: when you allow a host from a link card on an older reply (or undo it), that reply updates without a full page reload. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 10df195 Description read[DESCRIPTION-READ] 4ff307fb421b43521413f5ed765947cd2080b1f0e061801582bbe3e05e2554aa 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: |
b6eab9a to
d8131be
Compare
A link card's Allow and Undo reload the chat, but the reload kept every row above the newest page as the tab already had it, so a reply paged in from older history kept showing its link blocked (or clickable after Undo) until a full reload. The card now sends its reply's time with the reload event. refreshSlot resolves it to that row's mid (only when exactly one durable row carries the time) and, when the newest page does not hold that row, walks older with the existing bounded window walk until it does. The walk keeps its page cap, so no reload reads the whole transcript (#12907). Refs #17023
d8131be to
10df195
Compare
|
This PR makes an older reply re-render after "Allow for this host" or "Undo" on its link card. The card now sends its |
Problem / Motivation
Goal: After you allow a host (or undo that) from a link card on an older reply, that reply shows the change without a full page reload.
Since #13236 and #16005, a chat refresh reads only the newest page and keeps every row above it exactly as the tab had it. The link card's Allow for this host and Undo trigger that same refresh, so when the card's reply sits above the newest page (a long chat you scrolled back through), the reply keeps showing the link as blocked after Allow, or as a link after Undo, until the chat is reloaded.
Why it matters
The person most likely to hit this is the one reading back through a long session and allowing a host on an old reply: the click appears to do nothing, and after Undo a link to a host they just revoked stays rendered as a link. The fix must not bring back the whole-transcript read behind #12907.
Not a goal
main: switch version is offered only on the last reply (ChatPage.tsxonSwitchVariant={i === lastTextIdxRef.current ...}), and the server'sswitch-varianthandler only targets the newest reply with variants. A sign-in row is patched in place bychat_message_update(sseChatMessagePatchByTs, bymid), which already updates rows anywhere in the view.What changed (motivation → approach → change)
Symptom: Allow/Undo on an older reply's link card leaves that reply unchanged. Root cause: the refresh accepts any newest page that overlaps the view, and the reducer keeps the rows above the overlap verbatim, so the one row the card changed is never re-served.
Approach: the card already knows which reply it sits on, so the refresh only needs to reach that one row, not re-read everything the tab holds. The existing bounded walk (
walkWindowBackTo, at mostWINDOW_WALK_MAX_PAGESpages of 500) does the reaching, and the reducer's existing cut keeps everything above the walked window. The issue's suggested alternative, dropping all rows above the fresh page and resetting the cursor, was not taken: on this path it would also unmount the very reply the user just clicked, taking the card's Undo with it.RedactionCards.tsx/MarkdownRenderer.tsx: the redaction context carries the reply'smessageTs; Allow and Undo send it inmc:redaction-hosts-changed.eventBridges.ts: with a stringmessageTsthe bridge dispatchesrefreshSlot({ key, reachTs }); otherwise the plain refresh as before.slotRefresh.ts:reachTsis resolved to that row'smeta.mid, only when exactly one durable row in the view carries that time (atsis not an identity, so an ambiguous or id-less match falls back to the plain refresh). An overlapping page is accepted only when it also holds that row; otherwise the refresh walks.windowWalk.ts: optionalmustIncludemid; the walk's stop condition also requires the window to hold it. Same page cap, so a row further back than the cap reaches stays as it was.docs/system-specs/modules/security.md: one sentence on what an open chat shows after Allow/Undo and after a Settings revoke.Backwards compatibility
Compatible:
refreshSlotgains an optional field andwalkWindowBackToan optional parameter; every existing caller passes neither and behaves as before. The event's newmessageTsfield is optional and the bridge ignores a non-string value.Removes nothing: the change only adds a reason to walk older; no row, key, path or validator is removed or tightened.
Tests
website/src/store/chatSlice.refreshReachRow.test.ts(new): an 800-row view of a 2000-row chat. A plain refresh keeps row 1300 as the tab had it (pins the base behaviour);reachTsfor row 1300 walks exactly one older page plus the newest re-read and re-serves it with no duplicate or lost rows; a row already in the newest page walks nothing; an ambiguoustsfalls back to the plain refresh. Mutation-checked: dropping thepageHoldsReachgate, or the walk'sincludespredicate, each reddens the re-serve test.website/src/test/useChatPageEventBridges.test.tsx: the bridge passes{ key, reachTs }for a stringmessageTsand the bare key for a non-string one.website/src/test/MarkdownRenderer.blockedLink.test.tsx: Allow's event now carries the reply'smessageTs.Ran locally by path: those three files plus
chatSlice.windowWalk.test.ts(62 + 16 pass),tsc --noEmit, and eslint on the changed files.Manual verification
Not done on a live pod. The store-level test drives the real thunk and reducer against a stubbed slot-detail handler; the remaining unverified piece is the rendered reply swapping its chip for a link in a real long chat.
Screenshots / video
Why no screenshot: No new UI; an existing reply now re-renders with the server's current form, which the store test asserts directly.
Related Issues
Refs #17023 (covers the link-card path; the Settings revoke path is left for the owner decision below).
Pattern harvest
Not generalizable: the defect is a missing "re-serve this row" request on one caller of a refresh that is correct to keep rows for every other caller.
Decision for the owner
The issue asks whether rows kept above the newest page should be healed after a change that alters how they are served, and how, without bringing back whole-transcript reads. This draft heals only the reply whose link card made the change, by walking the existing bounded window to that row, and leaves a Settings revoke (and the drop-and-repage option) for you to decide, because dropping the kept rows would unmount the card the user just clicked.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.