Skip to content

fix: stabilize messages timeline virtualization#1664

Merged
juliusmarminge merged 11 commits intomainfrom
t3code/file-changed-virtualization-bug
Apr 2, 2026
Merged

fix: stabilize messages timeline virtualization#1664
juliusmarminge merged 11 commits intomainfrom
t3code/file-changed-virtualization-bug

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 1, 2026

Summary

  • Extracted timeline row derivation and row-height estimation into shared logic so the virtualizer uses the same row model as the renderer.
  • Improved changed-files height estimation by accounting for nested tree content, and surfaced virtual row metadata for debugging and verification.
  • Fixed ChangedFilesTree to respect the initial collapse state on first render and preserve expansion state across updates.
  • Added regression coverage for the collapsed directory rendering path and a browser harness that checks virtualization estimates against rendered heights.

Testing

  • Not run (PR description only).
  • Added ChangedFilesTree unit coverage for the initial collapse-state behavior.
  • Added Vitest browser coverage for timeline virtualization estimate mismatches and changed-files collapse/virtualizer synchronization.

Note

Medium Risk
Touches chat timeline virtualization and row-height estimation; mistakes could cause scroll-jank, incorrect cached heights, or missing content during expand/collapse, though changes are UI-only with no auth/data risk.

Overview
Stabilizes chat timeline virtualization by extracting a shared row model + height estimator (deriveMessagesTimelineRows, estimateMessagesTimelineRowHeight) and using it for virtualizer sizing, including work-group expansion state and changed-files card height.

Prevents stale virtualizer measurements on resize by scoping react-virtual item keys to the current timeline width, and adds optional onVirtualizerSnapshot plus extra data-* attributes to aid debugging/verification.

Fixes ChangedFilesTree initial expand/collapse behavior by replacing effect-driven directory expansion state with an override map keyed by expand-mode + directory set, and adds unit + browser harness tests to catch estimate/measurement drift and ensure collapse/expand keeps the virtualizer in sync.

Written by Cursor Bugbot for commit 32ef605. This will update automatically on new commits. Configure here.

Note

Stabilize messages timeline virtualization with improved row height estimation

  • Extracts timeline row derivation and height estimation into MessagesTimeline.logic.ts, grouping contiguous work log entries and handling proposed-plan, message, and working row kinds
  • Scopes virtualizer item keys by rounded timeline width to prevent stale measurement reuse on resize
  • Improves estimateMessagesTimelineRowHeight to account for changed-files cards, work group expansion/overflow, proposed-plan markdown length, and distinct assistant vs. user line heights
  • Reworks ChangedFilesTree expansion state to use a keyed { key, overrides } object instead of useEffect sync, so directories default to expanded/collapsed based solely on allDirectoriesExpanded
  • Adds an optional onVirtualizerSnapshot prop to MessagesTimeline for observing virtualizer measurements, plus a browser-based test suite validating height estimates against real renders

Macroscope summarized 32ef605.

juliusmarminge and others added 3 commits April 1, 2026 10:32
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Apr 1, 2026
macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 1, 2026

Approvability

Verdict: Approved

This is a self-contained bug fix for timeline virtualization, extracting height estimation logic, improving accuracy of estimates, and adding proper cache invalidation on width changes. The changes include comprehensive browser tests and are limited to UI behavior without touching sensitive areas.

You can customize Macroscope's approvability policy. Learn more.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1e853984-e485-4e6b-b4e4-04443468ee70

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/file-changed-virtualization-bug

Comment @coderabbitai help to get the list of available commands and usage tips.

- Add varied changed-files virtualization scenarios
- Expand tree tests for compacted prefixes and mixed roots
@macroscopeapp macroscopeapp bot dismissed their stale review April 1, 2026 17:46

Dismissing prior approval to re-evaluate 77d811d

- Covers compacted directories and root files when expand-all is active
macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 1, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp bot dismissed their stale review April 1, 2026 17:54

Dismissing prior approval to re-evaluate a370398

macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 1, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp bot dismissed their stale review April 1, 2026 21:14

Dismissing prior approval to re-evaluate fe1ce1e

macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 1, 2026
juliusmarminge and others added 3 commits April 1, 2026 16:19
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp bot dismissed their stale review April 2, 2026 01:57

Dismissing prior approval to re-evaluate 135bf5e

macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 2, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp bot dismissed their stale review April 2, 2026 07:00

Dismissing prior approval to re-evaluate 32ef605

@juliusmarminge juliusmarminge merged commit 867cf4c into main Apr 2, 2026
12 checks passed
@juliusmarminge juliusmarminge deleted the t3code/file-changed-virtualization-bug branch April 2, 2026 07:10
gigq pushed a commit to gigq/t3code that referenced this pull request Apr 6, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
Chrono-byte pushed a commit to Chrono-byte/t3code that referenced this pull request Apr 7, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant