Skip to content

fix(chat): keep the pinned prompt while reading the last reply - #15919

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/pinned-prompt-last-reply
Oct 7, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/pinned-prompt-last-reply

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The pinned copy of your prompt stays on screen while you read the last reply in a session, even when that reply is taller than the window.

Scroll down through the final reply of a session (a long answer with a big code block, say). Once the reply's top passes the fold, the pinned prompt card disappears. Scroll back up and it pops back in the moment the reply's top drops below the fold again. The card flickering in and out under the wheel makes scrolling feel broken.

Why it matters

The last reply is the one people read most, and long replies are where the card helps: it answers "what did I ask?" while you are deep in the answer. Today that is exactly where it vanishes, on every session whose newest reply is taller than the viewport.

Not a goal

What changed (motivation → approach → change)

The card needs a hand-off index: the first transcript row whose top is still below the fold. usePinnedPrompt found it by walking the mounted rows. When the reader is inside the final row, every row is already above the fold, so the walk found nothing, the index stayed -1, and the banner was dropped.

In website/src/pages/chat/usePinnedPrompt.ts, when no mounted row is below the line and the last mounted row is the end of the display list, that last row is treated as the row straddling the line. It stays readable and is never swapped for the banner; the prompt before it is pinned. When the last row is a reply, that is the prompt the reply answers. When it is a tall prompt that has no reply yet, it stays a readable row instead of pinning itself and hiding its own tail. When the last mounted row is short of the list end, rows below are unmounted and the boundary is unknown, so nothing is pinned, as before.

The scan now skips any data-display-index node that sits inside another row. Real row wrappers are never nested, and the markdown sanitizer admits arbitrary data-* attributes, so a nested node can only come from message content. Without the skip, a forged index in the last mounted row could pass for the end of the list and pin an unmounted prompt. The same check backs the hook's three by-index lookups (the pinned row, the incoming prompt and the jump target) through one findTranscriptRow helper. A plain querySelector returns the first match in document order, so a forged copy in an earlier row would be measured in place of the real one. The other data-display-index reads elsewhere in website/src are outside this PR.

Backwards compatibility

Compatible: only the case that used to show no banner changes; every case that already found a row below the line takes the same path.

Tests

website/src/test/usePinnedPrompt.test.tsx:

  • keeps the prompt pinned while reading a final reply taller than the viewport, run with requiresMountedHandoff both false and true. Both fail on main (banner null) and pass here.
  • never pins a tall final prompt as its own stand-in, both requiresMountedHandoff values: a last prompt taller than the space below the fold is not pinned over its own row.
  • pins nothing when every mounted row is above the line but rows below are unmounted keeps the unknown-boundary case unpinned.
  • ignores a data-display-index forged inside message content, both requiresMountedHandoff values. Both fail without the nested-row skip and pass here.
  • measures the real incoming row, not a forged index earlier in the DOM. With a plain querySelector the forged node is measured and the card is pushed 24px; here the push is 0.

The existing pinned-prompt suites (ChatPane.pinnedPrompt, PinnedPrompt.*, pinnedPrompt.*, useChatPageTranscriptEarlyController.coverage, UserMessage.pinnedStandinActions) pass.

Manual verification

An isolated gateway (spawn_feature_gateway, fixture minimal) was seeded with one session: a 9-line prompt and a reply holding a 55-line code block. Headless Chromium at 1280x900 wheel-scrolled it in 20px steps while the card height was recorded at each step. On main the card is present from 20px to 260px and gone from 280px to the end of the reply. On this branch it is present from 20px to the end.

Screenshots / video

Same scroll position (560px), inside the final reply.

Before, on main: no pinned card.

before: no pinned card while reading the final reply

After: the pinned prompt stays.

after: pinned prompt card stays while reading the final reply

Related Issues

no linked issue: reported directly with a screen recording.

Pattern harvest

Not generalizable: the defect is one missing end-of-list case in a single boundary walk; the rule "a scan for the first element past a line must handle running off the end" is too generic for a lint.

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

@Pearcekieser
Pearcekieser requested a review from a team October 1, 2026 15:47
@Pearcekieser
Pearcekieser requested a review from a team as a code owner October 1, 2026 15:47
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: Keep the pinned prompt card on screen while the reader scrolls through the final reply of a session, including replies taller than the viewport.
Not a goal: Changing where a prompt hands over to the card, how a tall prompt folds, or the card's height, peek and expand behaviour.

@Pearcekieser
Pearcekieser force-pushed the fix/pinned-prompt-last-reply branch from 4b4368f to 7f205fa Compare October 1, 2026 16:01
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/pages/chat/usePinnedPrompt.ts and website/src/test/usePinnedPrompt.test.tsx (#15828) since this head was pushed (35171e2 -> 3eafb47). Clean rebase, no code change; pinned-prompt suites (114 tests) and tsc pass locally. CI re-running.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of fa9fbf69dd4fc27f10e8a12092e75fbe2237995b via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the end-of-list fallback is still right while the final reply streams: a growing last row keeps pinning the prompt before it.

Suggestions

  • The forged-index filter (isTranscriptRow / findTranscriptRow) is applied one reader at a time, and the PR says the other readers are out of scope. Those include useScrollManager.ts, transcriptRows.ts and TurnNavigationMinimap.tsx, and a forged index can still mislead them. The sanitizer in api/helpers.ts calls DOMPurify.sanitize with its defaults, so it keeps data-* attributes. A follow-up PR could add FORBID_ATTR: ['data-display-index'] there, which would close this for every reader at once instead of guarding each one.

[DESIGN-REVIEWED] fa9fbf6

Description read

[DESCRIPTION-READ] 2cc5efb9f27661e74f6e58962899d41d41586648e459e40d0d128b61e95e2223

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed fa9fbf69dd4fc27f10e8a12092e75fbe2237995b via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fa9fbf6

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of fa9fbf69dd4fc27f10e8a12092e75fbe2237995b via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

No first-time reader has looked at the pinned card staying on screen through the last reply; this fork lane can't run that read, so a human should check it.

Watch

  • No recording of the scroll. The bug was a flicker during scrolling, and two stills can't show that it's gone. In attachment-02 the card stays at 560px, but the claim "present from 20px to the end" comes only from the author's own scripted run. This matters on every long final reply, the most-read spot in a session, so a regression would be seen on every scroll. Smallest fix: attach a short GIF scrolling top to bottom through the final reply.
  • The card hides content in the most-read reply. In attachment-02 the card covers code lines 8–10 of the reply. Hiding content under a pinned header is existing behaviour, but this PR now keeps the card over the final reply the whole time, so the cover is permanent for the session's main reading surface. Confirm the card can be collapsed, or that lines under it are reachable, before merging.

[UX-REVIEWED] fa9fbf6

Description read

[DESCRIPTION-READ] 4b21ea9d0807d5dfc57a68e398f948fb4146e1f7b314516134d2314f89f0284a

That sha256 names everything this verdict read: the PR description, plus the 5 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 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of fa9fbf69dd4fc27f10e8a12092e75fbe2237995b via the fork AI-review pipeline — 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: CONCERNS

The forged-index guards are hardening that rides along: no defect was reported, and they patch 4 reads in one hook while 7 identical reads in 4 other files stay unpatched.

Not justified as shipped

  • Item 3 — rides along, symptom-level: the description's only defect is the vanishing card. Its grounds are "the markdown sanitizer admits arbitrary data-* attributes", but no forgery was ever reported. The scan skip and findTranscriptRow guard this hook only. The same reads remain at useChatPageTranscriptController.tsx:195,290, useScrollManager.ts:41, TurnNavigationMinimap.tsx:85,293 and useBubbleVanishProbe.ts:57,66 (pattern data-display-index; 7 sites outside this hook). The cause is the sanitizer letting data-display-index through. In website/src, ALLOW_DATA_ATTR|FORBID_ATTR has 0 matches.
    Subtraction: delete findTranscriptRow and the three by-index lookups that call it, and keep the end-of-list branch.
    Clears when: a reported forgery defect is linked, or the guard moves to the sanitizer so it covers every site.

What this change ships

Inventory (3 items) — 2 justified

Intent: keep the pinned prompt card on screen while the reader scrolls through a final reply taller than the viewport. This is a FIX.

  1. The pinned card stays while you read inside the last reply, instead of flickering out — justified
  2. A tall final prompt with no reply yet is never pinned over its own row — justified
  3. Rows forged in message content are ignored by the row scan and by the pinned-row, incoming-prompt and jump-target lookups — rides along, symptom-level: no reported defect; 7 sibling reads in 4 files left unguarded

[FIRST-PRINCIPLES-REVIEWED] fa9fbf6

Description read

[DESCRIPTION-READ] 4fd99cfc3c8366b9d1117db82dd317936b90a35d2cc8e987e3ca6032ab39df65

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.

@Pearcekieser

Pearcekieser commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author
  • handoffIdx = list.length makes a final tall user prompt pin itself before a reply exists

Outcome: fixed in fe41d0c. The end-of-list branch now assigns list.length - 1, so the final row is the straddling row: it stays readable and only a prompt before it can pin.
Correction to my earlier reply on this span: a final tall prompt pinning itself is not equivalent to the mid-transcript case, because nothing follows it to shrink the fold, so its tail stayed covered at the bottom of the transcript.
Test never pins a tall final prompt as its own stand-in (both requiresMountedHandoff values) reports idx 2 with the old value and passes with the new one.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed fa9fbf69dd4fc27f10e8a12092e75fbe2237995b via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fa9fbf6

@Pearcekieser
Pearcekieser force-pushed the fix/pinned-prompt-last-reply branch from 7f205fa to fe41d0c Compare October 1, 2026 17:17
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • handoffIdx = list.length lets a tall final prompt pin over and hide its own row

Outcome: fixed in fe41d0c with the suggested list.length - 1; the final row is treated as the straddling hand-off row and stays readable.
When the final row is a reply, the prompt before it is still pinned, which is the PR's purpose; when it is a prompt already past the fold, the existing push drops the earlier card so the prompt has the band to itself.
Test never pins a tall final prompt as its own stand-in fails on the previous head (pins idx 2) and passes; the final-reply tests still pass.

@Pearcekieser
Pearcekieser force-pushed the fix/pinned-prompt-last-reply branch from fe41d0c to a497260 Compare October 1, 2026 22:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved 19+ commits since fe41d0c went green (aaaa524 -> 916e334), including a change in website/src/pages/chat/, and PR Readiness had sat pending since 21:40Z with every check passed. Clean rebase, no code change; pinned-prompt suites (116 tests) and tsc pass locally. CI re-running.

@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 Oct 2, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/pinned-prompt-last-reply branch from a497260 to 369b5e0 Compare October 6, 2026 18:00
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking, security): Message HTML can forge the end-of-list handoff. Fixed in 369b5e0.

The scan in usePinnedPrompt.ts now skips any [data-display-index] node whose parent chain reaches another [data-display-index] inside the scroller. Transcript row wrappers are never nested, so only message content can be nested. A forged attribute inside a message can no longer set lastMountedIdx or handoffIdx.

The new test ignores a data-display-index forged inside message content covers both requiresMountedHandoff values. It mounts rows 0 and 1, adds a span with data-display-index="3" inside row 1, and gives a 4-item list, so rows 2 and 3 are unmounted. Both cases fail on a497260 (the hook pins idx 2) and pass on 369b5e0 (nothing pinned).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): A human should wheel through one tall final reply before merge. Accepted, and left to the merging maintainer.

The automated check is a headless Chromium step-sweep. It ran an isolated gateway on a long session, wheel-scrolled through the final reply in fixed steps, and took a screenshot at each step on both the left and right edge. On main the card is gone at every step once the reply's top passes the fold. With this change it stays at every step. The PR body embeds stills from that sweep.

Headless Chromium doesn't animate smooth scrolling, so the sweep can't show frame-to-frame flicker during a smooth wheel scroll. That part needs the manual pass you describe: open a session whose last reply is taller than the window, scroll down with the wheel, and check that the card stays up the whole way.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased on main (695 commits) as 369b5e0. There were no conflicts and the rebase itself changes no behaviour.

The same push includes the fix for GPT's forged-index finding. The pinned-prompt scan now ignores data-display-index nodes nested inside a row, and a new test covers it. The 70 targeted frontend tests, including widthFamilyGc.test.ts, and tsc pass locally. That test failed in Frontend Tests shard 2 on the last head, and this PR doesn't touch it.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 6, 2026
When the final row of a transcript (usually a reply taller than the
viewport) scrolled past the fold, no mounted row was left below the
hand-off line, so usePinnedPrompt found no hand-off index and dropped the
banner. The card vanished while the reader was inside the answer and
popped back the moment the reply's top fell under the fold again.

When every mounted row has reached the line and the last of them is the
end of the display list, that last row is treated as the row straddling
the line: it stays readable and the prompt before it is pinned. A tall
final prompt with no reply yet therefore never pins itself over its own
row. A last mounted row short of the list end still pins nothing.
@Pearcekieser
Pearcekieser force-pushed the fix/pinned-prompt-last-reply branch from 369b5e0 to fa9fbf6 Compare October 6, 2026 22:45
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Fixed in fa9fbf6. The nested-row check is now a shared isTranscriptRow helper. All three by-index lookups in usePinnedPrompt (the pinned row, the incoming prompt and the jump target) go through a new findTranscriptRow helper. It walks every match and returns the first one that isn't nested in another row, so a forged copy earlier in document order is no longer measured in place of the real row.

New test: measures the real incoming row, not a forged index earlier in the DOM. On the previous head the forged node is measured and the card is pushed 24px. Here the push is 0.

The other data-display-index reads elsewhere in website/src predate this PR. The PR body lists them as out of scope.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted. The evidence is still frames from a headless step sweep. That sweep wheel-scrolled the whole final reply and checked that the card was present at every step, but headless Chromium doesn't animate smooth scrolling, so it can't show flicker in motion. Whoever merges this should do the manual wheel pass through a tall final reply.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted. As the review says, the fork lane has no first-time reader, so neither screenshot has had a cold read. I'm leaving that to the maintainer's pass.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 7, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted and deferred. The nested-row guard is in this PR because the GPT lane raised a forged data-display-index as a fenced security BLOCK on a497260, and this hook is the code that PR changes. No forgery has been reported in the wild. The root fix is to stop the markdown sanitizer from admitting data-display-index (or any data-* the transcript uses for structure), which would cover every reader and let the per-hook guard go. That touches the sanitizer and every message renderer, so it belongs in its own PR rather than this scroll fix.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted and deferred. useScrollManager.ts, transcriptRows.ts and TurnNavigationMinimap.tsx predate this PR and are named out of scope in the body. The fix that covers them all is a sanitizer change that drops data-display-index from message HTML, which would also make the guard in this hook unnecessary. That is a separate PR.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted. The headless sweep steps the scroll position through the whole final reply and checks the card at every step, but headless Chromium does not animate smooth scrolling, so it cannot show flicker. A maintainer should wheel through a tall final reply by hand before merging.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Accepted as existing behaviour. The pinned card already sits over the top of every reply in the middle of a transcript while you read it; this PR makes the final reply behave the same way instead of dropping the card. Changing how much the card covers is a design change to the pinned-prompt feature itself (open PR #14769 works in that area), not part of this fix.

@iamwhatever iamwhatever 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 (crew-pr-reviewer). The handoff looks only at real transcript row wrappers (isTranscriptRow), so a data-display-index copy inside message content cannot steer it. It also keeps the pinned prompt while the last reply is taller than the window. This is a frontend hook change with tests. CI is green and the base is main.

@iamwhatever
iamwhatever enabled auto-merge (squash) October 7, 2026 06:46
@iamwhatever
iamwhatever merged commit 291fa74 into kirodotdev:main Oct 7, 2026
104 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants