Skip to content

Show model reasoning as a collapsible Thinking item - #1

Merged
BunsDev merged 4 commits into
mainfrom
feat/thinking-item
Sep 25, 2026
Merged

BunsDev merged 4 commits into
mainfrom
feat/thinking-item

Conversation

@BunsDev

@BunsDev BunsDev commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Codex reasoning summaries and Claude extended thinking now stream into a collapsible Thinking item in the transcript: open while the model is thinking, folded to "Thought for Ns" once it moves on, click to expand the reasoning (Markdown).

  • Codex: item/started (reasoning) → item/reasoning/summaryTextDelta / textDelta / summaryPartAdded → item/completed (summary + content joined).
  • Claude: content_block_start (thinking) → thinking_delta → content_block_stop; a whole thinking block on the assistant message is handled when partial messages are off, without duplicating a streamed one.
  • Mock engine: thinking on a mock step streams through a new onThinking hook so --demo and e2e cover the item offline.

Tests: core 17/17, desktop 21/21 (codex + claude fake-process suites extended), e2e 2/2 (folded label, expand/collapse, content).

🤖 Generated with Claude Code

Codex reasoning summaries (item/reasoning/summaryTextDelta, textDelta,
summaryPartAdded, reasoning item completed) and Claude extended thinking
(content_block_start/thinking_delta/content_block_stop, or a whole thinking
block on the assistant message) stream into a new "thinking" thread item. The
item is open while the model is still thinking and folds to "Thought for Ns"
when it moves on; clicking toggles the reasoning text (Markdown). Deltas skip
the disk write; the final text persists with the transcript.

The offline engine gains `thinking` on mock steps (streamed via a new
onThinking hook) so the demo and e2e exercise the item without a CLI.

Tests: codex/claude fake-process suites assert the delta and completion
events (including no duplicate when the full assistant message repeats a
streamed thinking block); runner asserts the persisted item; e2e asserts the
folded label, expand/collapse, and content.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 25, 2026 09:18
BunsDev and others added 3 commits September 25, 2026 04:19
Codex reasoning summaries (item/reasoning/summaryTextDelta, textDelta,
summaryPartAdded, completed summary/content) and Claude extended thinking
(thinking content blocks with thinking_delta, or whole blocks when partial
messages are off) stream into a new `thinking` thread item. It is open with
a shimmering "Thinking…" label while the model reasons and folds to
"Thought for Ns" once it moves on; click to expand the text.

Engine: TurnSink gains thinkingDelta/thinkingDone; the mock provider/agent
carry an optional `thinking` step field so the offline demo and e2e exercise
the same path. Tests: Codex fake-server reasoning sequence, Claude
thinking block start/delta/stop without duplicating on the full message,
runner item ordering and duration, e2e expand/collapse.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The grid panes had no min-height:0 / row constraint, so a long transcript
grew the grid past the viewport and body{overflow:hidden} left nothing
scrollable. Rows are now minmax(0,1fr), panes are min-height:0 with their
own overflow, and the transcript/project list/diff scroll independently
while the composer stays pinned. e2e shrinks the window and asserts the
transcript scrolls, the document does not overflow, and the composer stays
on screen.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Backends announce a reasoning block before any text exists (Codex
item/started, Claude content_block_start). Models that keep their reasoning
private would leave an empty "Thought for 1s" row behind — observed live with
Codex on a short prompt. The runner now creates the item on the first
non-empty delta, or at completion when text arrives all at once.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues affect Thinking item identity, cleanup, and UI rendering.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Medium severity

Open (4)
What changed in this PR

Adds streamed, collapsible model reasoning items for Codex, Claude, and the mock engine.

Changes:

  • Adds reasoning callbacks and backend event handling.
  • Persists and renders expandable Thinking transcript items.
  • Adds styling, demo data, and automated coverage.
File Description
README.md Documents Thinking items.
packages/​core/​src/​types.ts Adds reasoning callback support.
packages/​core/​src/​providers/​mock.ts Streams mock reasoning.
packages/​core/​src/​agent.ts Emits reasoning events.
apps/​desktop/​test/​runner.test.ts Tests Thinking transcript behavior.
apps/​desktop/​test/​fakeproc.ts Adds reasoning test events.
apps/​desktop/​test/​codex-backend.test.ts Tests Codex reasoning streaming.
apps/​desktop/​test/​claude-backend.test.ts Tests Claude thinking streaming.
apps/​desktop/​src/​shared/​types.ts Adds the Thinking item type.
apps/​desktop/​src/​renderer/​styles.css Styles Thinking items.
apps/​desktop/​src/​renderer/​components/​ThreadView.tsx Renders collapsible reasoning.
apps/​desktop/​src/​main/​engine/​runner.ts Persists and updates Thinking items.
apps/​desktop/​src/​main/​engine/​backends/​types.ts Extends the backend sink API.
apps/​desktop/​src/​main/​engine/​backends/​mock.ts Bridges mock reasoning events.
apps/​desktop/​src/​main/​engine/​backends/​codex.ts Parses Codex reasoning events.
apps/​desktop/​src/​main/​engine/​backends/​claude.ts Parses Claude thinking events.
apps/​desktop/​e2e/​app.spec.ts Tests folding and expansion behavior.
apps/​desktop/​demo/​mock-script.json Adds demo reasoning content.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const started = new Map<string, number>();
// Extended-thinking blocks are keyed by content-block index within the current assistant message.
const thinking = new Map<number, string>();
let thinkingSeq = 0;
close: () => {},
};
let thinkingId: string | null = null;
let thinkingSeq = 0;
Comment on lines +224 to +227
thinkingDone: (id, text) => {
const existing = l.items.find((i) => i.id === id && i.kind === "thinking") as Extract<ThreadItem, { kind: "thinking" }> | undefined;
if (!existing) return;
this.patchItem(threadId, id, { text: text ?? existing.text, status: "done", durationMs: Date.now() - new Date(existing.at).getTime() });
Comment on lines +240 to +241
.thinking { margin: 0 auto 8px; }
.thinking-head { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 10px; cursor: pointer; text-align: left; color: var(--fg-2); }
@BunsDev
BunsDev merged commit 0017473 into main Sep 25, 2026
2 checks passed
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.

2 participants