fix(app): recover blank transcript from empty virtual window - #12
Draft
jpc-owner wants to merge 1 commit into
Draft
fix(app): recover blank transcript from empty virtual window#12jpc-owner wants to merge 1 commit into
jpc-owner wants to merge 1 commit into
Conversation
The message timeline virtualizer can bind its scroll element while the element still measures 0px (parent flex layout unresolved on first paint). The virtualizer then caches a 0px viewport rect and seeds its scroll offset from initialOffset (Number.MAX_SAFE_INTEGER when anchoring bottom). Neither self-heals: the cached rect only updates via the ResizeObserver rect callback, and the offset only updates on a real scroll event. For a session whose content fits the viewport the element never scrolls, so the range extractor keeps seeing a 0px viewport at a bogus offset and renders no rows — a blank transcript that only recovers once the user scrolls. Watch the scroll element size and, when it has a height but nothing is virtualized while rows exist, refresh the cached rect from the live element and reset the offset directly, then remeasure. scrollToEnd / scrollToOffset cannot correct this because they write element.scrollTop, which clamps to 0 on unscrollable content and emits no scroll event.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: |
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
The session message timeline (
MessageTimeline, TanStack Virtual) can render completely blank, indefinitely, on:0pxReproduces most on long sessions, which is why it's easy to miss on short ones.
Root cause
The virtualizer's scroll element can bind while it still measures
clientHeight === 0(parent flex layout not yet resolved). At that point the virtualizer caches a
0pxviewport rect and seeds its scroll offset from
initialOffset(
Number.MAX_SAFE_INTEGERwhen anchoring to bottom). Neither self-heals:ResizeObserverrect callback,which fires once, before rows exist, and never re-runs once the transcript populates.
scrollevent — butscrollToEnd()/scrollToOffset()writeelement.scrollTop, which clamps to0on unscrollablecontent and emits no
scrollevent.So
getVirtualItems()stays empty forever despitegetTotalSize()being non-zero:a blank transcript that only "fixes" once the user manually scrolls (which is the
only other path that updates
scrollOffset/scrollRect), and often leaves the viewmid-scroll rather than pinned to bottom afterward.
Fix
Watch the scroll element's own size with a
ResizeObserver(not the virtualizer'sinternal one) and, whenever it has a real height but zero virtual items are rendered,
refresh the virtualizer's cached rect from the live element and reset the scroll offset
directly (bottom-anchored or not), then remeasure. Purely additive — does not change
initialOffset/ existing anchoring behavior otherwise.Testing
bun testinpackages/app(timeline/message-timeline is not directly unit tested;covered by manual repro below).
0 height (e.g. via Forge UI embedding) — transcript now paints immediately instead of
requiring a scroll gesture.