Skip to content

fix(chat): re-serve the reply a link card allowed or revoked - #17634

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/redaction-allow-stale-head-17023
Oct 8, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/redaction-allow-stale-head-17023

Conversation

@buluoray

@buluoray buluoray commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

  • A host revoked from Settings → Security → Redaction. That surface sends no event to open chats, and older rows keep their earlier form until the page is reloaded (now stated in the security spec). Fixing it needs a broadcast or a cursor reset across every cached slot, which is the owner decision below.
  • Reply variant switches and OAuth sign-in rows, the other two cases the issue lists. Neither reaches a row above the newest page on main: switch version is offered only on the last reply (ChatPage.tsx onSwitchVariant={i === lastTextIdxRef.current ...}), and the server's switch-variant handler only targets the newest reply with variants. A sign-in row is patched in place by chat_message_update (sseChatMessagePatchByTs, by mid), which already updates rows anywhere in the view.
  • Changing the window walk's page cap or the refresh's first-page size.

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 most WINDOW_WALK_MAX_PAGES pages 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's messageTs; Allow and Undo send it in mc:redaction-hosts-changed.
  • eventBridges.ts: with a string messageTs the bridge dispatches refreshSlot({ key, reachTs }); otherwise the plain refresh as before.
  • slotRefresh.ts: reachTs is resolved to that row's meta.mid, only when exactly one durable row in the view carries that time (a ts is 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: optional mustInclude mid; 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: refreshSlot gains an optional field and walkWindowBackTo an optional parameter; every existing caller passes neither and behaves as before. The event's new messageTs field 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); reachTs for 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 ambiguous ts falls back to the plain refresh. Mutation-checked: dropping the pageHoldsReach gate, or the walk's includes predicate, each reddens the re-serve test.
  • website/src/test/useChatPageEventBridges.test.tsx: the bridge passes { key, reachTs } for a string messageTs and the bare key for a non-string one.
  • website/src/test/MarkdownRenderer.blockedLink.test.tsx: Allow's event now carries the reply's messageTs.

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

  • 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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 10df195ed97fcddcea3321b08ba3bc19d30dec06 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 10df195ed97fcddcea3321b08ba3bc19d30dec06 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check what happens when Allow/Undo is clicked during a streaming turn: the walk returns finish(null) and the follow-up refresh carries no reachTs, so the old reply can stay stale.

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 10df195ed97fcddcea3321b08ba3bc19d30dec06 — 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/CONCERNS are advisory.

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 ships

Inventory (5 items) — 5 justified

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

  1. Allow or Undo on a link card above the newest page now re-serves that reply — justified
  2. The card's reload event now includes the reply's message time (messageTs) — justified
  3. refreshSlot gains an optional reachTs. With it, the refresh walks older until that row is in the window, falling back to a plain refresh when the time is ambiguous — justified
  4. walkWindowBackTo gains an optional mustInclude stop condition, under the same page cap — justified
  5. The security spec now says what an open chat shows after Allow/Undo, and after a revoke made in Settings — justified

[FIRST-PRINCIPLES-REVIEWED] 10df195

Description read

[DESCRIPTION-READ] 4ff307fb421b43521413f5ed765947cd2080b1f0e061801582bbe3e05e2554aa

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 10df195

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 10df195ed97fcddcea3321b08ba3bc19d30dec06: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 10df195

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 10df195ed97fcddcea3321b08ba3bc19d30dec06: <one-sentence reason>

@buluoray
buluoray marked this pull request as ready for review October 7, 2026 18:19
@buluoray
buluoray requested a review from a team as a code owner October 7, 2026 18:19
@buluoray
buluoray requested a review from iamwhatever October 7, 2026 18:19
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 7, 2026
@buluoray
buluoray force-pushed the fix/redaction-allow-stale-head-17023 branch from b6eab9a to d8131be Compare October 7, 2026 21:48
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 7, 2026
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
@buluoray
buluoray force-pushed the fix/redaction-allow-stale-head-17023 branch from d8131be to 10df195 Compare October 8, 2026 00:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 Oct 8, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 8, 2026 04:22
@chenmingwei23
chenmingwei23 merged commit 23cbf6e into main Oct 8, 2026
101 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/redaction-allow-stale-head-17023 branch October 8, 2026 06:02
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

This PR makes an older reply re-render after "Allow for this host" or "Undo" on its link card. The card now sends its messageTs, the refresh resolves it to a unique durable row's meta.mid, and the bounded window walk continues until that row is inside the re-served window. That fixes the real cause (an overlapping newest page kept the changed row in the verbatim head) without bringing back the whole-transcript read from #12907, and the page cap is unchanged. I read the production diff in RedactionCards, eventBridges, slotRefresh and windowWalk plus the new reducer test. The ambiguous/no-mid fallback to the plain refresh looks right. All checks pass and the lanes PASS with no findings on 10df195. I am holding only because this is the redaction/blocked-link surface: after Undo, a revoked host's link must stop rendering as a live link, and the brief routes redaction changes to a maintainer. I found no defect in the code. — crew-pr-reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants