Skip to content

Keep active-turn prompts visible in budgeted timelines - #1639

Draft
brsbl wants to merge 1 commit into
mainfrom
bb/debug-disappearing-user-message-thr_2xxfbvsr9r
Draft

Keep active-turn prompts visible in budgeted timelines#1639
brsbl wants to merge 1 commit into
mainfrom
bb/debug-disappearing-user-message-thr_2xxfbvsr9r

Conversation

@brsbl

@brsbl brsbl commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Keep the accepted initiating user message in every sequence-cut page of an unfinished turn.
  • Preserve the existing event-count and byte budgets for internal work rows.
  • Query the initiating accepted input directly by thread and turn, and verify duplicate pinned prompts remain stable through client pagination.

Reproduce on base

Use a scratch checkout of this PR; the commands temporarily replace only the production timeline implementation with the exact PR base while retaining the regression assertions. Do not run them in a shared working tree.

git restore --source=641380f9804bbf80d06a017b7ea9867752723719 --worktree -- \
  apps/server/src/services/threads/timeline.ts \
  packages/db/src/data/events.ts \
  packages/db/src/data/index.ts

pnpm exec turbo run test --filter=@bb/server -- \
  --run test/services/threads/timeline-in-turn-window.test.ts \
  -t 'bounds a running turn while keeping its initiating user message|keeps latest byte-page row identities stable while a turn grows'

Expected on base: the suite fails because the budgeted latest window contains newer work rows but omits the accepted initiating user conversation row. The event-count case fails at bounds a running turn while keeping its initiating user message; the byte-only case fails at keeps latest byte-page row identities stable while a turn grows.

Restore the PR implementation and rerun:

git restore --worktree -- \
  apps/server/src/services/threads/timeline.ts \
  packages/db/src/data/events.ts \
  packages/db/src/data/index.ts

pnpm exec turbo run test --filter=@bb/server -- \
  --run test/services/threads/timeline-in-turn-window.test.ts \
  -t 'bounds a running turn while keeping its initiating user message|keeps latest byte-page row identities stable while a turn grows'

Expected on this PR: both targeted tests pass. The full file passes 22/22. The active-turn prompt remains present on latest and older event-count and byte-budget pages while internal work stays bounded.

Cause and fix

When the 1,500-event budget or 4 MiB byte budget cut inside an unfinished turn, the selected event window began after client/turn/requested and turn/input/accepted. The projector therefore had newer agent work but no input pair from which to build the initiating user row. A fresh client window could not recover it.

The server now identifies the unfinished turn for either cut and adds its first accepted input plus matching client request as small context rows. Page cursors, work-row budgets, response schemas, and daemon/public protocols are unchanged. Older pages repeat the same stable prompt row, which the existing client merge contract deduplicates.

Verification

  • DB event-query coverage: 79/79 passed
  • Server timeline budget/pagination/delta coverage: 32/32 passed
  • Client timeline merge/controller coverage: 21/21 passed
  • Turbo typecheck for @bb/db, @bb/server, and @bb/app: passed
  • Real BB desktop: initiating bubble remained visible from 1,494 through 1,514 stored events across five append/reload cycles, including the first over-budget state at 1,502

BB-Thread-ID: thr_2xxfbvsr9r

AGENT GENERATED: by GPT-5.6 Codex

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