Skip to content

Preserve reasoning summary and body after completion - #3109

Merged
ymichael merged 1 commit into
mainfrom
bb/fixer-preserve-reasoning-summary-and-body-after-thr_btttitcvfx
Sep 8, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fixer-preserve-reasoning-summary-and-body-after-thr_btttitcvfx

Conversation

@ymichael

@ymichael ymichael commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Completed reasoning has two valid persisted channels, summary and body, whose deltas can arrive interleaved. The final parser originally selected only one channel; the first version of this fix retained both but rebuilt them as all summary followed by all body, so a live S1 → B1 → S2 stream reopened as S1 → S2 → B1. This became user-visible after the completed-thinking history change.

What changed

The shared reasoning projection now keeps the arrival-order buffer and separately totals each channel. When both totals exactly match the completed item, completion preserves the live buffer; when deltas are missing or the provider corrects the final payload, the combined completed summary and body remain the fallback replacement. The same decision feeds normal and late post-interruption completion, preserving the generic Thought row, timing, status, single-channel behavior, and deterministic live/restored parity. There are no wire, database, CLI, Plugin SDK, configuration, documentation, or mobile changes.

How you verified

  • Added an assembler-valid summary S1 → body B1 → summary S2 regression that failed before the projection change and passed after it across active, just-completed, restored, and replayed projections.
  • pnpm exec turbo run test --filter=@bb/thread-view --force: 23 files and 379 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/thread-view --force passed.
  • Repeated both Turbo checks after rebasing onto current local origin/main.
  • DevBrowser at the same real route and 1440×1000 viewport showed the completed row change from S1 → S2 → B1 to the live S1 → B1 → S2 order.

Fixes #1248

AGENT GENERATED

@bb-slop-cop

bb-slop-cop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am reviewing this pull request now. I will check the change for security, code quality and architecture (including duplication), performance, and end-to-end behavior, then leave a consolidated review.

@ymichael

ymichael commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

@slopcop

@bb-slop-cop

bb-slop-cop Bot commented Sep 5, 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 end-to-end behavior, then leave one consolidated review.

@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 PR fixes an expandable AI “Thought” row losing detail when a response finishes or the page reloads. Providers can send a short reasoning summary and a separate reasoning body; the current code keeps only one, while this change keeps both.

Finding

  • Medium — a valid interleaved stream changes order at completion. Live reasoning appends summary and body updates as they arrive, but the completed event stores those channels separately and the new parser always puts all summary text before all body text. I reproduced summary S1 → body B1 → summary S2 rendering live as S1 / B1 / S2 and completed/restored as S1 / S2 / B1. The protocol grammar and shared assembler accept that sequence. I left an inline comment on the composition line with two concrete ways to make live and restored ordering share one invariant, plus the missing regression case.

Other review dimensions

  • Security: no findings. Both reasoning channels were already provider-visible during streaming, and completed details remain capped at 32,000 characters.
  • Performance: no findings. The production change adds one linear concatenation on reasoning completion, not per delta, and lifecycle buffers are still released normally.
  • Architecture and duplication: the shared reasoning parser is the correct seam and avoids provider-specific code. I found no duplicate summary/body merge elsewhere. The needed refactor is to centralize a single channel-ordering policy across live and completed projection.

Verification

  • Exact head SHA: pnpm exec turbo run test --filter=@bb/thread-view --force — 23 files, 379 tests passed.
  • Exact head SHA: pnpm exec turbo run typecheck --filter=@bb/thread-view --force — passed.
  • Real dev app with an assembler-valid dual-channel stream: both summary and body appeared in order in the completed Thought row and remained after a full reload for the non-interleaved case.
  • Focused interleaving reproduction demonstrated the ordering mismatch above.
  • Current GitHub CI is green, and later main commits do not touch the changed files.

I’m leaving this as a comment review, without approving or using GitHub’s request-changes state.

@ymichael
ymichael force-pushed the bb/fixer-preserve-reasoning-summary-and-body-after-thr_btttitcvfx branch from 5275fe6 to 43cf954 Compare September 6, 2026 05:55
@ymichael
ymichael merged commit 8db914a into main Sep 8, 2026
16 checks passed
@ymichael
ymichael deleted the bb/fixer-preserve-reasoning-summary-and-body-after-thr_btttitcvfx branch September 8, 2026 17:49
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

1 participant