Skip to content

Defer settled timeline content until a row is expanded - #5240

Merged
ymichael merged 1 commit into
mainfrom
bb/reduce-thread-history-fetch-thr_x4z84cgggj
Oct 9, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/reduce-thread-history-fetch-thr_x4z84cgggj

Conversation

@ymichael

@ymichael ymichael commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Opening a thread or scrolling back through its history downloaded the full content of every settled row inline, including command and tool output, file-change diffs, reasoning text, and every delegation's child rows. Most of that content stays collapsed and is never looked at, but it set the size of each timeline and turn-summary-details response. The table of contents also fetched every assistant message preview whenever it became visible, even when only the user-message tab was open.

What changed

  • Server: deferContent=true on GET /threads/:id/timeline and /timeline/turn-summary-details (timeline-deferred-content.ts). Settled rows whose content is over 1,000 characters omit it and carry contentDeferred: true:

    • commands: empty output, and the command text is cut to its first 300 characters
    • tools: empty output
    • file changes: null diff, stdout, and stderr; diffStats is kept
    • reasoning: null detail

    Settled delegations return childRows: null. Pending rows stay inline, so streaming and auto-expand on the live frontier behave as before. Without the flag, responses are unchanged, so bb thread log and existing SDK callers see no difference.

  • Server: itemId on turn-summary-details returns just one item's rows with full content. The range is widened to the item's own lifecycle events through the new getStoredItemLifecycleSequenceRange in @bb/db. An item outside the range returns 400 invalid_request.

  • Server: role=user|assistant on conversation-outline filters the cached outline by role.

  • Contract/SDK: childRows is now nullable. The new query fields are exposed through sdk.threads.timeline, timelineTurnSummaryDetails, and conversationOutline.

  • App: every timeline and detail request sends deferContent=true. Expanding a deferred row loads its content by itemId (resolveDeferredTimelineContent in @bb/client-core) and shows a retry action if that fails. The table of contents fetches user items while it's visible, and assistant items only while the Agent messages tab is open.

  • Docs: docs/timeline-pagination.md covers deferred content, itemId, and the outline role filter.

No daemon wire change; HOST_DAEMON_PROTOCOL_VERSION is untouched. The plugin SDK surface is unchanged (check-plugin-sdk-version.mjs passes).

How you verified

  • pnpm exec turbo run typecheck lint --filter='...[origin/main]': 116/116 pass.
  • turbo run test for @bb/thread-view, @bb/client-core, @bb/server-contract, @bb/db, @bb/sdk, @bb/server, @bb/app: all pass except one app test, PluginIcon.test.tsx. It fails on a stale, untracked plugins/navigation/ build-output folder in this worktree, left over from a plugin removed on main, and is unrelated to this change.
  • New and updated tests:
    • ThreadTimelineRows.deferred-details.test.tsx: expanding a deferred row loads and renders its content, with retry on error
    • server public tests for deferred work rows, output previews, and itemId detail pages
    • timeline-cache, in-turn window, and parented pagination tests for nullable childRows
    • TOC tests for role-scoped outline fetching

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael merged commit 92dc2c1 into main Oct 9, 2026
48 checks passed
@ymichael
ymichael deleted the bb/reduce-thread-history-fetch-thr_x4z84cgggj branch October 9, 2026 03:32
ymichael added a commit that referenced this pull request Oct 9, 2026
…hat, and palette (#5264)

## Human comments

## What was wrong

One user action stepped through several different loading placeholders because every layer of a lazily loaded surface drew its own placeholder and only started its async work after the layer above it mounted. Expanding a settled edit row showed "Loading details..." (the deferred-content fetch from #5240), then the diff block chunk skeleton, then the card header with a viewport-gated skeleton, then the bb-diff chunk skeleton, then the Pierre worker pool skeleton, then a plain diff, then the highlighted diff. Opening a thread, a file preview, the diff panel, side chat, and the Cmd+K thread search had the same pattern. Some placeholders also showed wrong data while loading: the diff toolbar said "No changes", the info tab said "No thread details available.", and the side chat composer showed the provider's default model before the thread's own model.

## What changed

Timeline rows (`ThreadTimelineRows.tsx`, `timeline-row-body-preload.ts`, `ExpandableTimelineRow.tsx`, `disclosure.tsx`):
- Rows preload their body on hover (80 ms dwell), press, or focus: the deferred detail query (`prefetchThreadTimelineTurnSummaryDetails`), the renderer chunks, and the diff worker pool.
- An expanded row body shows one bordered placeholder (`TimelineRowBodyPlaceholder`, fades in after 150 ms) until its content and renderers are ready. "Loading turn details..." and "Loading subagent activity..." are unchanged.
- The worker pool gate (`ThreadDetailWorkerPoolProvider`) now waits for `pool.initialize()`; Pierre renders nothing before that.
- The timeline diff card renders without waiting for an intersection callback (`renderBeforeVisible`).
- `defineSplit` exposes `isLoaded()`; `useRequirePierreWorkerPool(required)` and `useRequestPierreWorkerPool()` added.

Thread open (`route-loading-skeleton.tsx`, `ThreadTimelineLoadingSkeleton.tsx`, `ThreadTimelineSurface.tsx`, `App.tsx`, `LazyThreadDetailView.tsx`, `ThreadDetailView.tsx`):
- Thread route skeletons include the timeline skeleton, and the timeline shows its skeleton immediately when it replaces a route skeleton instead of going blank for 200 ms.
- The info tab shows its metadata skeleton until the thread bootstrap settles.

File preview (`FilePreviewChrome.tsx`, `lazySecondaryPanelComponents.tsx`, `ThreadStorageFilePreview.tsx`):
- Chunk fallbacks and the cold panel placeholder draw the same header and source skeleton as the loading preview. Preview tab chunks preload with the panel, and opening a preview starts the source renderer chunk and code workers alongside the file request.

Diff panel (`ThreadSecondaryPanelTabContent.tsx`, `ThreadSecondaryPanel.tsx`, `GitDiffToolbar.tsx`, `GitDiffCardBody.tsx`):
- "Checking Git support…" and the file-list wait show the same skeleton cards, now shaped like the real cards. The toolbar shows a skeleton instead of "No changes" while files load. The automatic context prefetch no longer flashes "Expand context" / "Loading context…" (a user-requested expansion still shows it). The diff renderer chunk and workers start when the panel opens.

Code hosts (`DiffHost.tsx`, `SourceCodeHost.tsx`): the `fallback` prop is removed; both always show their own skeleton while the renderer chunk loads, so the plugin SDK `Diff` and `SourceCode` components show a skeleton instead of rendering nothing first.

Side chat (`ThreadChatLoading.tsx`, `LazyPluginThreadChat.tsx`, `PluginThreadChat.tsx`, `PluginPanelActions.tsx`, `EmbeddedThreadChat.tsx`):
- The chat chunk fallback and the thread wait render the leading content (the "Replying to" anchor) with the same timeline skeleton the loaded chat uses.
- Plugin panel tabs render nothing instead of "This plugin tab is not available…" until plugin frontends settle.
- The composer shows the model picker's loading state until the thread's default execution options resolve. Sending was already blocked in that window, so this only removes the wrong label.
- The timeline controller (`useThreadTimelineController.ts`) no longer puts an already-loaded empty timeline back into the loading state on background refetches; only a timeline with no data yet (first load, or the retry after a failed read from #401) reports loading. New side chats are empty, so each refetch while the thread provisioned brought the skeleton back.
- `FollowUpPromptBox` starts expanded when its editor will autofocus on mount (fine pointers), instead of mounting compact and animating open one frame later.
- Short-lived status in empty chats: the working indicator on an empty timeline (`ThreadTimelineSurface`) and the embedded composer's "Provisioning thread..." placeholder (`EmbeddedThreadChat`) appear only once that state has lasted 1.5 s (`useSustainedFlag`). A new side chat used to flash "Provisioning thread..." then "Working..." for about a second. Timelines with rows still show the working indicator immediately.

Command palette (`CommandPalette.tsx`, `ThreadSearchPalettePlaceholder.tsx`): thread search preloads, and its fallback is the real search shell instead of a bare "Loading threads" line.

No server, daemon wire, CLI, or plugin SDK source changes; `HOST_DAEMON_PROTOCOL_VERSION` is untouched.

Remaining: diffs still render plain text before syntax colours arrive (Pierre's worker flow; changing it affects every diff surface), and the diff panel shows one ~24 ms frame where only the first card has mounted.

## How you verified

- `pnpm exec turbo run typecheck lint test --filter='...[origin/main]'`: 14/14 tasks pass (`@bb/app` 5577 tests).
- New tests, each failing before the change:
  - `ThreadTimelineRows.deferred-details.test.tsx`: pressing a collapsed deferred row starts its detail request before expansion.
  - `ThreadDetailWorkerPoolProvider.test.tsx`: consumers stay waiting until the pool's highlighter has initialized.
  - `GitDiffToolbar.test.tsx`: the summary does not say "No changes" while the file list is loading.
- `useThreadTimelineController.test.tsx`: "still reports timelineLoading while refetching an empty timeline" now asserts the opposite (a loaded empty timeline stays out of the loading state while refetching); the #401 error-retry test still passes unchanged.
- `useSustainedFlag.test.tsx`: the flag turns on only after the full delay and restarts the delay each time it turns on again.
- `FollowUpPromptBox.test.tsx`: the composer starts expanded on fine pointers and compact on coarse pointers; mobile tests now use a coarse pointer.
- Updated tests for the changed placeholders: `LazyTerminalOutputBlock`, `CodeHosts.cold-load`, `DiffFileCard`, `plugin-slot-mounts`, `ThreadSecondaryPanel.collapseControl`.
- Manual, on a `pnpm start:worktree` instance with a Claude Code fixture thread: recorded painted frames with CDP screencast at 300 ms network latency before and after, and screenshotted every new loading state by holding its request open. Time until content: edit row diff 2.4 s → 1.5 s, file preview 0.70 s → 0.37 s, diff panel 2.1 s → 0.4 s; thread open, side chat, and Cmd+K go from 2–4 visually different placeholders to one.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

1 participant