Skip to content

fix(app): hydrate timeline message parents#35269

Open
Hona wants to merge 1 commit into
anomalyco:devfrom
Hona:timeline-blank-repro
Open

fix(app): hydrate timeline message parents#35269
Hona wants to merge 1 commit into
anomalyco:devfrom
Hona:timeline-blank-repro

Conversation

@Hona

@Hona Hona commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

  • keep the two-message initial page for fast tab interactions
  • hydrate missing assistant user parents through the existing single-message endpoint before publishing the page
  • retain the original history cursor so older messages continue loading after the first valid timeline paint
  • keep assistant-only event state unready while parent hydration is active
  • preserve concurrent message and part events across parent-request retries

Reproduction

The reported session had one user message followed by 14 assistant messages. The initial two-message page therefore contained only assistants. Timeline projection starts from user messages, so the virtual timeline mounted with a 0px height and zero rows until older history happened to load.

The regression fixture reproduces that exact 1+14 shape at the reported narrow viewport, holds older history pending, and exercises both completion-to-idle and idle-before-aborted-message ordering. No private transcript content is included.

Performance

Production Playwright results against the same upstream/dev commit:

Scenario Upstream Candidate
Legacy cold tab, first correct median 6.3 ms 5.9 ms
Legacy hot tab, first correct median 6.9 ms 6.9 ms
V2 closed cold, combined median 5.3 ms 5.4 ms
V2 closed hot, combined median 7.0 ms 6.6 ms
Orphan-parent cold path, first correct median 221.5 ms 133.9 ms
Orphan-parent blank samples 10-12 6-7

The common path remains neutral. The reproduced orphan path improves by 87.6 ms, about 39.5%. These are click-to-first-correct DOM observations, not standardized browser INP.

Test Plan

  • bun run test:unit from packages/app: 523 passed
  • bun run test:browser from packages/app: 26 passed
  • relevant regression E2E suite: 14 passed
  • production timeline lifecycle and transition stability: 8 passed
  • bun typecheck from packages/app
  • bun run typecheck:e2e from packages/app
  • repository pre-push typecheck: 30 packages passed
  • production session-tab benchmark, upstream and candidate
  • focused orphan-parent production benchmark, upstream and candidate

@Hona Hona requested a review from Brendonovich as a code owner July 4, 2026 02:50
Copilot AI review requested due to automatic review settings July 4, 2026 02:50
@Hona Hona added the beta label Jul 4, 2026

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 timeline rendering regression where sessions whose initial message page contains only assistant messages could mount with a blank/zero-height virtual timeline. It does this by ensuring missing user “root” parents are hydrated via the single-message endpoint before the initial page is published, while preserving the original history cursor and maintaining correct behavior under concurrent live events and retries.

Changes:

  • Add a readiness predicate (isTimelineReady) so the session view can remain “not ready” during assistant-only initial loads while parent hydration is still in progress.
  • Enhance server-side session message loading to backfill missing user parents for assistant messages (using /session/:sessionID/message/:messageID) before applying the page.
  • Expand unit + E2E coverage with regression and performance benchmarks for the orphan-parent hydration path, and extend the E2E mock server to serve single-message requests.

Reviewed changes

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

Show a summary per file
File Description
packages/app/src/pages/session/timeline/model.ts Adjusts timeline “ready” gating to account for assistant-only initial loads while history/parent hydration is active.
packages/app/src/pages/session/timeline/model.test.ts Adds unit coverage for the new timeline readiness logic.
packages/app/src/context/server-session.ts Backfills missing user parents for assistant messages during initial page loads; preserves event correctness across retries.
packages/app/src/context/server-session.test.ts Adds unit tests covering parent backfill behavior, optimistic interaction, caching boundaries, and retry/event preservation.
packages/app/e2e/utils/mock-server.ts Adds support for the single-message endpoint and flexible message delay behavior for E2E scenarios.
packages/app/e2e/regression/session-timeline-history-root.spec.ts New regression E2E covering the reproduced assistant-only initial page shape and ensuring no blank timeline during lifecycle transitions.
packages/app/e2e/performance/timeline/session-parent-hydration-benchmark.spec.ts New performance benchmark measuring click-to-first-correct DOM paint in the orphan-parent hydration path.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants