Skip to content

Fix TUI context window display before first TokenCount#13896

Merged
etraut-openai merged 5 commits intomainfrom
etraut/issue-13623
Mar 8, 2026
Merged

Fix TUI context window display before first TokenCount#13896
etraut-openai merged 5 commits intomainfrom
etraut/issue-13623

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Mar 7, 2026

The TUI was showing the raw configured model_context_window until the first
TokenCount event arrived, even though core had already emitted the effective
runtime window on TurnStarted. This made the footer, status-line context
window, and /status output briefly inconsistent for models/configs where the
effective window differs from the configured value, such as the gpt-5.4
1,000,000-token override reported in #13623.

Update the TUI to cache TurnStarted.model_context_window immediately so
pre-token-count displays use the runtime effective window, and add regression
coverage for the startup path.

@etraut-openai etraut-openai changed the title Update context window from TurnStarted event Mar 7, 2026
etraut-openai and others added 3 commits March 7, 2026 13:04
Cache the runtime context window from TurnStarted before the first TokenCount arrives so the footer, status output, and status line agree immediately.

Add app-level coverage for the live status-line refresh path and keep the TurnStarted token-state update readable with a dedicated helper.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
let needs_refresh = matches!(
event.msg,
EventMsg::SessionConfigured(_) | EventMsg::TokenCount(_)
EventMsg::SessionConfigured(_) | EventMsg::TurnStarted(_) | EventMsg::TokenCount(_)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TurnStarted is needed here because it now changes status-line source data. Before the first TokenCount, the TUI caches TurnStarted.model_context_window so the displayed context window uses the effective runtime value rather than the raw configured value. Without refreshing on TurnStarted, the live status line stays stale until a later TokenCount, which preserves the original bug. SessionConfigured and TokenCount were already refresh points for the same reason: they each change inputs consumed by refresh_status_line().

@etraut-openai etraut-openai merged commit e8d7ede into main Mar 8, 2026
31 checks passed
@etraut-openai etraut-openai deleted the etraut/issue-13623 branch March 8, 2026 00:01
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants