Skip to content

Conversation

@zhubert
Copy link
Owner

@zhubert zhubert commented Jan 25, 2026

Summary

Enables real-time token count updates during Claude streaming responses by adding the --include-partial-messages flag to the Claude CLI invocation and parsing the resulting stream events.

Changes

  • Add --include-partial-messages flag to all Claude CLI command argument builders (resume, fork, new session)
  • Add streamEvent struct to parse the event payload in stream_event messages
  • Implement handleStreamEventTokens() to extract and emit token counts from message_start and message_delta events
  • Add parseStreamEvent() to handle content extraction from various stream event types (text deltas, tool use, etc.)
  • Add comprehensive tests for stream event parsing

Test plan

  • Run go test ./internal/claude/... to verify the new parsing tests pass
  • Start a session and observe that token counts update incrementally during streaming (rather than only at the end)
  • Verify text streaming still works correctly with the new event parsing

@github-actions
Copy link

github-actions bot commented Jan 25, 2026

🔍 Deadcode Analysis

✅ No unreachable functions detected. Nice work keeping the codebase clean!

Enables real-time token count display during Claude responses by parsing stream_event messages. Previously token counts only appeared after responses completed; now they update continuously as tokens are generated.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@zhubert zhubert enabled auto-merge (squash) January 26, 2026 20:20
@zhubert zhubert merged commit a7fc198 into main Jan 26, 2026
2 checks passed
@zhubert zhubert deleted the no-way-token branch January 26, 2026 20:22
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