Summary
Display token usage and compaction proximity in the chat UI. Users should be able to see how much context has been used and when compaction is approaching, similar to how Claude Code CLI shows context usage.
Motivation
This helps users understand:
- How much of the context window has been consumed
- When automatic compaction/summarization might occur
- Cost estimation based on token usage
Acceptance Criteria
Technical Details
Data Source
The Agent SDK returns usage information in the result message:
result.usage.inputTokens
result.usage.outputTokens
result.costUsd
The Conversation type already tracks metadata.totalTokens and metadata.totalCostUsd.
UI Location Options
- Header bar - Compact display next to conversation title
- Footer/status bar - Below the input area
- Collapsible panel - Expandable stats section
Visual Design
- Progress bar showing context usage percentage
- Color coding: green (<50%), yellow (50-80%), red (>80%)
- Tooltip with detailed breakdown
- Optional: cost estimate display
Implementation Approach
- Add token tracking to
AgentController.ts (accumulate per-turn usage)
- Add UI component
ContextStats.ts or integrate into ChatView.ts
- Add CSS for progress bar and status indicators
- Subscribe to streaming events to update in real-time
Priority
P2 - Medium priority feature enhancement
Summary
Display token usage and compaction proximity in the chat UI. Users should be able to see how much context has been used and when compaction is approaching, similar to how Claude Code CLI shows context usage.
Motivation
This helps users understand:
Acceptance Criteria
Technical Details
Data Source
The Agent SDK returns usage information in the result message:
result.usage.inputTokensresult.usage.outputTokensresult.costUsdThe
Conversationtype already tracksmetadata.totalTokensandmetadata.totalCostUsd.UI Location Options
Visual Design
Implementation Approach
AgentController.ts(accumulate per-turn usage)ContextStats.tsor integrate intoChatView.tsPriority
P2 - Medium priority feature enhancement