Skip to content

feat: streaming token output with Print Mode rendering#30

Open
Travelguest wants to merge 3 commits intoMagicCube:mainfrom
Travelguest:feat/streaming-token-print-mode
Open

feat: streaming token output with Print Mode rendering#30
Travelguest wants to merge 3 commits intoMagicCube:mainfrom
Travelguest:feat/streaming-token-print-mode

Conversation

@Travelguest
Copy link
Copy Markdown
Contributor

@Travelguest Travelguest commented Apr 12, 2026

Description:
Adds real-time streaming token output to the TUI, replacing the generic "Thinking..." shimmer with actual model text as it arrives.

Changes:
Extend AgentProgressThinkingEvent with text (accumulated) and delta (incremental) fields
Update Agent._deriveProgress() to extract text from streaming snapshots and compute deltas
Add StreamingMessage component for real-time Markdown rendering of streaming tokens
Update use-agent-loop to consume progress events and maintain streamingText state
Update App.tsx to show StreamingMessage while text is streaming, replacing the shimmer indicator
Fix top_p: 0 → 0.1 for DeepSeek API compatibility (top_p must be in (0, 1.0])
Add 3 unit tests covering thinking events (text + delta), final message, and tool progress

- Extend AgentProgressThinkingEvent with `text` (accumulated) and `delta`
  (incremental) fields so consumers can render tokens in real time.
- Update Agent._deriveProgress() to extract text from streaming snapshots
  and compute delta between consecutive progress events.
- Add StreamingMessage component for Ink-mode real-time Markdown rendering
  of streaming text tokens.
- Update use-agent-loop to consume progress events:
  - Ink Mode: update streamingText React state for re-rendering
  - Print Mode: write delta directly to stdout for instant output
- Update App.tsx to show StreamingMessage while text is streaming,
  replacing the generic shimmer indicator.
- Add AgentLoopProvider `printMode` prop to toggle between modes.
- Add 3 unit tests for streaming progress events (thinking text+delta,
  final message, tool progress without text fields).
DeepSeek's OpenAI-compatible API rejects top_p=0 with:
  'Invalid top_p value, the valid range of top_p is (0, 1.0]'

top_p=0.1 is the closest valid value that preserves near-deterministic
behavior while satisfying the API constraint.
Print Mode (direct stdout.write) conflicts with Ink's terminal control
and provides no real benefit over Ink Mode's real-time Markdown rendering.
A proper non-interactive mode (like Claude Code's -p flag) would bypass
Ink entirely rather than mixing stdout.write within the React tree.

Removed: printMode prop, stdout.write branches, printMode state.
@Travelguest Travelguest force-pushed the feat/streaming-token-print-mode branch from 38d49ef to 57dceec Compare April 12, 2026 04:44
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