Repository navigation
Conversation
Requested: stop one intermittently failing browser journey from failing CI: tests/browser/history-loading.spec.mjs:295, "pages inside one second › input after the page lands starts from the reader's row", on Linux WebKit. Find why the reader's row ends somewhere other than 40 px lower and fix that where the cause is. What fails - After the 40 px wheel the reader's row is 7.09, 22.25 and 7.86 px from where the journey expects it (CI runs 45108381111, 45096440304 and 45088508339, on three unrelated branches), and stays there for the whole 10 s poll. - Rate: 3 of the 118 "Browser journeys (webkit, 2/18)" jobs that completed in the 150 CI runs from 2026-11-23 00:23 to 05:44 UTC, counting each run's latest attempt. Cause: a product defect, in the reader's hold - Linux WebKit animates a mouse wheel over several frames. Any scroll write during that animation ends it where it is, including a write that changes nothing. In a bare page a -40 wheel moves 27 to 31 px in its first frame and reaches 40 in the next. Writing `scrollTop = scrollTop`, `scrollTop += 0.2` or `scrollTop += 5` in the first scroll event ended the wheel at that first step in 24 of 24 runs; 8 of 8 reached 40 without a write. - WebKit truncates scrollTop. The hold keeps the reader's row at an exact Y, so its first correction lands up to 1 px short, and every later measurement makes it write that same fraction again (for example 1225 to 1225.015625). The write moves nothing. - When a row measures while a wheel is still animating, that write ends the wheel. The reader loses the rest of the notch. - The three CI traces fit this. The scroller moved 32, 17 and 32 px of the 40. The list's height changed in the same step. Virtua's offset for the reader's row did not change, so nothing above it had moved and there was nothing to correct. Before the wheel the row sat 0.90, 0.75 and 0.14 px from the hold's Y. Each failure equals 40 minus the distance moved, less that fraction. Traces do not record scroll writes, so which code wrote is inferred there and observed locally. - Reproduced in a Linux WebKit container (Playwright 1.63.0 image) on main at 3064169, with every scrollTop write, scrollBy and scrollTo on the scroller logged and a row below the reader grown as the wheel starts: 9 of 16 runs failed. In each, the only scroll write between the wheel and its scrollend was the hold's fraction, and the scroller stopped 1 to 24 px into the wheel. Virtua wrote nothing. The 7 that passed finished the wheel before the row measured. Fix: src/features/messages/scroll-correction.ts - correctScrollTop remembers, per scroller, the part of its last correction that the offset did not take when that part is under 1 px. A correction that asks for that same fraction again is skipped: the scroller already refused it, so the write could only interrupt the reader. - A shortfall of 1 px or more is the end of the scroll range, which content can move, so it is not remembered and is asked again. - Corrections that move the scroller are unchanged, and so is the Y the hold keeps: it still asks for its exact position, so truncation does not add up across corrections. - This is not specific to Linux. On Mac WebKit a skipped correction also no longer hides overflow for a task, so a correction that moves nothing no longer stops trackpad momentum. The thread panel's corrections use the same helper and skip the same repeats. Tests - scroll-correction.test.ts: a scroller that truncates gets no second write for the fraction it left, and still takes the next real correction. A correction the end of the range refused is written again. The first fails on main's helper; the second passes there and guards the 1 px rule. - The journey now grows the last mounted row as the wheel starts, so a row measures during the wheel on every run instead of by chance. The 40 px expectation and its 4 px tolerance are unchanged. Nothing is skipped, retried or loosened. Verification - Linux WebKit, container, two workers, this journey: - edited journey on main's helper: 3 of 20 failed (36.6, 36.8 and 38.1 px from the expected Y); - edited journey with the fix: 60 of 60 passed; - the logged reproduction with the fix: 32 of 32 passed. In 18 of them a row measured mid-wheel, no scroll write followed, and the wheel finished. - the journey with the fix under full CPU load: 24 of 24 passed; - the whole spec with the fix, once, WebKit and Chromium: 46 of 46 passed. - macOS, local: the journey 10 of 10 on Chromium and 10 of 10 on WebKit. - vitest: scroll-correction.test.ts with the ChannelTimeline and ThreadPanel suites, 9 files, 549 tests, all passed. - pnpm typecheck: pass. biome check on the three changed files: pass. Not run - The whole vitest suite, the other browser specs and the integration tests. - The desktop app, and WebKitGTK outside Playwright's build. - Before the journey was edited it passed 10 of 10 unloaded and 24 of 24 under full CPU load on main in the container. At CI's rate that says nothing either way, which is why the evidence above forces the measurement. Remaining gaps - A correction that has to move the scroller still ends an animated wheel in Linux WebKit: a row above the reader that changes height mid-wheel, or Virtua's own jump. That is needed to keep the row in place, and the browser does not expose the wheel's target to resume it. The three CI failures were not this case, and the journey does not force it. - The Virtua patch's jump can issue a sub-pixel scrollBy of its own. I did not see one in any log and left it alone. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord found no blocking issues in the source review of b971206. Ready for Wes’s approval once CI passes, including the Linux WebKit flake check.
jedwards27
left a comment
There was a problem hiding this comment.
🤖 :bot: Jude’s code review agent — recommend changes before merge.
Reviewed: 306416901219871e3d3ef077bc03e2c101948215...b9712069767351453643b970a52d30c973859a79 (exact head b9712069767351453643b970a52d30c973859a79). Risk: high, because this changes the reader's scroll correction and virtualized timeline hold. No relay or native IPC contract is changed by the three-file diff.
Finding (P2, author-actionable): src/features/messages/scroll-correction.ts:46–49 caches any subpixel shortfall as offset quantization, but a fractional-scroll engine can produce the same shortfall when the requested target exceeds the current range. At scrollTop=99.5, max=100, a +0.75 correction clamps to 100 and caches 0.25; after content increases max to 101, the next +0.25 is skipped at line 22 even though it is now possible. In the thread reader, ThreadPanel.tsx:1648–1653 also advances its held target after the skipped correction, so successive growth can leave its held row displaced. The added range test at scroll-correction.test.ts:110–117 covers a 40px shortfall, not a subpixel clamp. Author action: distinguish range clamp from quantization before memoizing, and add a deterministic fractional-offset clamp → range-growth → retry regression. This stays within the helper/test ownership boundary.
Validation: pinned source and caller review; git diff --check 306416901219871e3d3ef077bc03e2c101948215...b9712069767351453643b970a52d30c973859a79 passed. At the exact clean head, focused scroll-correction/ChannelTimeline/ThreadPanel test files passed (430/430), and the changed history-loading journey passed locally on macOS Chromium and WebKit. GitHub checks at final preflight: 69 success, 1 skipped. These do not exercise the fractional range-growth case. Manual/native evidence: macOS browser journey only; no independent Linux WebKitGTK native wheel reproduction. Verification owner: author for code and regression; reviewer/tooling for platform-specific follow-up, with CI/release gate for hosted checks. The absent Linux reproduction is a confidence gap, not the reason for this recommendation.
What fails
tests/browser/history-loading.spec.mjs:295, "pages inside one second › input after the page lands starts from the reader's row", fails intermittently on Linux WebKit. After its 40 px wheel the reader's row is expected 40 px lower, within 4 px, and stays somewhere else for the whole 10 s poll.Cause
A product defect in the reader's hold, not a test race.
scrollTop. The hold keeps the reader's row at an exact Y, so its first correction lands up to 1 px short. Every later measurement makes it write that same fraction again (for example1225to1225.015625), which moves nothing.Evidence
CI traces (decoded from the three
browser-journeys-webkit-2artifacts):In all three the list's height changed in the same step as the short scroll, and Virtua's offset for the reader's row did not change. Nothing above the row had moved, so there was nothing to correct. Traces do not record scroll writes, so which code wrote is inferred there and observed in the reproduction below.
Bare page, Linux WebKit (Playwright 1.63.0 container): a −40 wheel moves 27 to 31 px in its first frame and reaches 40 in the next. Writing
scrollTop = scrollTop,scrollTop += 0.2orscrollTop += 5in the first scroll event ended the wheel at that first step in 24 of 24 runs; 8 of 8 reached 40 without a write.In the app, on
mainat 3064169, with everyscrollTopwrite,scrollByandscrollToon the scroller logged and a row below the reader grown as the wheel starts:scrollendwas the hold's fraction, and the scroller stopped 1 to 24 px into the wheel. Virtua wrote nothing.Change
src/features/messages/scroll-correction.ts:correctScrollTopremembers, per scroller, the part of its last correction that the offset did not take, when that part is under 1 px. A correction that asks for that same fraction again is skipped: the scroller already refused it, so the write could only interrupt the reader.Effects beyond Linux:
Tests:
scroll-correction.test.ts: a scroller that truncates gets no second write for the fraction it left, and still takes the next real correction. A correction the end of the range refused is written again. The first fails onmain's helper; the second passes there and guards the 1 px rule.Verified
Linux WebKit, container, two workers, this journey:
main's helperAlso:
scroll-correction.test.tswith theChannelTimelineandThreadPanelsuites, 9 files, 549 tests, all passed.pnpm typecheckandbiome checkon the three changed files pass.Not verified
mainin the container. At CI's rate that says nothing either way, which is why the evidence above forces the measurement. The Flake check lane's repeats of the edited journey on Linux WebKit are part of the evidence for this PR.Remaining gaps
scrollByof its own. None appeared in any log, and it is left alone.🤖 Generated with Claude Code