Repository navigation
fix(chat): reset the pinned card height when the prompt changes - #16372
Conversation
The gate that leaves a tall prompt unpinned compares what is left of the bubble against the last measured card height, which belongs to the previous prompt. An image-only card is two lines tall, so a text prompt after it could pin, re-measure at one line, fail the gate and unpin with no scroll in between. The height now falls back to the default whenever the pin candidate changes.
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that an expanded or peeking card across a What this change shipsInventory (5 items) — 5 justifiedIntent: when a text prompt follows an image-only prompt, the pinned card should pin once instead of flickering. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] a01a641 Description read[DESCRIPTION-READ] cf02487890633f993d4179288eee45c1dce3872c4e8d10edad0c1fc41859b38b That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check by hand that the pinned card no longer flickers when scrolling from an image-only prompt to a longer text prompt. No recording was supplied. [UX-REVIEWED] a01a641 Description read[DESCRIPTION-READ] ef2fc8e265b4f4e5e3744b4e849937185405257e51ae6c12da8100618ab88b1b 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 by hand that a text prompt followed by an image-only one doesn't jump for one frame when its card reports 90px over the reset seed height. [DESIGN-REVIEWED] a01a641 Description read[DESCRIPTION-READ] 8ddf096cb4e2bc0e24714da58be368ed762e44382d8dd6dd46571d8a6530fec4 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 |
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: |
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: |
|
Design Review (CONCERNS on 5ee8801), empty |
The resting-height reset keys on a pin candidate's identity, its index and ts together: a timestamp-less transcript (an import, a legacy log) reads ts as '' for every prompt, so ts alone never changes across a hand-off. The host also passes that identity to PinnedPrompt as promptKey, and the card's collapsed-height measure re-runs on it, so a card that stays mounted with the same text (older history prepended, one image-only prompt handing off to another) reports its height for the new identity instead of leaving the one-line seed under a taller card.
c9ae40a to
a01a641
Compare
|
Design Review (CONCERNS on c9ae40a), reset without a new measurement: fixed in a01a641 (folded into the second commit to stay within two). Confirmed in source: |
|
Read-only review: the fix is sound on its own (keys on index + ts and the card re-reports via promptKey), but it repairs the #16321 gate that open revert #16342 removes, and the two collide in usePinnedPrompt.ts, PinnedPrompt.tsx, both hosts and page-layout.md. Please settle #16342 first: if the revert lands, close this; if the revert is dropped, this can merge as is. |
Problem / Motivation
Goal: A text prompt that follows an image-only prompt pins once, at the right moment, instead of the pinned card flashing on and off.
usePinnedPromptleaves a tall prompt unpinned while more of its bubble is left than the resting card height (#16321). That height is the last one a card reported, so it belongs to the previous prompt. An image-only card rests two lines tall; when the next candidate is a text prompt, the gate admits it too early, the card mounts, reports one line, the gate fails on the next frame and the card unmounts with no scroll in between.Why it matters
Anyone who scrolls a chat with an image-only prompt followed by a longer text prompt sees the pinned card flicker at the hand-off. It looks broken and draws the eye to the wrong place.
Not a goal
What changed (motivation → approach → change)
pinCollapsedHRef, which still holds the previous card's measured height.pinCollapsedHReftoDEFAULT_PINNED_CARD_Hwhen it changes, until the new card reports. The candidate is keyed on its index andtstogether, so transcripts whose messages carry no timestamp (tsis'') still reset. Both hosts pass the same identity (pinCandidateKey) toPinnedPromptaspromptKey, and its collapsed-height measure re-runs on it, so a card that stays mounted with unchanged text (older history prepended, one image-only prompt handing off to another) reports its height for the new prompt.website/docs/page-layout.mdrecords that the resting height is per prompt.Backwards compatibility
Compatible: only the height the gate reads for a newly pinned prompt changes; the API of
usePinnedPromptis unchanged.Removes nothing: no field, key, prop or behavior is removed.
Tests
usePinnedPrompt.test.tsx› "gates a new prompt on the seed height, not the previous card's measured height": a card reports 90px, then a text prompt with 70px of bubble left must stay unpinned, and pins at the default height once one line is left. It fails with the reset disabled.ts": runs the scenario withts: ''on every message. It fails with a key ontsalone.PinnedPrompt.promptKey.test.tsx: the card reports again whenpromptKeychanges and the text does not, including a timestamp-less image-only hand-off, and does not report for a re-render with the same key. Two of its three tests fail withpromptKeyremoved from the measure effect's deps.tscandeslintpass.Manual verification
N/A — unit coverage sufficient: the defect is a frame-level gate decision, and the test drives that exact frame sequence through the hook.
Screenshots / video
Why no screenshot: the fix removes a one-frame mount/unmount at a single hand-off; every settled frame renders exactly as on main, so a still image would look identical before and after.
Related Issues
Split out of #15984, which is closed in favor of #16321; this was its remaining live fix (raised in review there).
Pattern harvest
Rule candidate: review-prompt
Pattern: a cached measurement keyed to one entity (a card, a row) reused after the entity it describes has changed.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement