Repository navigation
fix(chat): keep following the end while a growing draft shrinks the transcript - #1431
Conversation
…ranscript #1342 narrowed the follow intent in onScroll from 48 px to 1 px, so the scroll event a growing composer causes before the bottom correction dropped it and the chat stayed above the end (composer-fit regression on main). Restore the 48 px allowance for the follow intent; the end presentation the unread dot uses is still measured exactly in measureEnd.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
…n scroll input The 48 px follow allowance alone changed nothing: #1342's branch turns any upward move over 1 px while following into reading intent first. A growing composer causes such a move without any input. Upward moves within 500 ms of wheel, touch, pointer or key input in the transcript still count from the first pixel (#1342's rule, covered by the near-end sidebar case); others keep following within 48 px. The end presentation stays exact in measureEnd.
|
Fixes main's red CI after #1342. Reviews: omo-native-code-reviewer and Codex both PASS on 5ee00b6; the first commit alone was a no-op (found by review, confirmed 0/3 locally); with 5ee00b6 composer-fit passes 3/3 and the sidebar near-end case still passes. CodeRabbit did not review it (allowance ran out). Follow-ups are tracked in an issue. |
…eys anywhere (#1734) ## Change Since #1431 Chat stops following only when an upward move comes within 500 ms of the reader's own scroll input. That input was any wheel, pointer press or key inside the transcript, so a downward wheel to the end followed by Shift+Enter or a paste could still let the composer's growth stop following. And a key press usually was not seen at all: clicking transcript text focuses nothing, so ArrowUp or PageUp go to `body`. `src/components/ChatView.tsx` now records only input that scrolls the transcript up: an upward wheel, a touch moving the content up, a pointer drag (or a scrollbar press) that is followed by an upward move, and ArrowUp, PageUp, Home and Shift+Space anywhere in the document for the active chat, except while typing in an input. Downward input and plain clicks no longer count. The `ChatPaneContext` doc comment that the constant displaced is back, and the stale allowance comments are corrected. No visible change. Item 3 (screen-reader scrolling, a scrollbar held longer than the window) is left as is. Refs #1434 ## Validation - `scripts/chat-virtual-browser-qa.ts` (1440 and 390 px, light and dark): new cases for an upward wheel and navigation key stopping the follow, and a downward wheel and click keeping it; restoring the old wheel handling fails them. - `bun run check fast`: pass.
…avigate (#1831) ## What it does for the user When you scroll up in Chat to read older turns and then send a message from the message box, the chat now takes you back to its end once the PC accepts the message, and follows the reply there. Before this, the view stayed where you were reading, so your own message and the agent's answer appeared off screen behind a "New messages" pill. It only follows your own message from this browser that the bridge accepted at once (a receipt with no pending item, not a refusal, not an unconfirmed send to an older bridge). These keep the reader's place: - a refused or uncertain send - a queued or Send now delivery - another browser's message, a reconnect, or opening the pane again Scrolling or paging back, a wheel over the minimap rail, a minimap jump, a restored place, a replaced history, or leaving the pane before the receipt or before the turn shows cancels the follow. Nothing new is drawn: the existing Jump to latest and New messages controls stay as they are. ## Why Agent of Empires re-pins its view on every prompt, local, remote or replayed. Ovis's sends carry a receipt, so only that accepted local receipt counts, and the reader's own navigation after sending always wins. #1734 and #1431 changed how scroll intent is read. I checked this against current main: the regression script below still fails there, at the step where the accepted receipt should bring the view to the end. ## How it was verified - `scripts/chat-local-send-follow-demo-regression.ts` (added to the browser lane) runs on the demo app over its fixture transport. The submit receipts and transcript reads are gated, so each ordering is forced rather than timed. It covers: - an accepted send following to the end and the reply being followed - navigation before the receipt cancelling the follow - navigation before the transcript shows the turn cancelling the follow - refused, uncertain, remote, queued and Send now sends, a pane switch and a reconnect keeping the reader's place - The script passes on this branch. With `src/` reset to origin/main it fails at "the accepted receipt brings the view to the end". - `bun run check fast` passes (typecheck, build, 6380 unit tests). - Looked at the demo at 390 px (phone) and 1280 px (desktop): after scrolling away and sending, the message and the Working row sit at the end above the composer, no horizontal overflow, no page errors, nothing new drawn. - Reviewed by a code-review agent and by Codex. No HIGH findings. One MEDIUM from both (a wheel over the minimap rail scrolled the chat without counting as navigation) is fixed in the second commit, along with paging down no longer cancelling a follow. ## Follow-up The regression script exercises wheel navigation only. PageUp and minimap tick jumps cancelling the follow are covered by code reading, not by a scripted step yet. Rebased onto current main; the composer send moved to `src/lib/useComposerSends.ts` since the branch was cut, so the change was ported there.
… follow allowances (#1902) ## What it does for the user Holding the chat's scrollbar still for a moment and then dragging it up a little now stops Chat from following new output, as any other upward scroll does. Before this, only a drag that began within half a second of the press counted. A thumb that rested first and then moved up less than 48 px kept following, so the next update pulled the reader back to the end. Fixes #1434. #1734 already fixed items 1, 2, 4 and 5. This PR fixes what was left of item 3: - **A held scrollbar press** (3a). In Chromium a thumb drag sends `pointerdown` on the scroller at the press, no `pointermove` while the thumb moves, then scroll events, then `pointerup` at release (measured in Playwright's Chromium with scrollbars shown). `ChatView` now remembers that a primary-button press on the transcript's scrollbar is held. While it is held, an upward move counts as the reader's own, however long the thumb rested first. The hold ends on `pointerup`/`pointercancel`, on a new press, on any pointer event with no button down (a release this page did not see), and when the chat's input listeners are removed (the pane hidden or left). - **The 1 px and 48 px values** (3c) are named: `READER_ALLOWANCE_PX` (endpoint rounding only, after the reader's own input) and `LAYOUT_ALLOWANCE_PX` (a composer growing a few lines before the correction to the end lands). - **Screen-reader scrolling** (3b) is not fixed and is documented beside `LAYOUT_ALLOWANCE_PX`. A scroll that sends no input this page can see, from a screen reader or from Firefox's scrollbar (which may send no press), leaves the end only past 48 px. The page has no signal to tell such a scroll from the composer's own growth, and guessing would bring back the composer-growth bug #1431 fixed. No visible change otherwise. Design precedent: none of the coding-agent apps exposes this. It follows the rule #1734 set: only input that scrolls the transcript up is the reader's intent. **#1831:** that open PR edits the same `allowance` line in `onScroll` (it adds `byReader` and `navigated()`). Whichever lands second keeps both: #1831's `byReader` with the named constants. A held-thumb drag then also counts as navigation for #1831's follow of the reader's own send. ## How it was verified - `scripts/chat-virtual-browser-qa.ts` (already in CI's browser lane) runs the real `ChatView` in Chromium at 1440 px and 390 px, light and dark. Its scroll-intent loop gains four cases. Each fires the scrollbar press on the scroller right of its content box, then moves the transcript up 20 px, inside the layout allowance but past endpoint rounding. `performance.now` is skewed by 600 ms around that move, so the move comes after the input window as a resting thumb's would, with no sleep. - `scrollbar-held`: the press is still held when the move lands. Following stops and **New messages** shows. - `scrollbar-held-released-first`: the thumb is released before the scroll event is delivered (the order Codex's review found). Following stops. - `scrollbar-released`, `scrollbar-unseen-release` (no `pointerup`, the next pointer event has no button down): the press is over, so the same 20 px correction keeps following. - On origin/main the script fails at `scrollbar-held: only upward input stops following` (`0 !== 1`). On this branch it passes, 52 PASS, together with the existing cases: a downward wheel, a click, typing and composing keys keep following; an upward wheel, navigation keys and a drag stop it; a composer growing a line paints no frame off the end. - `bun run check fast` passes on this commit (typecheck, build, unit tests). - Reviewed by a code-review agent (omo, approved) and by Codex (gpt-6.1-sol). Codex's one MEDIUM (a thumb released before the browser delivered its scroll lost the intent) is fixed and covered by `scrollbar-held-released-first`. omo's LOWs: - **Fixed:** the hold now needs the primary button, and it is cleared when the chat's input listeners go away (the pane hidden or left mid-press). - **Left:** a new press clearing the hold has no case of its own; it duplicates the release paths. Not reproduced on a real Firefox or with a screen reader; see the screen-reader note above. --------- Co-authored-by: mp <mp@local>
## What it does for the user Chat now keeps following new output to the end when part of the transcript folds on its own. Before this, a turn settling at the end (its work folding together with a block above it), or a block above the view folding while the view was still gliding to the end, could stop following mid-transcript and show **New messages**, with no scroll by the reader. Fixes #2042. Reported by @odfalik. ## Cause `onScroll` in `src/components/ChatView.tsx` treats an upward move with no reader input that lands past the 48 px layout allowance as the reader leaving the end: it sets `pagingAway` and drops the list's pending scroll to the end. LegendList (`maintainVisibleContentPosition`) and the browser make such moves themselves when the transcript shrinks. The list holds the rows on screen where they were, and the browser keeps the view inside a shorter transcript. For one shrink both can move the view up, so it lands hundreds of pixels from the end, or past the end of a follow glide that was still on its way. ## Change - Without reader input, an upward move during which the transcript got shorter (the last row moved up in it, or its height dropped since the previous scroll event) now counts as the layout's: following goes on, and a view left more than 48 px short of the end is put back there. - That pin-back is skipped while `pagingAway` is set and while a following reader's own click is laid out where they are (ChatTimeline `manualLayout`), as the timeline's own follow paths already do. - Over a transcript that did not shrink, nothing changes: a no-input scroll (a screen reader's, a Firefox scrollbar's) leaves the end once the view is past 48 px from it, however small its steps (#1902). Reader input (wheel, keys, touch, a scrollbar drag) is unchanged. - The new scroll baselines reset with the chat's other scroll state on a pane change or a history replacement. Known trade-off: a no-input reader scroll that lands in the same scroll event as a fold is put back at the end once; the next move leaves as before. During a turn that keeps folding this can happen more than once. The page has no signal that tells such a scroll from the layout's own move in that event. Design precedent: none of the coding-agent apps exposes how it tells its own re-layout from a reader's scroll; this follows the rule #1734 set and #1902 kept, that only input that scrolls the transcript up is the reader's intent. ## How it was verified - `scripts/chat-virtual-browser-qa.ts` (real `ChatView` in Chromium, 1440 and 390 px, light and dark, already in CI's browser lane) gains: - `fold-together`: at the end, the last row and a row above fold in one layout (a turn settling). Following goes on to the end and the next output is followed. **Fails on main** ("fold-together: the next output is followed"), passes here. - `fold-above` / `grow-above`: a row above folds or grows while the view glides to the end after the last row grew. These pass here; on main they fail only when the fold lands in the same frame as the glide, so they do not fail on every main run. - `wheel-up`: a real upward wheel (`page.mouse.wheel`) still stops following ("Jump to latest", then **New messages** with the reader left away from the end). - Two 30 px upward steps without input from the end stop following past the allowance. This catches the first commit's regression found in review. - Full script: 60 PASS over all four width/theme combinations, exit 0. - `scripts/chat-local-send-follow-demo-regression.ts` (#1831), `scripts/chat-gjc-streaming-browser-qa.ts` (#1388/#1937) and `scripts/composer-fit-demo-regression.ts` (#1431): pass on the final commit. - `bun run check fast`: green on the final commit. - Reviews: Codex (gpt-6.1-sol, fast, xhigh) and the omo code reviewer. Both blocked the first commit on one finding: the 48 px allowance applied per scroll event, so small no-input steps were pinned back (a #1902 regression). The second commit measures it from the end again. The omo reviewer's other findings were fixed: the `manualLayout` guard and the baseline resets. Codex re-reviewed the fix: APPROVE. Not reproduced on a real Firefox or with a screen reader. Once, during QA, a real wheel landing early in a glide did not stop following; it did not reproduce in six later runs (three on main, three here) and this change does not touch moves made with reader input.
Change
Fixes the main CI failure after #1342 (run 39324428972):
scripts/composer-fit-demo-regression.tstimed out waiting for the chat to stay at the bottom while a multiline draft grows the composer (twice in CI, and 5/5 locally on main 69f0959; f736a9c, just before #1342, passes all 25 cases).#1342 added a branch to
ChatView.onScrollthat turns any upward move over 1 px while following into reading intent, so a near-end wheel of 20 px stops following (the sidebar's near-end case relies on that). A growing composer shrinks the transcript viewport and causes such an upward move before the bottom correction lands, without any input, so the chat stopped following and stayed above the end.Now an upward move counts as reading from the first pixel only within 500 ms of the reader's own scroll input in the transcript (wheel, touch, pointer, keys); otherwise the follow intent keeps main's 48 px allowance. The end presentation the unread dot relies on is still measured exactly (
measureEnd, 1 px), so a finish counts as seen only once its end is on screen.The first commit (48 px for the follow assignment alone) was a no-op, as the review found: the branch above decided first.
Validation
bun scripts/composer-fit-demo-regression.ts: 25 PASS, three runs in a row (main and the first commit: 0/3).bun scripts/sidebar-activity-demo-regression.ts: 41 PASS, including near-end (a 20 px wheel shows New messages).HERDR_TEST_MODE=unit bun test src/lib/panePresentation.test.ts src/lib/sidebarActivity.hook.test.ts src/lib/chatScrollMemory.test.ts src/conventions.test.ts: 46 pass.