Fix TUI context window display before first TokenCount#13896
Merged
etraut-openai merged 5 commits intomainfrom Mar 8, 2026
Merged
Fix TUI context window display before first TokenCount#13896etraut-openai merged 5 commits intomainfrom
etraut-openai merged 5 commits intomainfrom
Conversation
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>
charley-oai
approved these changes
Mar 7, 2026
| let needs_refresh = matches!( | ||
| event.msg, | ||
| EventMsg::SessionConfigured(_) | EventMsg::TokenCount(_) | ||
| EventMsg::SessionConfigured(_) | EventMsg::TurnStarted(_) | EventMsg::TokenCount(_) |
Contributor
There was a problem hiding this comment.
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().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TUI was showing the raw configured
model_context_windowuntil the firstTokenCountevent arrived, even though core had already emitted the effectiveruntime window on
TurnStarted. This made the footer, status-line contextwindow, and
/statusoutput briefly inconsistent for models/configs where theeffective window differs from the configured value, such as the
gpt-5.41,000,000-token override reported in #13623.
Update the TUI to cache
TurnStarted.model_context_windowimmediately sopre-token-count displays use the runtime effective window, and add regression
coverage for the startup path.