Repository navigation
fix(threads): keep scrolling the thread over interactive visuals - #707
Merged
Merged
Conversation
Wheel and touch input over a visual's sandboxed frame stays in the frame while its scroll chains to the thread feed. The feed saw a scroll with no reader gesture, took it for a layout change and restored its anchor or the end, so the thread froze under the cursor and then jumped. The kit now reports whether the pointer is inside the frame (a bare boolean, rate-limited and validated by the host inbox), and the feed takes a scroll under a hovered frame as the reader's. The kit document also stops being scrollable when its content fits, so a sub-pixel overflow can't capture a whole wheel gesture. Fixes: #685
nixuuu
marked this pull request as ready for review
November 14, 2026 12:19
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
Scrolling up a long thread could snap the view back to the end or jump it by hundreds of rows as older rows were measured. - Re-estimated rows above can shorten the scroll range below the reading position. The browser clamps to the new end; during a gesture that clamp counted as the reader reaching the end and turned following back on. A clamp is now layout: the anchor is restored. - A smooth scroll (wheel, Page Up) moves ahead of its scroll events. When settle took such a scroll in after a re-estimate, it recaptured the anchor from rows not yet corrected, often finding none. The anchor now moves by the reader's distance and settle corrects the rest in the same frame. Related: #687, #707
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
…721) ## Problem Scrolling up a long thread sometimes moved the view by itself: it snapped back to the end, or jumped by hundreds of pixels to rows far above. It happened over the margin too, with no visuals (found while testing #707, reproducible on `dev`). ## Root cause Older rows are re-estimated as rows are measured (group averages). Two paths then lost the reading position: 1. **Clamp counted as the reader.** A re-estimate can shorten the scroll range by more than the reader's distance from the end. The browser clamps `scrollTop` to the new end. While a wheel/key gesture lease is active, `ScrollIntent` labelled that clamp `reader` with distance 0, so `followingAfterScroll` turned following back on and the view snapped to the end. 2. **Anchor recaptured from uncorrected rows.** A smooth scroll (wheel notch, Page Up) moves ahead of its `scroll` events. When `settle` (after `padTop` changed) took such a pending scroll in, `onscroll` recaptured the anchor from rows that the re-estimate had just moved, often by thousands of px. Often no row was on screen: the anchor was dropped, and the window then followed the estimate, about 165 rows away. ## Fix - `scrollOrigin` (`scroll.ts`): a position clamped to the end of a range that shrank below the last position is `unattributed` (layout). `settle` restores the anchor, in the same frame. - `followScroll` (`feed-anchor.ts`): a scroll taken in by `settle` (no event) moves the existing anchor by the reader's distance, instead of reading the rows on screen. `settleAnchor` then corrects the layout part in the same frame. Native scroll events still recapture as before. - #687 (cached threads, restored position) and #707 (scroll over visuals) logic is unchanged. A local check: scroll up, switch to another thread and back. The same row returns at the same offset. - Docs: `client-performance.md` has the measurement lessons (frames with no shared row are jumps; `layout-shift` also counts same-frame compensated corrections; check smooth wheel and Page Up). ## Measurements Private bench stack (`scripts/bench/client-stack.ts`), Chromium with smooth scrolling and `--site-per-process`. 120 steps per run, starting at the end. A probe samples every frame after paint (rAF, then a task) and compares the rows on screen with the previous frame. A **jump** is a frame where shared rows move against the scroll or further than one input step. A **teleport** is a frame with no shared row: a snap to the end or a leap to another part of the thread. `/dev/long-thread?turns=1000` (all 5000 rows loaded, mostly estimated): | Input (120 steps) | Width | `dev`: teleports (size) | This branch | | --- | --- | --- | --- | | Wheel −40 px | 1280 | 2 (−1188, −24060 px) | 0 | | Wheel −100 px | 1280 | 5 (−198 … −23980 px) | 0 | | Trackpad-like (4 × 8–32 px) | 1280 | 4 (−1196 … −24060 px) | 0 | | Page Up | 1280 | 30 teleports + 30 jumps (max 935 px) | 0 + 0 | | Wheel −40 px | 390 | 1 (−22155 px) | 0 | | Wheel −100 px | 390 | 2 (−22115, −2066 px) | 0 | | Trackpad-like | 390 | 2 | 0 | | Page Up | 390 | 33 teleports + 17 jumps (max 1262 px) | 0 + 0 | Seeded 1000-turn thread page (history paged in through the gateway): wheel and trackpad-like runs had no jumps on `dev` either. Paging keeps the estimated region small. Page Up had 5–6 teleports and 3–6 jumps (max 528–597 px) on `dev`, 0 and 0 on this branch, at both widths. With smooth scrolling off, `dev` Page Up had no jumps: the second path needs a smooth scroll. Real mouse wheels are smooth-animated on Linux and Windows, so the reported 360–400 px wheel jumps are likely this path. Synthetic CDP wheel events in headless Chromium are not animated, so they only reproduced the first path. `layout-shift` entries are not a jump metric here: a 3 px row growth with `scrollTop += 3` in the same frame also produces them on a plain test page, more during smooth scrolling. ## Browser check On a second machine with a fresh clone of this branch (own ports, own container, cleaned up afterwards), I ran the same 15-run matrix on both pages. It covered wheel −40 px and −100 px, trackpad-like and Page Up, at 1280 × 900 and 390 × 844. All runs had 0 teleports and 0 jumps, and visual travel matched input (e.g. 12000 of 12000 px). Page Up now travels about 75000 px over 120 presses, against 62000 on `dev` (the view no longer falls back). Cached threads (#687): scrolled up, switched to another thread and back. The same row returned at the same offset. No visual change, so no light/dark difference. After rebasing onto `dev` with #707, the same 16 runs (both pages, both widths, wheel −40 and −100 px, trackpad-like, Page Up) again had 0 teleports and 0 jumps. A clamp still wins over #707's hovered-frame attribution: a clamp is layout even while the pointer is over a visual. ## Checks `bun install`, `gen:check`, `typecheck`, `lint`, `format:check`, focused test (`tests/integration/thread-scroll.test.ts`, the clamp origin), web build. ## Copy audit (docs/copy.md §8) No UI text changed. Related: #687, #707
This was referenced Nov 16, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 26, 2026
Fixes: #1300 The per-target desktop workflow call did not pass repository signing secrets. In Release #707 both macOS jobs fell back to ad-hoc signing, so electron-builder omitted `nightly-mac.yml` and the publication gate kept the release in draft. Pass the signing secrets to the reusable workflow with `secrets: inherit` and document the handoff. Local verification: formatted the edited workflow with oxfmt, parsed both workflow YAML files and checked the reusable call and secret forwarding, and ran `git diff --check`. Required checks run in GitHub Actions. The next eligible Release can verify signing and feed generation on both macOS targets. Incident: https://github.com/itsoltech/canopy/actions/runs/45803821381/job/139865717474
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On web and desktop, the thread stops scrolling while the cursor is over an interactive visual, then jumps once the cursor leaves it. The user's recording shows this.
Root cause
Wheel and touch input over the sandboxed visual frame goes to the frame's document. The frame can't scroll, so the scroll chains to the thread feed, but the feed never gets the
wheelevent.ScrollIntentlabels that scrollunattributedandsettle()treats it as a layout change. It then restores the reading anchor, or the end when following, and every step is undone.Fix
hover: a bare boolean that says whether the pointer is over the frame. It carries no coordinates and forwards no other events. The kit sends at most 4 per second, and the last report always carries the current state.VisualFrameInboxparses it, checks the type, and rate-limits it with its own window (hoversPerSecond).pointermovein the feed's own document clears the state, and so does unmounting the frame.overflow: hiddenotherwise). A document that can scroll even 1px captures a whole wheel gesture. The height is now measured from the bounding box and rounded up.readyincludes the body padding too, so the frame no longer hops 24px after mount.allow-scriptsonly, same CSP, port-only channel.scrollEnabled={false}), so mobile doesn't have this problem. Mobile ignores the new message.A per-gesture message didn't work: in Chromium (site-per-process), the feed's scroll event can arrive before the frame's message, even with a non-passive listener. The hover state arrives long before any wheel.
Verification
Chromium with
--site-per-process, on the/dev/long-threadfeed with a local fixture (not committed) that adds a tabs + stats + chart visual every third turn. I measured how far a row moved on screen for each wheel step:devdev: it is the virtual feed measuring rows above, not the frames.overflowY: hidden, scrollHeight equals innerHeight (719).Checks:
bun install,gen:check,typecheck,lint,format:check,check:tmp, the web build,expo exportfor Android and iOS.Copy audit (docs/copy.md §8)
No UI text changed.
Fixes: #685