-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: session token breakdown in footer and /status #2152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1434,6 +1434,28 @@ async fn run_event_loop( | |
| .session | ||
| .total_conversation_tokens | ||
| .saturating_add(turn_tokens); | ||
| app.session.total_input_tokens = app | ||
| .session | ||
| .total_input_tokens | ||
| .saturating_add(usage.input_tokens); | ||
| app.session.total_output_tokens = app | ||
| .session | ||
| .total_output_tokens | ||
| .saturating_add(usage.output_tokens); | ||
| // Only accumulate cache telemetry when reported. | ||
| if let Some(hit_tokens) = usage.prompt_cache_hit_tokens { | ||
| app.session.total_cache_hit_tokens = app | ||
| .session | ||
| .total_cache_hit_tokens | ||
| .saturating_add(hit_tokens); | ||
| let cache_miss = usage | ||
| .prompt_cache_miss_tokens | ||
| .unwrap_or_else(|| usage.input_tokens.saturating_sub(hit_tokens)); | ||
| app.session.total_cache_miss_tokens = app | ||
| .session | ||
| .total_cache_miss_tokens | ||
| .saturating_add(cache_miss); | ||
| } | ||
| app.session.last_prompt_tokens = Some(usage.input_tokens); | ||
| app.session.last_completion_tokens = Some(usage.output_tokens); | ||
| app.session.last_prompt_cache_hit_tokens = usage.prompt_cache_hit_tokens; | ||
|
|
@@ -6606,6 +6628,8 @@ fn apply_loaded_session(app: &mut App, config: &Config, session: &SavedSession) | |
| app.session.last_prompt_cache_hit_tokens = None; | ||
| app.session.last_prompt_cache_miss_tokens = None; | ||
| app.session.last_reasoning_replay_tokens = None; | ||
| // Accumulated token breakdown is per-runtime-session; reset on load. | ||
| app.session.reset_token_breakdown(); | ||
| app.session.turn_cache_history.clear(); | ||
|
Comment on lines
+6631
to
6633
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| app.current_session_id = Some(session.metadata.id.clone()); | ||
| app.session_artifacts = session.artifacts.clone(); | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid duplicating the resetting of the accumulated token breakdown fields across multiple commands and UI event loops, consider adding a helper method on
SessionState.For example: