mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Show estimated thread usage in /status (#38281)
## What changed - Extend `account/usage/read` with an optional `threadId` request and a backward-compatible `threadUsage` response containing estimated credits, optional USD cost, and model, reasoning, speed, and token breakdowns. - Fetch thread usage for eligible Business and Enterprise plans when `/status` is opened, then update the rendered status card asynchronously. - Preserve terminal scrollback when replacing a visible status-card tail, and append a refreshed card when the original tail can no longer be updated. ## Testing - Add app-server coverage for authentication, canonical thread IDs, unavailable billing routes, and malformed IDs. - Add TUI coverage for usage formatting, stale responses, retries, history updates, terminal reflow, and scrollback preservation. GitOrigin-RevId: 49300914b3fba917c0f08e8595363e04e5ba6d37
This commit is contained in:
1 parent
27a98dde4d
commit
f1a1fce26a
55 files changed
+2903
-60
No files matched your search
@@ -81,6 +81,7 @@ impl App {
|
||||
pub(super) fn reset_history_emission_state(&mut self) {
|
||||
self.has_emitted_history_lines = false;
|
||||
self.deferred_history_lines.clear();
|
||||
self.last_rendered_history_tail = None;
|
||||
}
|
||||
|
||||
fn display_lines_for_history_insert(
|
||||
@@ -179,6 +180,11 @@ impl App {
|
||||
retained_lines,
|
||||
self.history_line_wrap_policy(),
|
||||
);
|
||||
if self.pending_thread_usage_history_refresh
|
||||
&& let Err(err) = self.refresh_thread_usage_history_tail(tui)
|
||||
{
|
||||
tracing::warn!(error = %err, "failed to refresh thread usage after initial replay");
|
||||
}
|
||||
self.request_scrollback_history_top_up(retained_rows);
|
||||
}
|
||||
|
||||
@@ -480,6 +486,25 @@ impl App {
|
||||
self.history_line_wrap_policy(),
|
||||
);
|
||||
}
|
||||
self.last_rendered_history_tail =
|
||||
self.transcript_cells
|
||||
.last()
|
||||
.map(|cell| super::history_ui::RenderedHistoryTail {
|
||||
cell: Arc::downgrade(cell),
|
||||
lines: cell.display_hyperlink_lines_for_mode(
|
||||
width,
|
||||
self.chat_widget.history_render_mode(),
|
||||
),
|
||||
});
|
||||
if let Some(status_history) = self.last_thread_usage_status_cell.as_mut()
|
||||
&& let Some(cell) = status_history.cell.upgrade()
|
||||
{
|
||||
status_history.lines = cell
|
||||
.display_hyperlink_lines_for_mode(width, self.chat_widget.history_render_mode());
|
||||
}
|
||||
if self.pending_thread_usage_history_refresh {
|
||||
self.refresh_thread_usage_history_tail(tui)?;
|
||||
}
|
||||
self.request_scrollback_history_top_up(reflowed_rows);
|
||||
|
||||
Ok(terminal_width)
|
||||
|
||||
Reference in new issue
Block a user