feat(terminal): add context token status#10
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR implements end-to-end token usage tracking in the assistant and terminal. It adds a ChangesToken Usage Tracking
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/assistant/sse.go`:
- Around line 31-37: When handling event["response"] in the SSE accumulator,
avoid overwriting previously captured usage: instead of blindly doing
accumulator.finalResponse = response, merge any existing usage from
accumulator.finalResponse["usage"] into the new response (e.g., if oldUsage :=
accumulator.finalResponse["usage"]; oldUsage != nil { response["usage"] =
oldUsage }) before assigning; keep using
ensureSSEFinalResponse(accumulator.finalResponse) when processing event["usage"]
so later usage updates still attach correctly to accumulator.finalResponse.
In `@internal/terminal/app.go`:
- Line 143: Reset tokenUsage when clearing message or session state: find the
places that reset message/session state (the same code paths that clear current
message, session, or message-related fields) and add tokenUsage =
model.TokenUsage{} so it is zeroed alongside other resets; ensure you update
every reset path referenced in this file (including the other reset locations
around where message/session switching occurs) so stale token usage isn't
retained after ResetMessage/ResetSession flows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6b7a0c65-ff80-484a-99e4-db0c59fde6f4
📒 Files selected for processing (22)
internal/assistant/anthropic.gointernal/assistant/client.gointernal/assistant/openai_chat.gointernal/assistant/openai_responses.gointernal/assistant/runtime.gointernal/assistant/runtime_test.gointernal/assistant/sse.gointernal/assistant/tool_loop.gointernal/assistant/usage.gointernal/assistant/usage_events.gointernal/assistant/usage_test.gointernal/model/usage.gointernal/terminal/app.gointernal/terminal/async_events.gointernal/terminal/auth_commands.gointernal/terminal/input.gointernal/terminal/render_parity_test.gointernal/terminal/render_test.gointernal/terminal/runtime_buffers.gointernal/terminal/token_usage.gointernal/terminal/token_usage_export_test.gointernal/terminal/token_usage_test.go
No description provided.