Show task tokens and usage estimates in the agent command center (#44970)

## What changed

- Display input/output token counts and estimated credits and USD cost in task details. Prefer live token totals, falling back to complete totals from usage breakdowns.
- Fetch estimates for the selected task on a one-minute cadence for supported Business and Enterprise plans. Cache results, preserve prior nonzero estimates when a response reports zero, and stop fetching when the capability is unavailable.
- Clear cached usage and discard pending results on account changes, reconnects, or missed server events. Prioritize activity and usage over the original prompt when space is limited.

## Testing

Add a rendering snapshot and tests covering caching, stale results, unavailable usage, token resets, and incomplete usage breakdowns.

GitOrigin-RevId: b72c96053557389fdc723a70fab0dab841a52e49
This commit is contained in:
Eric Traut
2026-09-12 04:29:48 +00:00
committed by copyberry
parent 7efb0262d6
commit aee8a55ab6
15 changed files with 533 additions and 4 deletions
+2
View File
@@ -204,6 +204,7 @@ mod agents_overview;
mod agents_overview_actions;
mod agents_overview_details;
mod agents_overview_threads;
mod agents_overview_usage;
mod agents_overview_view;
pub(crate) use agents_overview::AGENTS_OVERVIEW_VIEW_ID;
mod app_server_event_targets;
@@ -953,6 +954,7 @@ impl App {
// Allow widgets to process any pending timers before rendering.
let had_active_view = self.chat_widget.has_active_view();
self.chat_widget.pre_draw_tick();
self.refresh_agents_overview_usage(app_server, tui.frame_requester());
let rendered_area = self.render_chat_widget_frame(tui, screen_size)?;
if !had_active_view
&& self.chat_widget.has_active_view()