Skip to content

fix(chat): keep a scrolled-up reader in place while a reply streams - #18508

Merged
iamwhatever merged 1 commit into
mainfrom
fix/18421-follow-release-while-streaming
Oct 9, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/18421-follow-release-while-streaming

Conversation

@pepmach

@pepmach pepmach commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A reader who scrolls up while a reply is streaming stays where they scrolled; the transcript follows only a reader who is still at the bottom.

On 0.8.0 (Windows desktop, #18421), scrolling up during a streaming reply does not hold: the next streamed update pulls the view back to the bottom, every time, until the turn ends. Reproduced on current main with a test driving the real transcript hook: an upward wheel notch followed by a new tail row in the same frame lands the reader at the new bottom (expected 8720 to be 8599: 8599 is where the reader stopped, 8720 the new bottom).

Why it matters

Long replies and multi-tool turns are exactly when a reader wants to re-read what came before. Being pulled back on every update makes the transcript unreadable for the whole turn, and a mouse wheel, the most common desktop input, triggers it every time.

Not a goal

  • Changing when follow releases or re-arms on a scroll outside the self-scroll tolerance (that path is untouched).
  • Touching explicit-intent scrolls (send, jump-to-bottom) or anything but the pending-intent hold.
  • A platform-specific branch: the input shape, not the platform, is what matters.
  • The side-panel toggle jump in Chat transcript scroll jumps when the artifact/activity side panel is toggled #13092 (a width-driven trigger, separate cause).

What changed (motivation → approach → change)

Follow tells the reader's scroll events from its own by comparing the live scrollTop to the value it last wrote, within a 2px tolerance (SELF_SCROLL_EPSILON) meant for sub-pixel rounding. It also already holds the automatic pin while an upward input is waiting for its scroll event (scrollIntentPending), and retired that hold on the next scroll event of any origin.

A desktop wheel notch is one 100px input the browser animates over several frames, and the first scroll event of that animation moves a fraction of a pixel to a couple of pixels; a slow precision touchpad reports a pixel or two per event. Such a frame lands inside the tolerance, so the handler rightly reads it as its own pin landing and leaves follow armed. But it also retired the hold, and a row appended in that frame found a reader "resting on our write" and pinned them to the new bottom with an instant write, which also cancels the in-flight wheel animation: the notch was eaten whole.

The change is one condition in onFollowScroll: the hold is retired only by a scroll event outside the tolerance. A frame inside it cannot say whether it is the pin landing or the first frame of the reader's input, so the intent stays pending; the append's pin is held until the notch's next frame lands outside the tolerance and releases follow through the unchanged path, or the intent expires unanswered (a wheel the transcript never answered) and the held pin retries against a reader who is still resting, as it does today. The same stamp serves the scrollbar-grab hold (a pointer that landed on the thumb or track, whose first drag frame can be as small), so that hold now outlives a sub-tolerance frame in the same way.

Area Change
website/src/hooks/virtualizer/followPolicy.ts lastScrollEventAtRef is stamped only for a scroll outside SELF_SCROLL_EPSILON of the last write; the ref's comment says why
website/src/hooks/virtualizer/FollowController.ts Doc comment of scrollIntentPending describes the narrowed stamp (no logic change)
docs/system-specs/modules/history.md The follow paragraph describes the rule

No scrollTop writer changes; every write still goes through writeScrollTop. Follow fixes merged since the 0.8.0 cut (#14568, #14906, #13066, #15974, #13359, #18047) address other triggers (composer dock, idle DM follow, table width, restore, iOS toolbar, quiet-reply footer); none covers this frame, so the issue reproduces on current main.

Backwards compatibility

Compatible: nothing that works today stops working. Every scroll outside the 2px tolerance retires the hold exactly as before, and the hold still expires after SCROLL_SETTLE_MS with the same retry; the only difference is that a scroll inside the tolerance no longer retires it, so an append landing in that frame waits up to 150ms instead of pinning at once.

Removes nothing: the diff narrows one stamp and edits two comments and a spec paragraph.

Tests

  • website/src/test/useVirtualChat.streamingWheelRelease.test.tsx (new) drives the real hook through a fake scroller: a large wheel step up; a notch whose first frame is under SELF_SCROLL_EPSILON with a new tail row in that frame; 1px touchpad steps with a chunk after each, and with a new row between them; a height commit between two scroll events of one gesture; an upward input never answered past one sub-epsilon frame (the held pin retries at expiry); a still reader who is carried; a pin landing a quarter pixel short under an upward input that moved nothing (keeps following). Three of the eight fail on current main (expected 8720 to be 8599 for the notch and touchpad-row cases, a premature write for the unanswered-intent case).
  • Full website (2735 files) and electron suites, build, lint, i18n:check pass.

Manual verification

Static render of the real chat page (built app, stubbed API, Chromium) under a controlled clock, long transcript, running turn: one wheel notch up, its first 1px frame, a new tail row committing in that frame, then the notch's second frame. Before the fix the view lands at the new bottom at commit (the anchor row moves 317px); after it the anchor row keeps its viewport position while the transcript grows below it and the jump pill appears. Both themes. Not measured: the size of a Windows wheel notch's first animation frame on the reporter's machine. The repro asserts a frame inside the 2px tolerance, which is the shape of a smooth-scrolled notch and of a slow touchpad; a frame outside it already released follow on main.

Screenshots / video

Before the fix, after a new row landed on the notch's 1px first frame (pulled to the new bottom):

Before the fix, dark, after the row

After the fix, the same scene before and after the appended row (the view holds):

After the fix, dark, before the row

After the fix, dark, after the row

Light theme: the two after-the-row frames (before and after the fix) are attached below.

Related Issues

Fixes #18421

Pattern harvest

Rule candidate: review-prompt
Pattern: a hold that waits for "the event that answers the input" is retired by the first event of any origin, including one the code itself classifies as undecidable (inside a self-write tolerance); ask any such hold whether the event that retires it is one it would also act on.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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.

Before the fix, light, after the row

After the fix, light, after the row

A reader who scrolled up while a reply streamed was pulled back to the
bottom by the next streamed update, so a scrolled-up position could not
be held until the turn ended. Auto-follow must pin only a reader who is
still at the bottom.

The follow policy already holds the automatic pin while an UPWARD input
is waiting for its scroll event (scrollIntentPending), and retires that
hold on the next scroll event of any origin. A desktop wheel notch is one
100px input the engine animates over several frames, and the first
scroll event of that animation moves a fraction of a pixel to a couple
of pixels; a slow precision touchpad reports a pixel or two per event.
Such a frame lands inside SELF_SCROLL_EPSILON (2px) of follow's last
write, so the scroll handler rightly reads it as our own pin landing and
leaves follow armed -- but it also retired the hold, and a row appended
in that frame found a reader "resting on our write" and pinned them to
the new bottom with an instant write that cancelled the notch's
animation as well: the whole notch was eaten.

onFollowScroll now retires the hold only for a scroll event OUTSIDE the
epsilon. A frame inside it cannot say whether it is the pin landing or
the first frame of the reader's input, so the intent stays pending: the
append's pin is held until the notch's next frame lands outside the
epsilon and releases follow through the unchanged path, or the intent
expires unanswered and the held pin retries against a reader who is
still resting. No scrollTop writer changes and every write still goes
through writeScrollTop.

Red-first vitest drives the real hook through a fake scroller: one
large wheel step, a notch whose first frame is under the epsilon with a
row appended in that frame, 1px touchpad steps with chunks and appended
rows between them, a height commit between two scroll events of one
gesture, an upward input never answered past one sub-epsilon frame (the
held pin retries), a still reader who is carried, and a pin landing a
device pixel short under an upward input that moved nothing. The history
module spec describes the rule.
@pepmach
pepmach requested review from a team and KiroCrewCaptain as code owners October 9, 2026 15:45
@pepmach
pepmach requested a review from CrysisDeu October 9, 2026 15:45
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f62618e7c1cb389826c204eb10db6eb06489fa7e — 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

Check on a real Windows desktop that a wheel notch's first animation frame is under 2px. The author says this was never measured.

What this change ships

Inventory (4 items) — 4 justified

Intent: let a reader who scrolls up during a streaming reply stay where they scrolled (#18421). FIX.

  1. A wheel notch or slow touchpad step whose first frame moves under 2px no longer gets pulled back to the bottom by a row appended in that frame. — justified
  2. A scrollbar grab whose first drag frame is under 2px keeps its hold through that frame in the same way. — justified
  3. A follow pin under an upward input that never got a scroll answer now waits up to SCROLL_SETTLE_MS before it retries, where it used to pin straight away. — justified
  4. The history.md follow paragraph and the scrollIntentPending / lastScrollEventAtRef comments now describe the narrowed stamp. — justified

[FIRST-PRINCIPLES-REVIEWED] f62618e

Description read

[DESCRIPTION-READ] 917cffd14aae90a488ab8615f845cc20239f2a4b432bb80befb842cf24b485f7

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 9, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check on a real Windows wheel that the second frame of a notch moves more than 2px inside the 150ms SCROLL_SETTLE_MS hold. The PR says it did not measure this.

[DESIGN-REVIEWED] f62618e

Description read

[DESCRIPTION-READ] 609ee9b8d7c7517c3ed51e02cab908c70055d5b6b46f890a15cfeef0884c95ff

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 9, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Check on a real Windows wheel notch, the reporter's case. The PR itself says the size of that notch's first frame was never measured.

[UX-REVIEWED] f62618e

Description read

[DESCRIPTION-READ] a469771811984ad9cf23e2e55b0ad95b59e2d64c931e1a3e693414d525f5b5f5

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f62618e

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

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f62618e

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

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

@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 9, 2026
@pepmach

pepmach commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

CI on f62618e7c1: one red, E2E (stub ACP backend, offline) (run 37954076156, job 113901304407), on a spec this diff does not touch. test/test_playwright_e2e.py::test_dashboard_playwright_suite failed the MAX_FLAKY_SPECS=0 ceiling: playwright/session-tags-e2e.spec.ts:740 > E2E: sidebar tag columns > 17b. right-click on ANOTHER row while the Tags picker is open closes the picker and opens that row's menu passed only on a retry (324 passed, 1 flaky, 10.5m). That spec drives the sidebar tag-column context menu; this PR changes only the chat virtualizer's follow policy (website/src/hooks/virtualizer/followPolicy.ts, FollowController.ts), one new vitest file and a history.md paragraph. Flake, untouched by this diff; it is the known 17b retry flake tracked in #17941 (sightings on nine unrelated PRs since 10-08). Re-ran only the failed job once at 16:44 UTC; no code change.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 9, 2026

@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.

This fixes #18421, where a wheel notch or slow touchpad step during a streaming reply was eaten and the reader snapped back to the bottom. The root cause is fixed: onFollowScroll in website/src/hooks/virtualizer/followPolicy.ts retired the pending upward-intent hold on any scroll event, including a sub-SELF_SCROLL_EPSILON first frame that cannot tell the reader's input from our own pin landing. It now stamps lastScrollEventAtRef only for a scroll outside the epsilon, which is one condition. I read the full diff. The only side effect is that an append arriving in that frame waits up to SCROLL_SETTLE_MS and then retries, so a resting reader is still carried. The new useVirtualChat.streamingWheelRelease test drives the real hook, and three of its cases fail on main. The other cases pin the still-reader and quarter-pixel-short-pin paths, so the hold cannot turn into a follow brake. Base is main, all checks are green, all three AI lanes are PASS, and no change request is open. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 9, 2026 19:32
@iamwhatever
iamwhatever merged commit 547b3f6 into main Oct 9, 2026
147 of 148 checks passed
@iamwhatever
iamwhatever deleted the fix/18421-follow-release-while-streaming branch October 9, 2026 19:34
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 2026
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.

Chat transcript auto-scrolls to bottom while the agent streams, preventing scroll-up (regression in 0.80)

2 participants