Repository navigation
Index historical file paths during timeline row matching - #7835
Merged
Merged
Conversation
The timing-ratio assertion flakes under load: 5 of 16 local runs on the fixed branch exceeded the 64x threshold. The identity regression keeps the row-matching behavior covered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 19, 2026
## Human comments ## What was wrong The timeline build in `@bb/thread-view` had no check against cost growing faster than the data. #7754 replaced an indexed lookup with a per-file scan of every row. Behavior tests passed, and the regression stayed in until #7835. Adding a growth check found two more quadratic paths in `group-event-projection-turns.ts`: - `applyExternalUserBoundaries` filtered every root user message in the thread once per turn (turns × messages). - `findRootTurnRunningAtSequence` scanned every turn once per thread-scoped warning or interaction prompt (turns × prompts). ## What changed - **New test, `packages/thread-view/test/timeline-build-growth.test.ts`.** It builds timelines for 16 thread shapes at 100 and at 400 units: files in one edit (same and reversed completion order), file changes, commands, command output deltas, assistant messages and deltas, reasoning deltas, tool calls, reads and searches, web searches, plan updates, delegations, user messages sent during a running turn, turns, and turns that each raise a thread-scoped permission prompt. - It counts work during the build: array callback, scan and copy methods, plus Array/Map/Set iteration and `Object.keys/values/entries`. - It requires 4× the input to cost less than 6× the work. Linear code measures about 4×; quadratic code about 16×. - It counts work rather than timing it, so it is deterministic and cannot flake under load. - The prototype wrappers exist only during the synchronous build and are restored in `finally`. - **`applyExternalUserBoundaries`:** sorts the boundary sequences once, then binary-searches each turn's window. The output is already ascending, so the per-turn sort is gone. - **Thread-scoped messages:** a single sweep resolves the running turn for all of them (`findRootTurnsRunningAtThreadMessages`). It walks turns sorted by start and keeps a stack that discards turns completed before the current message. - No wire, protocol, CLI, persisted-data or UI changes. ## How you verified - The new test fails on the code it guards: - `item-records.ts` from before #7835: 11.4× and 13.7×. - `group-event-projection-turns.ts` from before this PR: 6.97× for turns, 9.41× for per-turn thread-scoped prompts. - After this PR, every scenario measures 3.5–4.0×. - Real data, read-only export of 7 local threads (the four with the most turns, 1,370/798/641/720, plus the three with the most thread-scoped interaction prompts): - `JSON.stringify(buildThreadTimelineFromEvents(...))` hashes are identical before and after, for `completedTurnDisplay` collapse/expand × `includeNestedRows` true/false. - Full-build medians: | thread | turns | before | after | |---|---:|---:|---:| | `thr_cdfq9maj8q` | 1,370 | ~395 ms | ~345–357 ms | | `thr_d5ej4e2gtv` | 798 | ~357 ms | ~303–322 ms | Smaller threads show no measurable change. - `pnpm exec turbo run test typecheck lint:type-aware lint --filter=@bb/thread-view` passes. - `pnpm exec turbo run test --filter=@bb/server -- test/services/threads/timeline test/public/public-thread-timeline test/timeline-history` passes: 263 passed, 2 skipped. The skipped tests are history replays that need `BB_TIMELINE_HISTORY_DB`. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.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.
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
Timeline projection searched every accumulated file row separately for each incoming file change, including rows already claimed in the same event. This made large file-change events quadratic in their file count. The behavior reproduces on trusted main in two clean checkouts: a sixteenfold increase in file count costs about 183× as much with reversed completion order.
Reproduction and root-cause report: https://get-bb.github.io/reports/issues/7833.html
What changed
packages/thread-view; no dependency, lockfile, generated-file, persisted-data, public API, protocol, CLI, or UI changes.git diff --numstat origin/main. Production: 27 additions and 5 deletions; tests: 161 additions. No binary changes.How you verified
pnpm exec turbo run test --filter=@bb/thread-view -- test/file-change-scaling.test.ts test/build-thread-timeline.test.ts --silent=false: 86 passed.pnpm exec turbo run test typecheck lint:type-aware --filter=@bb/thread-view: 545 tests passed, typecheck and type-aware lint passed.pnpm exec turbo run test --filter=@bb/server -- test/timeline-history test/services/threads/timeline-in-turn-window.test.ts test/services/threads/timeline-event-budget.test.ts test/public/public-thread-timeline-work-rows.test.ts: 58 passed, 2 skipped. The history-replay cases requireBB_TIMELINE_HISTORY_DB, which was not supplied; no real application data was used.pnpm exec oxfmton the three changed files andgit diff --checkpass.Fixes #7833