Skip to content

fix(app): reject stale timeline range indexes#33488

Merged
Hona merged 4 commits into
anomalyco:devfrom
Hona:fix/app-timeline-sparse-virtual-items
Jun 23, 2026
Merged

fix(app): reject stale timeline range indexes#33488
Hona merged 4 commits into
anomalyco:devfrom
Hona:fix/app-timeline-sparse-virtual-items

Conversation

@Hona

@Hona Hona commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

  • constrain the custom timeline rangeExtractor to indexes in [0, range.count)
  • prevent stale resize-pinned indexes from becoming missing TanStack virtual items after the timeline shrinks
  • reproduce the full count-shrink and new Map(...) crash path with the installed patched Solid adapter
  • give two existing live-clock queued prompt tests enough time for real HTTP, Git, and subprocess work

Deterministic root cause

Large row resizes capture visible DOM indexes in resizePinnedIndexes and retain them for two animation frames. The timeline projection can shrink before those frames expire. The custom range extractor previously merged the stale pinned indexes without validating them against the new range.count.

TanStack Virtual trusts custom range extractors. getVirtualItems() indexes directly into the current measurement array, so an out-of-range index adds undefined. The Solid adapter reconciles that value into its keyed store, leaving a sparse array. The timeline then preserves the hole through .map(...), and new Map(...) throws TypeError: Iterator value undefined is not an entry object.

The browser-condition regression uses the real adapter:

  1. Start with count 2 and pinned index 1.
  2. Shrink count to 1 while index 1 remains pinned.
  3. Assert getVirtualItems() contains only index 0.
  4. Assert the production new Map(items.map(...)) conversion does not throw.

With filterVirtualIndexes changed to return its input unchanged, this test deterministically fails at step 4 with TypeError.

The fix rejects invalid indexes at the custom range producer rather than masking missing items at the Map consumer.

CI timeout stabilization

The first CI run also exposed two unrelated packages/opencode/test/session/prompt.test.ts tests whose 3-second limits were below their observed live-clock runtimes. Both use it.instance, which runs with the live Effect clock, plus real temporary Git repositories, HTTP, and subprocess work; the shell case also executes sleep 0.2.

Using the pinned Bun 1.3.14 locally, both failed 5/5 at 3 seconds and completed cleanly at 10 seconds. Their timeout limits are raised to 10 seconds without changing test behavior.

Verification

  • bun install --frozen-lockfile
  • bun run test:virtualizer: 3 passed
  • focused timeline unit tests: 7 passed
  • pinned Bun 1.3.14 queued prompt tests: 2 passed
  • bun typecheck from packages/app
  • repository push-hook typecheck: 23 tasks passed
  • git diff --check upstream/dev...HEAD

@Hona Hona requested a review from Brendonovich as a code owner June 23, 2026 07:58
Copilot AI review requested due to automatic review settings June 23, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a TanStack Virtual edge case in the session message timeline where “resize-pinned” indexes can become stale after the timeline projection shrinks, causing getVirtualItems() to return undefined entries and crash consumers that expect the contract to hold.

Changes:

  • Introduces filterVirtualIndexes() to discard out-of-range virtualizer indexes against the current range.count.
  • Applies the filtering inside the timeline’s custom rangeExtractor to prevent invalid indexes from reaching TanStack Virtual.
  • Adds a regression test covering the stale pinned-index scenario when the row count shrinks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/app/src/pages/session/timeline/virtual-items.ts Adds a small helper to filter virtualizer indexes to [0, count).
packages/app/src/pages/session/timeline/virtual-items.test.ts Adds a regression test ensuring stale pinned indexes are removed after shrink.
packages/app/src/pages/session/timeline/message-timeline.tsx Uses the helper in rangeExtractor to prevent invalid indexes from propagating into getVirtualItems().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Hona Hona merged commit f0849a6 into anomalyco:dev Jun 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants