Skip to content

Show completed thinking in thread history - #3066

Merged
SawyerHood merged 4 commits into
get-bb:mainfrom
IlyaM:bb/implement-small-show-thinking-patch-thr_cf9ffny2pq
Sep 4, 2026
Merged

SawyerHood merged 4 commits into
get-bb:mainfrom
IlyaM:bb/implement-small-show-thinking-patch-thr_cf9ffny2pq

Conversation

@IlyaM

@IlyaM IlyaM commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

#1248 requests expandable
Thought for <duration> sections while retaining the existing streaming
thinking presentation.

bb already displayed provider-visible reasoning through the active
Thinking… disclosure, but discarded that text from the timeline projection
when the reasoning lifecycle completed. Completed threads therefore retained
the surrounding work and assistant response, but not the reasoning shown while
the turn was running.

What changed

Completed, non-empty reasoning lifecycles now produce expandable
Thought for <duration> entries in thread history through the existing generic
system-operation timeline machinery.

  • Titles use persisted lifecycle timestamps and the existing compact duration
    formatter.
  • Expandable details contain only reasoning text exposed by the provider.
  • Entries retain their event range, turn scope, effective parent scope, and
    completed or interrupted status.
  • Turn completion and thread interruption finalize reasoning that did not
    receive an explicit completion event.
  • Finalized lifecycle keys reject late streaming deltas and duplicate completions.
  • When a provider completes reasoning after Stop, its final text and event range
    update the saved thought while preserving its interrupted status and stop time.
  • Completed reasoning details are capped at 32,000 characters.
  • Active reasoning remains in the existing Thinking… disclosure.

Completed thoughts can appear inside the existing Worked for… disclosure.
No new public timeline-row kind or reasoning-specific UI component was added.

There are no database, persisted-event, server/host-daemon wire, CLI,
Plugin SDK, configuration, or documentation contract changes.
HOST_DAEMON_PROTOCOL_VERSION remains unchanged.

How you verified

  • Added focused coverage for explicit completion, final-text replacement,
    persisted lifecycle start times, interrupted reasoning, turn-finalization
    fallback, nested/root lifecycle isolation, late-delta rejection, completed
    CLI rendering, and deterministic replay.
  • Replayed provider reasoning events through the timeline projection and
    confirmed that active reasoning appears only through Thinking…, completed
    reasoning appears once as Thought for <duration>, and completed entries
    survive rebuilding the idle timeline.
  • Verified the behavior in the isolated development app with Claude Code and
    Pi sessions.
  • @bb/thread-view: 377 tests passed; server timeline integration tests: 54
    passed; provider parity: 56 passed. Server and thread-view typechecks passed.
  • The Stop → late provider completion regression fails on the original code and
    passes with the fix. Doobie verified the saved interrupted thought expands
    after reload in the development app.
  • Formatting and git diff --check passed.

Fixes #1248

AGENT GENERATED

Render completed, non-empty reasoning as expandable `Thought for <duration>` entries through the existing generic operation timeline row. Preserve persisted timing, event ordering, turn and parent scope, and completed or interrupted status.

Keep active reasoning in the existing `Thinking…` disclosure, and reject late deltas after finalization so one reasoning lifecycle produces at most one completed entry.

Refs get-bb#1248
@SawyerHood

Copy link
Copy Markdown
Collaborator

@slopcop review

@bb-slop-cop

bb-slop-cop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I’m reviewing this pull request now. I’ll check security, code quality and architecture (including duplication), performance, and the user-facing behavior before posting a consolidated review.

acp-cursor/resume rows 2->4, acp-cursor/stop-interrupt rows 3->5.
Events unchanged; the show-completed-thinking change retains
completed reasoning as operation rows.
@SawyerHood

Copy link
Copy Markdown
Collaborator

CI diagnosis for the Tests (packages) failure (run 33884534351):

@bb/provider-parity → assembles every cell to its pinned counts fails with:

  • acp-cursor/resume: 21 events/4 rows, pinned 21/2
  • acp-cursor/stop-interrupt: 39 events/5 rows, pinned 39/3

Root cause: this PR intentionally retains completed reasoning as timeline operation rows (Thought for …), which adds 2 rows to each of those recorded parity cells. Events/unhandled/grammarDrops are unchanged — only the pinned row counts are stale.

Fix: I regenerated packages/provider-bridge-protocol/recordings/row-counts.json with UPDATE_PARITY_ROW_COUNTS=1 and verified the test passes (the regeneration touches only those 2 lines). I don't have push access to the fork, so I opened IlyaM#1 from get-bb/bb@bb/pr-3066-parity-row-counts — merging it should turn CI green.

AGENT GENERATED

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary: this change keeps provider-visible thinking after a response finishes. It adds an expandable Thought for <duration> entry inside the existing Worked for… history row, while leaving in-progress thinking in the current live disclosure.

I found two behavior issues and one required fixture update:

  1. A turn that ends with status: "failed" labels its unfinished reasoning as completed. I reproduced this on the exact PR head: the parent turn came back as error, but its child Thought for 4s row came back as completed. That should be interrupted/error-aligned rather than successful.
  2. Completed reasoning is copied into a generic system-row detail, so it bypasses the timeline's existing 32,000-character truncation and 4,000-character preview paths for work output. I inserted a valid 50,000-character reasoning completion and the turn-summary-details API returned all 50,000 characters. This needs a bounded preview/lazy-detail path or equivalent truncation for reasoning details.
  3. The full package gate is currently red because the intended new rows changed two provider-parity counts without updating the pins: acp-cursor/resume is now 4 rows (pinned 2), and acp-cursor/stop-interrupt is now 5 rows (pinned 3). I reproduced the same @bb/provider-parity failure locally; packages/provider-bridge-protocol/recordings/row-counts.json needs the intentional count updates.

Security review found no HTML/Markdown injection path: the reasoning remains text-rendered, and the PR does not newly persist provider data. It does intentionally make interrupted, unfinished reasoning durable history; that matches the PR description, but it is worth confirming as product policy because it broadens how long transient reasoning is exposed.

Architecture/duplication scan: reusing the generic operation renderer avoids a duplicate UI component, and I did not find a stale parallel reasoning implementation. The tradeoff is that generic system rows do not participate in work-output limits; a semantic reasoning discriminator or a shared bounded-detail policy would close that gap cleanly.

Verification on 652619a01557499c5697f18f8e4f329147fd31ef:

  • @bb/thread-view typecheck passed.
  • All 374 @bb/thread-view tests passed.
  • @bb/provider-parity failed with the two stale row-count pins above, matching GitHub CI.
  • Exact-head dev server + Doobie passed the user path: expand Worked for 5s → see Thought for 3s → expand it → see the completed reasoning detail.

I’m leaving this as a comment review, per policy—not approving or requesting changes.

- Finalize open reasoning lifecycles as interrupted when their turn
  ends failed, not completed.
- Cap completed reasoning detail at 32k chars with a truncation
  marker so reasoning rows share the inline-output budget instead
  of bypassing the timeline truncation paths.
@SawyerHood

Copy link
Copy Markdown
Collaborator

Update: all three CI/SlopCop items are now fixed directly on this branch (pushed 652619a → 3d6c3af, fresh CI triggered):

  1. Parity pins — row-counts.json: acp-cursor/resume rows 2→4, acp-cursor/stop-interrupt rows 3→5 (regenerated with UPDATE_PARITY_ROW_COUNTS=1, verified green).
  2. Failed-turn reasoning status (SlopCop 1) — onTurnCompleted in packages/thread-view/src/event-projection-state.ts now finalizes open reasoning as interrupted for any non-completed turn status, so a failed turn no longer labels unfinished thinking completed. Added test: finalizes streamed reasoning as interrupted when its turn fails.
  3. Unbounded reasoning detail (SlopCop 2) — completed reasoning detail is now capped at 32k chars with a …[N more characters truncated] marker in finalizeReasoningLifecycleByKey (packages/thread-view/src/reasoning-lifecycle-projection.ts), sharing the inline-output budget instead of bypassing the timeline truncation paths. This covers both the timeline list and turn-summary-details APIs since both project from events. Added test: truncates very long completed reasoning detail.

Verified: full @bb/thread-view suite 376/376 pass, typecheck passes, parity assembles every cell to its pinned counts passes.

Note: I opened IlyaM#1 earlier as a workaround before realizing maintainer push works — it's now closed as superseded.

AGENT GENERATED

@SawyerHood
SawyerHood merged commit 6e83eb2 into get-bb:main Sep 4, 2026
14 checks passed
ymichael added a commit that referenced this pull request Sep 8, 2026
## Human comments

## What was wrong

The shared timeline window closure treated every scoped item that
crossed a page boundary as belonging to the newer sequence window. For a
completed thinking item whose start was in an older user turn but whose
completion arrived after the next prompt began, standard turn pagination
therefore separated the lifecycle: the newest page rendered the
completion beneath the wrong prompt as “Thought for 0ms,” and loading
the older page left the originating turn without its thought. This
followed
[6e83eb2](6e83eb2)
from #3066.

A thought that never receives `item/completed` could also disappear from
both pages when its original turn moved into older history.

## What changed

- Expose the completion sequence in the existing item-span query.
- Give the shared whole-item closure explicit origin-versus-later page
ownership.
- Keep an unfinished thought on its origin page until it receives a
newer-page event; then keep the active lifecycle on the newer page
without duplication.
- Assign completed items to their originating user segment while
preserving existing later-page ownership for byte and details windows.
- Constrain span lookups to item events and distribute their thread/type
constraints into each scoped lookup, allowing SQLite to use the existing
`(thread_id, turn_id, type, item_id, sequence)` index.
- Guard that multi-turn query plan and the unfinished and late-completed
latest/older/details behavior with focused regressions.

There are no database schema or migration, host-daemon wire, CLI,
documentation, UI-component, pagination-limit, or mobile changes.

## How you verified

- The focused regression fails before the fixes: late completion appears
on the newest page, while a never-completed thought disappears from both
pages.
- `pnpm exec turbo run test --filter=@bb/server --
test/services/threads/timeline-in-turn-window.test.ts` — 28/28 passed
after rebasing onto current local `origin/main`.
- `pnpm exec turbo run test --filter=@bb/db` — 448/448 passed.
- `pnpm exec turbo run typecheck --filter=@bb/server` and `pnpm exec
turbo run typecheck --filter=@bb/db` — passed.
- The committed multi-turn `EXPLAIN QUERY PLAN` regression proves the
span lookup uses `events_thread_turn_type_item_sequence_idx`; no new
index is created.
- DevBrowser verified the real app history boundary: after loading the
older page, the original turn expands through “Worked for 5s” to the
interrupted “Thought for 2s,” its text, and “Stopped manually,” with no
thought under the next prompt.

> AGENT GENERATED
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.

Feature Request: Show Thinking

2 participants