Repository navigation
Conversation
ChatMessageList's scrollToTopAction fired at scrollTop 0, exactly where CSS scroll anchoring is suppressed, so prepended history teleported the reader and the sentinel never re-armed after the first load. - Anchor-based compensation: capture the first content element and its offset in the resolved scroll container at fire time; restore it per commit until the prepend lands. Measured, not assumed, so it composes with native anchoring and bails when the reader scrolls mid-load. - Single-flight guard; the action lives in a ref so inline callbacks no longer reconnect the IntersectionObserver every render. - aria-busy while loading so prepended history is not announced as new. - Underfilled lists keep loading until they overflow. - Standalone lists compensate the nearest scrollable ancestor, not the page. Adds 15 tests (IntersectionObserver + rect-stub harness), a Storybook 'Load Earlier History' story, and doc.mjs contract notes. Refs meta#4102
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsOutline (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 3 accessibility violation(s) found — 3 serious. ChatComposer - 1 issue(s)
ChatComposerInput - 1 issue(s)
ChatToolCalls - 1 issue(s)
Visual RegressionStatus: No visual change across 420 compared shot(s). Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
- accept the deprecated overflow-y: overlay like Outline's getScrollableAncestor, and document why findScrollContainer deliberately has no scrollHeight > clientHeight requirement - pin coalesced IntersectionObserver delivery, the empty-page auto-refill bound, and standalone nearest-scroller compensation - settle the dangling refill action in the underfilled-list test: React runs async transition actions on one global chain, and a forever-pending load wedges every later transition commit
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for this, it's careful work and the tests are the best part.
align="top" landed on main after you opened this, and it omits the spacer. Your anchor is the spacer's next sibling, so a top-aligned list anchors nothing and the reader lands 20 messages from where they were. I measured 1160px of lost position on your own story with align="top"; no test sets it, so the suite stays green either way.
Ideally I'd like the anchor to fall back to the sentinel, which is there whenever scrollToTopAction is:
const anchor = (spacerRef.current ?? sentinelRef.current)?.nextElementSibling;Same at the prepended check. I tried it on the merge — both alignments hold, all 30 tests still pass.
You need a merge with main anyway; can that come with it?
If you'd rather talk it through with someone, we're in Discord.
[Reviewed by Robohands]
| loadEarlierInFlightRef.current = true; | ||
|
|
||
| const resolvedContainer = container ?? document.scrollingElement; | ||
| const anchor = spacerRef.current?.nextElementSibling; |
There was a problem hiding this comment.
align="top" on main drops the spacer, so this goes null after the merge.
There was a problem hiding this comment.
Fixed in 75c0ca0. The anchor is now the first message element: after the spacer, else after the spinner while a load is pending, else after the sentinel. Same at the prepended check.
The spinner step is needed: with only the sentinel fallback, a load that fires as the previous one resolves (spinner still mounted) anchors the spinner, which unmounts and disarms the compensation. Three tests cover align="top": position held across a prepend, a late prepend, and that back-to-back case.
| * require scrollHeight > clientHeight: an underfilled list's scroller | ||
| * cannot scroll *yet*, and the auto-refill cycle must still target it. | ||
| */ | ||
| function findScrollContainer(el: Element | null): Element | null { |
There was a problem hiding this comment.
Outline has this at useScrollSpy.ts:60. Might be worth sharing rather than a second copy.
There was a problem hiding this comment.
Shared in 75c0ca0 as utils/getScrollableAncestor.ts, used by Outline and ChatMessageList. Outline keeps its scrollHeight > clientHeight requirement (the default); ChatMessageList passes requireOverflow: false, since an underfilled list's scroller cannot scroll yet and the auto-refill cycle must still target it.
Kept out of utils/index.ts, which the package entry re-exports. lab's ListInput keeps its own copy for that reason.
|
Checking in on chat scroll preservation: top-aligned lists still need a sentinel fallback anchor after merging main. Would you like to continue, have us carry it, or close this for now? |
`align="top"` (meta#3933) omits the bottom spacer, so the anchor (the spacer's next sibling) was null and a top-aligned list lost its reading position on every prepend. - Anchor on the first message element: after the spacer, else after the spinner while a load is pending, else after the sentinel. Same at the prepended check. The spinner step matters when a load fires as the previous one resolves: anchoring the spinner disarms as soon as it unmounts. - Share the scrollable-ancestor walk with Outline via utils/getScrollableAncestor (internal; utils/index is public API). Outline keeps its overflow requirement by default; ChatMessageList opts out, since an underfilled list's scroller cannot scroll yet. - Add a top-aligned variant of the Load Earlier History story. Adds 3 tests for align="top" and 7 for the helper. Refs meta#4102
|
Continuing. Merged main (
A "Load Earlier History (Top Aligned)" story now sits next to the existing one. Headless Chromium on both stories, three pages each: 0px anchor drift, 1160px compensated per page. ChatMessageList.test.tsx is at 33 tests, the helper has 7, Outline's suite is unchanged and green. |
There was a problem hiding this comment.
Thanks for finishing the load-earlier path — preserving position, single-flight loads, and support for both alignments are well covered.
One fix is needed before approval:
- After a final page loads nothing and the consumer removes
scrollToTopAction(the documented exhaustion flow), the prepend anchor inChatMessageListis never cleared. Later rerenders keep performing synchronous geometry reads on every commit, and a stale anchor could still adjustscrollTop. Please add a terminal settlement for that no-op case (without breaking late prepends while the action is still present) and extend the empty-page test to remove the action, rerender with the same first message, and verify geometry is no longer read.
Tests and Storybook could not be run in this review environment, so please include the focused test results with the fix.
[Automated review]
Resolved conflicts: - packages/core/src/Chat/ChatMessageList.tsx: file-header @input line. Kept both sides: the PR's useIsomorphicLayoutEffect/getScrollableAncestor inputs and upstream's isRenderable empty-state input (ddb63c3). - packages/core/src/Chat/ChatMessageList.test.tsx: file-header docblock and vitest import. Took upstream's docblock and imported {describe, it, expect, vi, beforeEach, afterEach}; upstream's two new tests ('renders an accepted numeric empty state', 'loads older messages through the top sentinel and exposes pending status') are kept and pass.
With the default align="bottom", an empty final page followed by the
consumer passing scrollToTopAction={undefined} left the prepend anchor
armed: the first message never changed, so no disarm condition fired.
Every later commit then forced layout (anchor + container
getBoundingClientRect), and a stale anchor could scroll the list, e.g.
by 40px when a banner was rendered above the first message.
align="top" already disarmed, because removing the sentinel leaves no
first-message element.
astracat F1: the layout effect now also disarms once the load has
settled and the action is gone. The check runs after the delta
compensation, so a final page that prepends and removes the action in
the same commit still holds position, and late prepends while the action
is present work as before.
- 'leaves the scroll untouched when the action loads nothing' now
removes the action, rerenders with the same first message and asserts
no further anchor reads, then adds a banner above it and asserts
scrollTop stays 0. Before the fix: "expected 3 to be +0" (anchor
reads) and "expected 40 to be +0" (scrollTop). After: passes.
- New guard, 'compensates a final page that also removes the action'
for align="bottom" and "top": scrollTop 37 -> 437, passing before and
after the fix.
astracat F2: ChatMessageList.test.tsx 37/37; with getScrollableAncestor,
Outline, ChatLayout and useChatStreamScroll suites 133/133.
The pre-commit hook (lint-staged: eslint --fix, prettier --write) ran on every staged file of merge 8c1559a and rewrote the formatting of 12 upstream files this PR never touches. Restore them byte-for-byte from the merge's upstream parent (82fb22c) so the PR diff against main lists only the PR's own 8 files. Committed with --no-verify because the same hook would reformat them again. Restored: apps/storybook/stories/MobileTokenizer.stories.tsx, internal/vibe-tests/stepper-collapse-naming-test/PLAN.md and docs/arm-{a-collapsed,b-bare,c-summary,d-enum,recall}.md, packages/core/src/Carousel/Carousel.test.tsx, packages/core/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts, packages/core/src/TextInput/TextInput.test.tsx, packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsx, packages/lab/src/MobileTokenizer/MobileTokenizer.tsx.
|
Thanks. Pushed up to aa7f7a1:
@cixzhang your review still shows changes requested. The sentinel fallback and shared helper went in with 75c0ca0, so could you take another look? Also, the new |
There was a problem hiding this comment.
Thanks for the careful follow-up — the remaining issue from the last review is addressed cleanly.
- The prepend anchor now disarms once a settled load leaves no
scrollToTopAction, so the documented exhaustion flow (empty final page, then passingundefined) no longer leaves geometry reads running on later commits or risks a stale scroll adjustment. Placing the disarm after the delta compensation preserves the late-prepend behaviour, and the new tests cover both sides: the empty-page case now removes the action and asserts no further anchor reads or scroll change, and a both-alignments guard proves a final page that prepends while removing the action still holds position.
No other issues were found: the public API is unchanged, both alignments and standalone scrollers are covered, and the shared scrollable-ancestor helper keeps Outline's existing behaviour. Tests and Storybook could not be run in this review environment (dependencies unavailable offline), so please let the pending checks on this head finish before merging.
[Automated review]
|
Closing as stale to reduce CI load; feel free to reopen or push a fresh branch if it's still needed. Posted by Cindy's agent on her behalf. |
Refs #4102
In one breath
Chat list. You scroll up to read older messages. The app loads more history on top. Before: the page jumped and you lost your place. Now: your spot stays put, a small spinner shows while the page loads, and older pages keep coming until the history runs out. Same API, the existing
scrollToTopActionprop now just behaves.Why
#4102 weighs two paths for long transcripts: load-earlier (Option A) vs a virtualization plugin (Option B). Option A's core affordance already shipped,
scrollToTopActionpredates the issue; but it teleported the reader on prepend (CSS scroll anchoring is suppressed atscrollTop0, exactly where the sentinel fires), went dead after one load, could double-fire, and reconnected its observer on every render. This finishes Option A with zero new props. Option B stays open and untouched.What changed
scrollTopadjustment restores it. Measured means it composes with native scroll anchoring — and backs off entirely if the reader scrolled away mid-load.align="top"has no spacer, so the anchor falls back past the spinner to the sentinel; a load that fires as the previous one resolves still anchors a message, never the spinner.aria-busywhile loading so screen readers don't announce old history as new messages.ChatLayout) compensate against their nearest scrollable ancestor, including legacyoverflow-y: overlayscrollers, viautils/getScrollableAncestor, now shared with Outline (internal; Outline keeps its overflow requirement, the list opts out because an underfilled scroller cannot scroll yet).undefinedwhen history is exhausted.How to check
align="top".ChatMessageList.test.tsx) plus 7 forgetScrollableAncestor, written red-first.align="bottom"andalign="top"; no snap-back when the reader scrolls away mid-load. Screenshots below.Notes
Full suite green; the only failures are the 13 pre-existing
packages/cliones reproducible on untouched main.