mirror of
https://github.com/openai/codex.git
synced 2026-05-01 01:47:18 +00:00
Fix TUI context window display before first TokenCount (#13896)
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. --------- Co-authored-by: Charles Cunningham <ccunningham@openai.com> Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -3316,7 +3316,7 @@ impl App {
|
||||
fn handle_codex_event_now(&mut self, event: Event) {
|
||||
let needs_refresh = matches!(
|
||||
event.msg,
|
||||
EventMsg::SessionConfigured(_) | EventMsg::TokenCount(_)
|
||||
EventMsg::SessionConfigured(_) | EventMsg::TurnStarted(_) | EventMsg::TokenCount(_)
|
||||
);
|
||||
// This guard is only for intentional thread-switch shutdowns.
|
||||
// App-exit shutdowns are tracked by `pending_shutdown_exit_thread_id`
|
||||
@@ -4805,6 +4805,29 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn live_turn_started_refreshes_status_line_with_runtime_context_window() {
|
||||
let mut app = make_test_app().await;
|
||||
app.chat_widget
|
||||
.setup_status_line(vec![crate::bottom_pane::StatusLineItem::ContextWindowSize]);
|
||||
|
||||
assert_eq!(app.chat_widget.status_line_text(), None);
|
||||
|
||||
app.handle_codex_event_now(Event {
|
||||
id: "turn-started".to_string(),
|
||||
msg: EventMsg::TurnStarted(TurnStartedEvent {
|
||||
turn_id: "turn-1".to_string(),
|
||||
model_context_window: Some(950_000),
|
||||
collaboration_mode_kind: Default::default(),
|
||||
}),
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
app.chat_widget.status_line_text(),
|
||||
Some("950K window".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn open_agent_picker_keeps_missing_threads_for_replay() -> Result<()> {
|
||||
let mut app = make_test_app().await;
|
||||
|
||||
Reference in New Issue
Block a user