Skip to content

Make bb thread log truncation visible and add --all paging - #2174

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-1768-thread-log-paging
Aug 21, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-1768-thread-log-paging

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

bb thread log cut 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 the timelinePage.hasOlderRows flag the server returns. --json reads GET /threads/:id/events?limit=100, which lists ascending by sequence with LIMIT, so it printed the oldest 100 events and dropped the newest ones. Nothing in either output said the list was cut, and --limit was 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.html

What changed

apps/cli/src/commands/thread/show.ts:

  • Human formats append a trailer when timelinePage.hasOlderRows is 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. For minimal/verbose it maps to the timeline segmentLimit (newest first, default 20, max 100). For json it stays the event cap (oldest first, default 100).
  • --json over-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.
  • New --all pages through the whole thread: timeline pages via olderCursor (beforeAnchorSeq/beforeAnchorId, 100 segments per page, prepended oldest first) and /events via afterSeq in pages of 1000. --all with --limit is an error.
  • --after-seq remains json-only.

No server, SDK, or wire changes; the timeline and events routes already supported this paging. HOST_DAEMON_PROTOCOL_VERSION is untouched.

Discoverable surfaces updated: packages/templates/src/templates/bb-guide-threads.md and apps/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 --limit flag 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-seq paging scripts keep working.

How you verified

Added 6 tests in apps/cli/src/__tests__/command-output/thread-log.test.ts. With show.ts checked out from origin/main all 6 fail, for example:

× bb thread log prints an older-history notice when the timeline page is cut
AssertionError: expected '── User ────…' to contain 'newest 20 user-message turns'
× bb thread log --json caps at --limit and warns on stderr when more events exist
AssertionError: expected "vi.fn()" to be called with arguments: [ { query: { limit: "4" } } ]
× bb thread log rejects --all combined with --limit
AssertionError: expected '' to contain '--all cannot be combined with --limit'

With the fix: Tests 14 passed (14).

From the committed tree (git status --porcelain empty):

pnpm exec turbo run typecheck test --filter=@bb/cli --filter=@bb/templates
 Tasks:    10 successful, 10 total
@bb/cli:test:        Tests 460 passed (460)
@bb/templates:test:  Tests 41 passed (41)

Also ran apps/server test/skills (6 files, 69 passed) for the SKILL.md consumers.

Manual check against my own dev instance with a seed:perf thread of 919 events / 25 user turns, running the built CLI with BB_CLI unset so it does not re-exec the installed binary:

  • default: 20 ── User blocks, ends with the older-history notice
  • --limit 30, --all, --all --format verbose: 25 blocks, no notice; --all output 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, stderr Showing 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 duplicates

Fixes #1768

AGENT GENERATED: by Claude Opus 5

Independent verification

Checked out d598b086e on a fresh worktree (git merge-base --is-ancestor origin/main HEAD true; mergeable: MERGEABLE).

Fail-before / pass-after (apps/cli, pnpm exec vitest run src/__tests__/command-output/thread-log.test.ts):

  • With 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' and expected '' to contain '--all cannot be combined with --limit'.
  • With the PR's show.ts restored: 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/cli 48 test files passed, @bb/templates 6 passed, @bb/server 1822/1823 passed. The single server failure is test/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, thread thr_rk6a3mv9zq with 2417 events / 59 user turns, server timelinePage.hasOlderRows: true):

  • default: 20 ── User blocks, 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 59 client/turn/requested events in --json --all), no notice, first prompt present (absent from the default page); --all --format verbose: 59 blocks
  • --all --limit 5 and human --after-seq 5: rejected with the expected errors
  • --json: 100 events seq 1-100 plus stderr Showing 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 events

CI: 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 100 page, the notice still suggests --limit <n> (max 100); qa/manual-runbook.md pipes --format json | jq '.[-10:]' expecting the newest events and now gets the stderr warning instead of silent truncation; human --all can hit a stale-cursor 400 on a thread written to concurrently.

AGENT GENERATED: by Claude Opus 5

Rebase

Rebased onto origin/main at c9aef7514 (was 32 commits behind, base c942421a4). No conflicts. Main touched two of the PR's files in unrelated sections: e0175eb65 (HEIC/HEIF attachment note in bb-cli/SKILL.md) and b0ac28cc6 (bb tasks detach note in bb-cli/SKILL.md); show.ts, thread-log.test.ts, and bb-guide-threads.md were 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.ts checked out from origin/main, thread-log.test.ts gives Tests 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/cli Tests 460 passed (460), @bb/templates Tests 41 passed (41), @bb/server 1893 passed | 4 failed (1897). The server failures are the known umask internal-skill-trees artifact plus 5s timeouts in test/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.

AGENT GENERATED: by Claude Opus 5

Independent verification (post-rebase)

Verified head 0013bae45 (rebased) in a fresh worktree. Merge base with origin/main is 75d6fc4d4; main has since gained only 85eec4da6 (TestFlight CI), git merge-tree --write-tree origin/main HEAD is clean. apps/cli/src/commands/thread/show.ts, the /events and /timeline routes, and the SDK timelineQuery pass-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.md then pnpm exec vitest run src/__tests__/command-output/thread-log.test.ts (from apps/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).
  • Restored (git checkout HEAD -- ...): Tests 14 passed (14).

From the committed tree (git status --porcelain empty): 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/cli Tests 460 passed (460), @bb/templates Tests 41 passed (41), @bb/server 1 failed | 1896 passed (1897). The one server failure is test/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_CLI unset so the worktree CLI ran instead of the daemon-managed binary): spawned a codex thread with --model does-not-exist-model and 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 ...
  • --all and --format verbose --all: all 25 turns, oldest first, no trailer.
  • --json: 100 events (seq 1..100) on stdout, stderr Showing 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 3 and --after-seq 3 (human) are rejected with the documented errors.
  • Walked /timeline?segmentLimit=10 through olderCursor -> beforeAnchorSeq/beforeAnchorId by hand: pages were turns 16-25, 6-15, 1-5 with hasOlderRows false at the end; the cursor is exclusive and gap-free, so the --all loop 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 --all fetches 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 no HOST_DAEMON_PROTOCOL_VERSION bump is needed.

AGENT GENERATED: by Claude Opus 5

@SawyerHood
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
SawyerHood force-pushed the bb/fix-1768-thread-log-paging branch from d598b08 to 0013bae Compare August 21, 2026 16:40
@SawyerHood
SawyerHood merged commit d41d1ab into main Aug 21, 2026
13 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-1768-thread-log-paging branch August 21, 2026 21:56
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.

bb thread log truncates silently: human view shows only the newest 20 segments, --json returns the oldest 100, no paging or 'more' indicator

1 participant