Repository navigation
Fix paginated timeline scroll and streaming stability - #894
Merged
SawyerHood merged 1 commit intoJul 29, 2026
Merged
Conversation
SawyerHood
added a commit
that referenced
this pull request
Jul 30, 2026
## What changed - preserve the last assistant or error message for each human-boundary segment of a completed provider turn - keep that terminal message visible between the collapsed work summary and the following user steer - add regression coverage for accepted in-turn steers and external human new-turn boundaries ## Why Completed-turn grouping only preserved the globally final assistant message for a provider turn. When a human steer split a long provider turn into multiple visible exchanges, the preceding segment's last agent message remained inside the collapsed work summary and disappeared from the conversation flow. This restores the intended visible order: 1. user message 2. collapsed work summary 3. last agent message 4. next user message History tracing shows this behavior was introduced by `a0c5475ab` (June 23, "Split completed turn summaries at user boundaries"), not by the July timeline pagination optimizations. ## Cross-version DOM audit Three isolated builds were run against identical thread-only databases: - pre-optimization: `ec8b31a1e`, the parent of PR #882 - post-optimization/pre-fix: `afe167761`, containing PRs #882, #891, and #894 - this PR: `1f389914d` The corpus contains 19 selected threads and 45,418 events, spanning 10 to 10,207 events and including Codex/Claude threads, parent/child threads, giant completed turns, and multi-page histories. The databases contain no hosts, environments, project sources, daemon sessions, app settings, or Connect configuration. After loading every older page, canonicalized top-level timeline row DOM was exact for all 19/19 threads between the pre-optimization and post-optimization builds. Canonicalization removed only transient inline transition measurements and generated Radix IDs; row order, IDs, structure, classes, attributes, and rendered text remained strict. This PR changed 11/19 sampled threads by restoring 102 assistant rows at human boundaries. No conversation row was removed. Two now-empty collapsed summary rows disappeared because their only content became the visible assistant row; the remaining in-place text changes were collapsed-duration labels recalculated without the extracted terminal message. ## Validation - full `@bb/thread-view` test suite: 345 tests passed - `pnpm exec turbo run typecheck --filter=@bb/thread-view` - rendered the originally reported production thread from an isolated thread-only import and confirmed the corrected DOM order in the browser - cross-version DOM audit described above: 19/19 optimization comparisons exact - `git diff --check`
SawyerHood
added a commit
that referenced
this pull request
Jul 30, 2026
## The problem Since #891 bounded timeline cost within long-running turns, the tops of long streaming assistant messages were clipped — the message rendered starting mid-sentence, and the cut point kept advancing as the stream grew (observed live in a real thread whose final message streamed ~28KB across ~5,700 events in one turn). #894 added a guard meant to carry a still-streaming message's below-the-cut deltas into the owning window, but the guard keyed off `row.itemKind` on the in-window rows. The only in-window rows for a message that began below the budget floor are delta rows, and delta rows are always persisted with `item_kind = NULL` (`deriveStoredEventItemFieldsFromSource`). The guard therefore never fired in production: verified against a live database where all 9,242 `item/agentMessage/delta` rows have a NULL kind. ## The fix `ensureInTurnWindowWholeItemRows` now reads the item kind from the backfilled `item/started` lifecycle row instead of from in-window rows. The lifecycle backfill is fetched first, and the completed-item check covers backfilled rows too, so an item that completed below the cut is never treated as still streaming. ## Why CI was green The #894 regression test seeded delta rows with `itemKind: "agentMessage"` through raw `insertEvents` — a row shape the production write path can never produce. The test now seeds deltas with `itemKind: null`, and fails against the previous server code. The parented-toolCall `itemKind === "toolCall"` checks elsewhere in `timeline.ts` were audited and left alone: they run after whole-item backfill has merged in lifecycle rows, so the kind is available there. ## Testing - `pnpm exec turbo run test --filter=@bb/server -- --run` on all 7 timeline suites (33 tests pass) - rewritten regression test confirmed to fail against pre-fix `timeline.ts` - `pnpm exec turbo run typecheck --filter=@bb/server` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
amadad
pushed a commit
to amadad/bb
that referenced
this pull request
Aug 14, 2026
…#913) ## The problem Since get-bb#891 bounded timeline cost within long-running turns, the tops of long streaming assistant messages were clipped — the message rendered starting mid-sentence, and the cut point kept advancing as the stream grew (observed live in a real thread whose final message streamed ~28KB across ~5,700 events in one turn). get-bb#894 added a guard meant to carry a still-streaming message's below-the-cut deltas into the owning window, but the guard keyed off `row.itemKind` on the in-window rows. The only in-window rows for a message that began below the budget floor are delta rows, and delta rows are always persisted with `item_kind = NULL` (`deriveStoredEventItemFieldsFromSource`). The guard therefore never fired in production: verified against a live database where all 9,242 `item/agentMessage/delta` rows have a NULL kind. ## The fix `ensureInTurnWindowWholeItemRows` now reads the item kind from the backfilled `item/started` lifecycle row instead of from in-window rows. The lifecycle backfill is fetched first, and the completed-item check covers backfilled rows too, so an item that completed below the cut is never treated as still streaming. ## Why CI was green The get-bb#894 regression test seeded delta rows with `itemKind: "agentMessage"` through raw `insertEvents` — a row shape the production write path can never produce. The test now seeds deltas with `itemKind: null`, and fails against the previous server code. The parented-toolCall `itemKind === "toolCall"` checks elsewhere in `timeline.ts` were audited and left alone: they run after whole-item backfill has merged in lifecycle rows, so the kind is available there. ## Testing - `pnpm exec turbo run test --filter=@bb/server -- --run` on all 7 timeline suites (33 tests pass) - rewritten regression test confirmed to fail against pre-fix `timeline.ts` - `pnpm exec turbo run typecheck --filter=@bb/server` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
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.
Summary
Testing
pnpm exec turbo run test --filter=@bb/app -- --run src/components/thread/timeline/useAutoLoadOlderRows.test.tsx src/components/ui/bottom-anchored-scroll-body.scroll-preservation.test.tsxpnpm exec turbo run test --filter=@bb/server -- --run test/services/threads/timeline-head-state.test.ts test/services/threads/timeline-in-turn-window.test.ts test/services/threads/timeline-parented-pagination.test.ts test/services/threads/timeline-event-budget.test.ts test/services/threads/timeline-cache.test.ts test/services/threads/timeline-pagination.test.ts test/services/threads/timeline-output-truncation.test.tspnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/apppnpm exec turbo run lint --filter=@bb/server --filter=@bb/db --filter=@bb/app(0 errors; 147 pre-existing app warnings)