From 26615dabd81585715f8fbf84354ea6ea608e074b Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 18 May 2026 22:58:23 -0700 Subject: [PATCH] Handle refreshed thread settings in TUI --- codex-rs/tui/src/app/app_server_events.rs | 2 ++ codex-rs/tui/src/app/tests.rs | 22 ++++++++++++++++++++-- codex-rs/tui/src/app/thread_events.rs | 1 - 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/app/app_server_events.rs b/codex-rs/tui/src/app/app_server_events.rs index 5e50341f2e..3525e4f07d 100644 --- a/codex-rs/tui/src/app/app_server_events.rs +++ b/codex-rs/tui/src/app/app_server_events.rs @@ -199,6 +199,8 @@ impl App { return; } + self.file_search + .update_search_dir(notification.thread_settings.cwd.to_path_buf()); self.chat_widget .handle_server_notification(server_notification, /*replay_kind*/ None); } diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs index 7eb608fbb2..019d9295f0 100644 --- a/codex-rs/tui/src/app/tests.rs +++ b/codex-rs/tui/src/app/tests.rs @@ -5060,7 +5060,7 @@ async fn replace_chat_widget_reseeds_collab_agent_metadata_for_replay() { } #[tokio::test] -async fn refreshed_snapshot_session_persists_resumed_turns() { +async fn refreshed_snapshot_session_persists_resumed_turns_and_drops_stale_settings_update() { let mut app = make_test_app().await; let thread_id = ThreadId::new(); let initial_session = test_thread_session(thread_id, test_path_buf("/tmp/original")); @@ -5072,6 +5072,22 @@ async fn refreshed_snapshot_session_persists_resumed_turns() { Vec::new(), ), ); + let stale_settings_update = + ServerNotification::ThreadSettingsUpdated(ThreadSettingsUpdatedNotification { + thread_id: thread_id.to_string(), + thread_settings: test_thread_settings("gpt-stale", test_path_buf("/tmp/stale").abs()), + }); + { + let channel = app + .thread_event_channels + .get(&thread_id) + .expect("thread channel"); + channel + .store + .lock() + .await + .push_notification(stale_settings_update.clone()); + } let resumed_turns = vec![test_turn( "turn-1", @@ -5093,7 +5109,7 @@ async fn refreshed_snapshot_session_persists_resumed_turns() { let mut snapshot = ThreadEventSnapshot { session: Some(initial_session), turns: Vec::new(), - events: Vec::new(), + events: vec![ThreadBufferedEvent::Notification(stale_settings_update)], input_state: None, }; @@ -5120,6 +5136,8 @@ async fn refreshed_snapshot_session_persists_resumed_turns() { let store_snapshot = store.snapshot(); assert_eq!(store_snapshot.session, Some(resumed_session)); assert_eq!(store_snapshot.turns, snapshot.turns); + assert!(store_snapshot.events.is_empty()); + assert!(snapshot.events.is_empty()); } #[tokio::test] diff --git a/codex-rs/tui/src/app/thread_events.rs b/codex-rs/tui/src/app/thread_events.rs index 389a9978c3..30f68dc640 100644 --- a/codex-rs/tui/src/app/thread_events.rs +++ b/codex-rs/tui/src/app/thread_events.rs @@ -50,7 +50,6 @@ impl ThreadEventStore { ThreadBufferedEvent::Request(_) | ThreadBufferedEvent::Notification(ServerNotification::HookStarted(_)) | ThreadBufferedEvent::Notification(ServerNotification::HookCompleted(_)) - | ThreadBufferedEvent::Notification(ServerNotification::ThreadSettingsUpdated(_)) | ThreadBufferedEvent::FeedbackSubmission(_) ) }