fix(ui-tui): hide stale sticky prompt when newer prompt is visible

Sticky prompt selection only considered the top edge of the viewport, so it could keep showing an older user prompt even when a newer one was already visible lower down. Suppress sticky output whenever a user message is visible in the viewport and cover it with a regression test.
This commit is contained in:
Brooklyn Nicholson 2026-04-23 14:32:29 -05:00
parent aa47812edf
commit 9a885fba31
3 changed files with 41 additions and 2 deletions

View file

@ -270,7 +270,7 @@ export function StickyPromptTracker({ messages, offsets, scrollRef, onChange }:
const vp = Math.max(0, s?.getViewportHeight() ?? 0)
const total = Math.max(vp, s?.getScrollHeight() ?? vp)
const atBottom = (s?.isSticky() ?? true) || top + vp >= total - 2
const text = stickyPromptFromViewport(messages, offsets, top, atBottom)
const text = stickyPromptFromViewport(messages, offsets, top + vp, top, atBottom)
useEffect(() => onChange(text), [onChange, text])