Skip reasoning effort animations during TUI thread replay (#63998)

## Why

Switching back to a thread restores its current settings before replaying
older updates. Those updates can trigger reasoning effort animations and
leave the status line temporarily showing an older effort level.

## What changed

Set the composer's reasoning effort baseline before refreshing it for
each replayed settings update. The status line reflects the replayed
effort immediately, and live changes still animate.

## Testing

Add a regression test that replays earlier effort changes after restoring
a thread, checks the displayed effort, and verifies that a subsequent
live change starts the animation.

GitOrigin-RevId: 3daadc7b8b5917eba1055940c67399b8ab729eda
This commit is contained in:
Felipe Coury
2026-11-25 22:44:36 +00:00
committed by copyberry
parent 03f4f4e6b7
commit fd95d89146
4 changed files with 69 additions and 15 deletions
-1
View File
@@ -106,7 +106,6 @@ use codex_app_server_protocol::SkillMetadata;
use codex_app_server_protocol::ThreadGoal as AppThreadGoal;
use codex_app_server_protocol::ThreadGoalStatus as AppThreadGoalStatus;
use codex_app_server_protocol::ThreadItemPayload;
use codex_app_server_protocol::ThreadSettings;
use codex_app_server_protocol::ThreadSettingsUpdatedNotification;
use codex_app_server_protocol::ThreadTokenUsage;
use codex_app_server_protocol::ToolRequestUserInputParams;
+1 -1
View File
@@ -99,7 +99,7 @@ impl ChatWidget {
self.on_thread_goal_cleared(notification.thread_id.as_str());
}
ServerNotification::ThreadSettingsUpdated(notification) => {
self.on_thread_settings_updated(notification);
self.apply_thread_settings(notification, replay_kind);
}
ServerNotification::TurnStarted(notification) => {
self.turn_lifecycle.has_turn_history = true;
+24 -13
View File
@@ -439,18 +439,7 @@ impl ChatWidget {
&mut self,
notification: ThreadSettingsUpdatedNotification,
) {
let Ok(thread_id) = ThreadId::from_string(&notification.thread_id) else {
tracing::warn!(
thread_id = notification.thread_id,
"ignoring app-server ThreadSettingsUpdated with invalid thread_id"
);
return;
};
if self.thread_id != Some(thread_id) {
return;
}
self.apply_thread_settings(notification.thread_settings);
self.apply_thread_settings(notification, /*replay_kind*/ None);
}
#[cfg(test)]
@@ -535,7 +524,23 @@ impl ChatWidget {
self.refresh_open_model_picker();
}
fn apply_thread_settings(&mut self, mut settings: ThreadSettings) {
pub(super) fn apply_thread_settings(
&mut self,
notification: ThreadSettingsUpdatedNotification,
replay_kind: Option<ReplayKind>,
) {
let Ok(thread_id) = ThreadId::from_string(&notification.thread_id) else {
tracing::warn!(
thread_id = notification.thread_id,
"ignoring app-server ThreadSettingsUpdated with invalid thread_id"
);
return;
};
if self.thread_id != Some(thread_id) {
return;
}
let mut settings = notification.thread_settings;
self.invalidate_permission_discovery();
if let Some(environments) = &settings.environments {
self.primary_environment_cwd =
@@ -617,6 +622,12 @@ impl ChatWidget {
self.queue_unavailable_daybreak_disable(&settings.model);
}
settings.collaboration_mode.settings.model = settings.model;
// A thread switch replays earlier effort changes after restoring the session.
// Establish each replayed tier before refreshing the composer so only live changes animate.
if replay_kind.is_some() {
self.bottom_pane
.set_active_reasoning_effort_baseline(settings.effort.as_ref());
}
settings.collaboration_mode.settings.reasoning_effort = settings.effort;
self.thread_settings_confirmed = true;
self.set_effective_collaboration_mode(settings.collaboration_mode);
@@ -845,6 +845,50 @@ async fn thread_settings_updated_updates_visible_state_without_transcript() {
assert_eq!(chat.current_model(), "gpt-5.4");
}
#[tokio::test]
async fn thread_settings_updated_during_replay_restores_effort_without_animating() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(Some("gpt-5.2")).await;
let thread_id = ThreadId::new();
chat.local_settings.tui.status_line = Some(vec!["model-with-reasoning".to_string()]);
let mut session = configured_thread_session(thread_id);
session.reasoning_effort = Some(ReasoningEffortConfig::Ultra);
chat.handle_thread_session(session);
chat.show_welcome_banner = false;
let settings = |effort| {
let mut update = thread_settings_for_test("gpt-5.2", thread_id);
update.thread_settings.collaboration_mode.mode = ModeKind::Default;
update.thread_settings.service_tier = None;
update.thread_settings.effort = Some(effort);
ServerNotification::ThreadSettingsUpdated(update)
};
crate::terminal_palette::with_test_palette(/*colors*/ None, || {
// Switching back restores the current session before replaying older settings.
let replay = Some(ReplayKind::ThreadSnapshot);
chat.handle_server_notification(settings(ReasoningEffortConfig::High), replay);
chat.handle_server_notification(settings(ReasoningEffortConfig::Max), replay);
assert!(render_bottom_popup(&chat, /*width*/ 80).contains("max"));
chat.handle_server_notification(settings(ReasoningEffortConfig::Ultra), replay);
insta::assert_snapshot!(render_bottom_popup(&chat, /*width*/ 80), @"
» Ask Codex to do anything
gpt-5.2 ultra
? for shortcuts
");
// A live change still starts by showing the outgoing Ultra status line.
chat.handle_server_notification(
settings(ReasoningEffortConfig::Max),
/*replay_kind*/ None,
);
assert_eq!(
chat.current_reasoning_effort(),
Some(ReasoningEffortConfig::Max)
);
assert!(render_bottom_popup(&chat, /*width*/ 80).contains("ultra"));
});
}
#[tokio::test]
async fn thread_settings_updated_preserves_default_settings_for_plan_mode() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(Some("gpt-5.2")).await;