Add thread usage to TUI status surfaces (#38282)

## What changed

- Add `thread-credits` and `estimated-thread-cost` items to the configurable
  status line and terminal title for Enterprise workspaces.
- Fetch one shared thread usage estimate only when either item is selected,
  omit unavailable values, and refresh the display after turns complete.
- Preserve the last nonzero estimate while usage settles, with bounded delayed
  refreshes and retries for transient failures.

## Testing

- Add coverage for configuration, rendering, previews, plan availability,
  replay handling, retries, and post-turn settlement.

GitOrigin-RevId: dd69ee621c5bca0e5d9edd32b2bba42487eb1500
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-08-13 00:34:39 +00:00
1 parent f1a1fce26a
commit 1e71e35df6
19 files changed
+2282 -4

No files matched your search

@@ -0,0 +1,9 @@
---
source: tui/src/chatwidget/tests/status_and_layout.rs
expression: normalized_backend_snapshot(terminal.backend())
---
" "
" "
"› Ask Codex to do anything "
" "
" gpt-5.6-sol default · 5.2 credits · ~$0.21 "
@@ -0,0 +1,6 @@
---
source: tui/src/chatwidget/tests/status_surface_previews.rs
expression: snapshot
---
status line: 5.2 credits · ~$0.21
terminal title: 5.2 credits | ~$0.21
@@ -0,0 +1,20 @@
---
source: tui/src/chatwidget/tests/status_surface_previews.rs
expression: terminal_title_popup_snapshot(&mut chat)
---
Configure Terminal Title
Select which items to display in the terminal title.
Type to search
>
› [x] thread-credits Estimated current-thread credits (Enterprise workspaces only; omitte…
[x] estimated-thread-cost Estimated current-thread cost (Enterprise workspaces only; omitted w…
[ ] app-name Codex app name
[ ] project-name Project name (falls back to current directory name)
[ ] current-dir Current working directory
[ ] activity Spinner while working, action-required message while blocked.
[ ] run-state Compact session run-state text (Ready, Working, Thinking)
[ ] thread-title Current thread title, or thread identifier when unnamed
5.2 credits | ~$1.82
Press space to toggle; ←/→ to move; enter to confirm and close; esc to close