feat(chat): surface streamed model thinking in the dashboard (#1907) #1910

Merged
sam merged 3 commits from feat/1907-chat-thinking into main 2026-11-12 13:25:51 +00:00
Owner

Surfaces the model's reasoning end to end while a turn streams.

Gateway:

  • The ai-sdk FullStream drain moves from the archiegateway composition into internal/gateway as DrainStreamParts, next to the TurnStream it feeds.
  • New reasoning-delta case: each ReasoningDelta is forwarded on the new optional ReasoningStream method; localChatStream.Reasoning emits ChatEvent{Kind: "reasoning", Text: delta} on the same stream. toolCallRecorder forwards it through. done/error semantics unchanged; the FullStream is still drained to close when no stream is attached.
  • The webui SSE handler already forwards any event kind with text through its default branch, so internal/webui needed no change (verified by reading the switch in handleChatStream).

UI:

  • state.ts accumulates reasoning frames into streamingTurn.reasoning alongside delta.
  • The live row renders the thinking in a collapsible "Thinking" trace (ChatThinking.vue, built from components/ui trace/collapsible like AgentTranscript), with a spinning icon and shimmering title while no reasoning text has arrived yet; a turn with no reasoning renders nothing, and reasoning never leaks into the reply text.

Tests:

  • internal/gateway/chat_stream_test.go: table-driven fake SDK stream (reasoning deltas -> Kind "reasoning" ChatEvents, text deltas still stream, tool results still report, nil stream still drains). Failed before the fix (undefined DrainStreamParts), passes after.
  • ui/test/chat-thinking.test.ts: drives the real sendMessage frame handling over a stubbed SSE stream; fails on the pre-fix state.ts (reasoning not accumulated), passes after.

Verified: go test -short ./internal/gateway/... ./internal/app/archiegateway/... ./internal/domain/messaging/..., pnpm test (105 pass), pnpm run typecheck, pnpm run build, task check (all on this exact tree). No live browser check: running the full stack needs a configured model provider, which this environment does not have; the SSE frame shape was verified against internal/webui/chat.go's default branch and the UI frame handling is covered by the node test.

Note: internal/app/archiegateway/chat_setup.go is outside the listed ownership, but the SDK stream is only read there; the change is a pure move of the drain into internal/gateway plus one call site, which is what lets the gateway own (and test) the reasoning forwarding.

Surfaces the model's reasoning end to end while a turn streams. Gateway: - The ai-sdk FullStream drain moves from the archiegateway composition into internal/gateway as `DrainStreamParts`, next to the TurnStream it feeds. - New `reasoning-delta` case: each ReasoningDelta is forwarded on the new optional `ReasoningStream` method; `localChatStream.Reasoning` emits `ChatEvent{Kind: "reasoning", Text: delta}` on the same stream. `toolCallRecorder` forwards it through. done/error semantics unchanged; the FullStream is still drained to close when no stream is attached. - The webui SSE handler already forwards any event kind with text through its default branch, so `internal/webui` needed no change (verified by reading the switch in handleChatStream). UI: - `state.ts` accumulates `reasoning` frames into `streamingTurn.reasoning` alongside `delta`. - The live row renders the thinking in a collapsible "Thinking" trace (`ChatThinking.vue`, built from components/ui trace/collapsible like AgentTranscript), with a spinning icon and shimmering title while no reasoning text has arrived yet; a turn with no reasoning renders nothing, and reasoning never leaks into the reply text. Tests: - `internal/gateway/chat_stream_test.go`: table-driven fake SDK stream (reasoning deltas -> Kind "reasoning" ChatEvents, text deltas still stream, tool results still report, nil stream still drains). Failed before the fix (undefined DrainStreamParts), passes after. - `ui/test/chat-thinking.test.ts`: drives the real `sendMessage` frame handling over a stubbed SSE stream; fails on the pre-fix state.ts (reasoning not accumulated), passes after. Verified: `go test -short ./internal/gateway/... ./internal/app/archiegateway/... ./internal/domain/messaging/...`, `pnpm test` (105 pass), `pnpm run typecheck`, `pnpm run build`, `task check` (all on this exact tree). No live browser check: running the full stack needs a configured model provider, which this environment does not have; the SSE frame shape was verified against internal/webui/chat.go's default branch and the UI frame handling is covered by the node test. Note: internal/app/archiegateway/chat_setup.go is outside the listed ownership, but the SDK stream is only read there; the change is a pure move of the drain into internal/gateway plus one call site, which is what lets the gateway own (and test) the reasoning forwarding.
sam added 2 commits 2026-11-12 13:23:58 +00:00
The ai-sdk FullStream drain moves from the archiegateway composition into
internal/gateway (DrainStreamParts), next to the TurnStream it feeds, and
gains a StreamPartReasoningDelta case: each reasoning delta is forwarded on
the new optional ReasoningStream method, which localChatStream turns into a
ChatEvent{Kind: "reasoning", Text: delta} on the same stream. done/error
semantics are unchanged, and the FullStream is still drained to close when no
stream is attached.
feat(chat): render the live turn's thinking in the dashboard (#1907)
Quality / check (pull_request) Canceled after 0s
ci/woodpecker/pr/quality Pipeline was successful
433ea390a6
Reasoning frames accumulate into streamingTurn.reasoning and the live row
shows them in a collapsible Thinking trace built from the components/ui
trace pattern, with a spinning icon and shimmering title while no reasoning
has arrived yet. A turn that produces no reasoning renders no trace, and
reasoning never leaks into the reply text.
sam added 1 commit 2026-11-12 13:24:25 +00:00
Merge branch 'main' into feat/1907-chat-thinking
Quality / check (pull_request) Successful in 12m49s
607bfddd0e
sam merged commit 5b282c9efe into main 2026-11-12 13:25:51 +00:00
sam deleted branch feat/1907-chat-thinking 2026-11-12 13:25:51 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1910