Skip to content

Fix paginated timeline scroll and streaming stability - #894

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-pagination-scroll-behavior-thr_wfgn3izrxp
Jul 29, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-pagination-scroll-behavior-thr_wfgn3izrxp

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

  • preserve the reader’s position when older timeline rows are prepended, even when Chromium native anchoring and stale intersection state race the restore
  • keep unfinished assistant, plan, and reasoning text whole when an in-turn event-budget cutoff moves through the streaming item
  • add focused regression coverage for both scroll races and for a streaming assistant message across repeated window refreshes

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.tsx
  • pnpm 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.ts
  • pnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/app
  • pnpm exec turbo run lint --filter=@bb/server --filter=@bb/db --filter=@bb/app (0 errors; 147 pre-existing app warnings)
  • manual browser QA against the reported paginated thread

@SawyerHood
SawyerHood merged commit e89e2da into main Jul 29, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-pagination-scroll-behavior-thr_wfgn3izrxp branch July 29, 2026 23:07
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]>
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