Repository navigation
Make bb thread log truncation visible and add --all paging - #2174
Merged
Merged
Conversation
SawyerHood
marked this pull request as ready for review
August 21, 2026 07:56
bb thread log silently cut the thread in both formats. The human formats rendered only the newest 20 user-message turns and ignored the timelinePage.hasOlderRows flag the server returns, and --json printed the oldest 100 events (ORDER BY seq ASC LIMIT 100) with nothing marking the cut. A grep over either default page looked like a search over the whole thread. Human formats now end with a notice when older history was omitted and accept --limit <n> (the timeline segmentLimit, max 100). --json over-reads by one row and warns on stderr with the next --after-seq when more events exist. --all pages through every entry in either format: the timeline via olderCursor (beforeAnchorSeq/beforeAnchorId) and /events via afterSeq. No server or wire changes; the API already supported the paging. Co-Authored-By: Claude <[email protected]>
SawyerHood
force-pushed
the
bb/fix-1768-thread-log-paging
branch
from
August 21, 2026 16:40
d598b08 to
0013bae
Compare
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.
What was wrong
bb thread logcut the thread silently in both formats. The human formats (minimal,verbose) render the timeline API's default page, which is the newest 20 user-message turns, and the CLI ignored thetimelinePage.hasOlderRowsflag the server returns.--jsonreadsGET /threads/:id/events?limit=100, which lists ascending by sequence withLIMIT, so it printed the oldest 100 events and dropped the newest ones. Nothing in either output said the list was cut, and--limitwas rejected outside--json. A grep over either default page looked like a search over the whole thread. Issue: #1768. Report: https://get-bb.github.io/reports/issues/1768.htmlWhat changed
apps/cli/src/commands/thread/show.ts:timelinePage.hasOlderRowsis true:(Showing the newest N user-message turns; older history omitted. Use --limit <n> (max 100) or --all to see more.).--limit <count>now works in every format. Forminimal/verboseit maps to the timelinesegmentLimit(newest first, default 20, max 100). Forjsonit stays the event cap (oldest first, default 100).--jsonover-reads by one row and, when more events exist, prints the rows up to the limit and warns on stderr:Showing the oldest 100 events; more exist. Use --after-seq 100 for the next page or --all for the whole thread.stdout stays valid JSON.--allpages through the whole thread: timeline pages viaolderCursor(beforeAnchorSeq/beforeAnchorId, 100 segments per page, prepended oldest first) and/eventsviaafterSeqin pages of 1000.--allwith--limitis an error.--after-seqremains json-only.No server, SDK, or wire changes; the timeline and events routes already supported this paging.
HOST_DAEMON_PROTOCOL_VERSIONis untouched.Discoverable surfaces updated:
packages/templates/src/templates/bb-guide-threads.mdandapps/server/src/services/skills/builtin-skills/bb-cli/SKILL.md(tells agents to grep--all, not the default page, when checking whether a thread ever received a message).Deviation from the report's proposal: one
--limitflag per format instead of a separate--segments, and the JSON direction is documented plus warned about rather than flipped to newest-first, so existing--after-seqpaging scripts keep working.How you verified
Added 6 tests in
apps/cli/src/__tests__/command-output/thread-log.test.ts. Withshow.tschecked out fromorigin/mainall 6 fail, for example:With the fix:
Tests 14 passed (14).From the committed tree (
git status --porcelainempty):Also ran
apps/servertest/skills(6 files, 69 passed) for the SKILL.md consumers.Manual check against my own dev instance with a
seed:perfthread of 919 events / 25 user turns, running the built CLI withBB_CLIunset so it does not re-exec the installed binary:── Userblocks, ends with the older-history notice--limit 30,--all,--all --format verbose: 25 blocks, no notice;--alloutput is byte-identical to--limit 30--limit 5 --format verbose: 5 blocks plus notice;--limit 500:--limit must be at most 100 ...;--limit 0:--limit must be a positive integer.--json: 100 events seq 1-100, stderrShowing the oldest 100 events; more exist. Use --after-seq 100 ...--json --after-seq 850: 69 events seq 851-919, no warning--json --all: 919 events, seq 1-919, no duplicatesFixes #1768
Independent verification
Checked out
d598b086eon a fresh worktree (git merge-base --is-ancestor origin/main HEADtrue;mergeable: MERGEABLE).Fail-before / pass-after (
apps/cli,pnpm exec vitest run src/__tests__/command-output/thread-log.test.ts):git checkout origin/main -- apps/cli/src/commands/thread/show.ts:Tests 6 failed | 8 passed (14), e.g.AssertionError: expected '── User ────…' to contain 'newest 20 user-message turns'andexpected '' to contain '--all cannot be combined with --limit'.show.tsrestored:Tests 14 passed (14).pnpm exec turbo run typecheck test --filter=@bb/cli --filter=@bb/templates --filter=@bb/server: typecheck green for all three;@bb/cli48 test files passed,@bb/templates6 passed,@bb/server1822/1823 passed. The single server failure istest/internal/internal-skill-trees.test.ts(file mode 0644 vs 0664), a known local umask-0002 artifact unrelated to this PR; the same job passes in CI.Repro on the fixed branch (own dev instance,
seed:perf --projects 1 --threads 3 --events 3000, threadthr_rk6a3mv9zqwith 2417 events / 59 user turns, servertimelinePage.hasOlderRows: true):── Userblocks, last line(Showing the newest 20 user-message turns; older history omitted. Use --limit <n> (max 100) or --all to see more.)--limit 5 --format verbose: 5 blocks + notice;--limit 100: 40 blocks (timeline event budget) + notice;--limit 101:--limit must be at most 100 ...;--limit 0:--limit must be a positive integer.--all: 59 blocks (matches 59client/turn/requestedevents in--json --all), no notice, first prompt present (absent from the default page);--all --format verbose: 59 blocks--all --limit 5and human--after-seq 5: rejected with the expected errors--json: 100 events seq 1-100 plus stderrShowing the oldest 100 events; more exist. Use --after-seq 100 for the next page or --all for the whole thread.;--json --limit 2416: warns;--json --limit 2417: silent;--json --after-seq 2400: 17 events, silent--json --all: 2417 events, 2417 unique seqs, 1..2417;--json --all --after-seq 2400: 17 eventsCI: all required checks pass (Checks, Tests app-1/2/3, server, packages, integration, Package Smoke ubuntu/macos, version checks).
Residual risks (minor, not blocking): when the server's event budget cuts a
--limit 100page, the notice still suggests--limit <n> (max 100);qa/manual-runbook.mdpipes--format json | jq '.[-10:]'expecting the newest events and now gets the stderr warning instead of silent truncation; human--allcan hit a stale-cursor 400 on a thread written to concurrently.Rebase
Rebased onto
origin/mainatc9aef7514(was 32 commits behind, basec942421a4). No conflicts. Main touched two of the PR's files in unrelated sections:e0175eb65(HEIC/HEIF attachment note inbb-cli/SKILL.md) andb0ac28cc6(bb tasks detachnote inbb-cli/SKILL.md);show.ts,thread-log.test.ts, andbb-guide-threads.mdwere untouched on main, so the fix applies as-is. Still one commit, same message.Re-proved on the new base: with
apps/cli/src/commands/thread/show.tschecked out fromorigin/main,thread-log.test.tsgivesTests 6 failed | 8 passed (14)(same three assertions quoted above); restored,Tests 14 passed (14). From the committed tree,pnpm exec turbo run typecheck test --filter=@bb/cli --filter=@bb/templates --filter=@bb/server:Tasks: 11 successful, 12 total;@bb/cliTests 460 passed (460),@bb/templatesTests 41 passed (41),@bb/server1893 passed | 4 failed (1897). The server failures are the known umaskinternal-skill-treesartifact plus 5s timeouts intest/services/plugins/plugin-update.test.ts(git-clone tests, a different case each run, load average 67 on a 16-core box shared with other agents); neither exercises code this PR changes.Independent verification (post-rebase)
Verified head
0013bae45(rebased) in a fresh worktree. Merge base withorigin/mainis75d6fc4d4; main has since gained only85eec4da6(TestFlight CI),git merge-tree --write-tree origin/main HEADis clean.apps/cli/src/commands/thread/show.ts, the/eventsand/timelineroutes, and the SDKtimelineQuerypass-through are unchanged on main since the base, so the fix still targets the right code.Fail-before / pass-after (source files swapped to
origin/main, tests kept):git checkout origin/main -- apps/cli/src/commands/thread/show.ts apps/server/src/services/skills/builtin-skills/bb-cli/SKILL.md packages/templates/src/templates/bb-guide-threads.mdthenpnpm exec vitest run src/__tests__/command-output/thread-log.test.ts(fromapps/cli):Tests 6 failed | 8 passed (14). Failing assertions:expected '── User ────…' to contain 'newest 20 user-message turns',expected '' to contain '--all cannot be combined with --limit',expected "vi.fn()" to be called with arguments: [ { …(2) } ](segmentLimit / limit+1 query shapes).git checkout HEAD -- ...):Tests 14 passed (14).From the committed tree (
git status --porcelainempty):pnpm exec turbo run typecheck test --filter=@bb/cli --filter=@bb/templates --filter=@bb/server->Tasks: 11 successful, 12 total; typecheck green for all three; @bb/cliTests 460 passed (460), @bb/templatesTests 41 passed (41), @bb/server1 failed | 1896 passed (1897). The one server failure istest/internal/internal-skill-trees.test.ts(local umask 0664-vs-0644 artifact, unrelated, passes in CI).Live repro on my own dev instance (PR build,
BB_CLIunset so the worktree CLI ran instead of the daemon-managed binary): spawned a codex thread with--model does-not-exist-modeland queued 24 more turns, giving 25 user turns / 158 events.bb thread log <id>: 20 turns (6..25) and trailer(Showing the newest 20 user-message turns; older history omitted. Use --limit <n> (max 100) or --all to see more.)--limit 5: 5 turns + trailer;--limit 101:Error: --limit must be at most 100 ...--alland--format verbose --all: all 25 turns, oldest first, no trailer.--json: 100 events (seq 1..100) on stdout, stderrShowing the oldest 100 events; more exist. Use --after-seq 100 for the next page or --all for the whole thread.;--json --after-seq 100: 58 events starting at seq 101, no warning;--json --all: 158 events, no warning;--json --limit 158: 158 events, no warning (over-read by one works at the exact boundary).--all --limit 3and--after-seq 3(human) are rejected with the documented errors./timeline?segmentLimit=10througholderCursor->beforeAnchorSeq/beforeAnchorIdby hand: pages were turns 16-25, 6-15, 1-5 withhasOlderRowsfalse at the end; the cursor is exclusive and gap-free, so the--allloop cannot duplicate or skip a segment.CI on
0013bae45: all checks pass (Checks, Package Smoke x2, Tests app-1/2/3, integration, packages, server). PR is already in ready state;mergeable: MERGEABLE.Residual risks: the human trailer goes to stdout, so a grep for words like "omitted" over minimal output will match the notice;
--json --allfetches 1000-event pages with full event data, which is slow on very large threads but correct. No wire shape changed (CLI-only plus docs), so noHOST_DAEMON_PROTOCOL_VERSIONbump is needed.