Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: update file search directory when session CWD changes (#9279)

Yuvraj Angad Singh13e85b1549ae
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs
index 7ed9d0b035..7bbbb2f997 100644
--- a/codex-rs/tui/src/app.rs
+++ b/codex-rs/tui/src/app.rs
@@ -1370,10 +1370,7 @@ impl App {
self.shutdown_current_thread().await;
self.config = resume_config;
tui.set_notification_method(self.config.tui_notification_method);
- self.file_search = FileSearchManager::new(
- self.config.cwd.clone(),
- self.app_event_tx.clone(),
- );
+ self.file_search.update_search_dir(self.config.cwd.clone());
let init = self.chatwidget_init_for_forked_or_resumed_thread(
tui,
self.config.clone(),
diff --git a/codex-rs/tui/src/file_search.rs b/codex-rs/tui/src/file_search.rs
index ff55ac1274..90e2f7f149 100644
--- a/codex-rs/tui/src/file_search.rs
+++ b/codex-rs/tui/src/file_search.rs
@@ -38,6 +38,17 @@ impl FileSearchManager {
}
}
+ /// Updates the directory used for file searches.
+ /// This should be called when the session's CWD changes on resume.
+ /// Drops the current session so it will be recreated with the new directory on next query.
+ pub fn update_search_dir(&mut self, new_dir: PathBuf) {
+ self.search_dir = new_dir;
+ #[expect(clippy::unwrap_used)]
+ let mut st = self.state.lock().unwrap();
+ st.session.take();
+ st.latest_query.clear();
+ }
+
/// Call whenever the user edits the `@` token.
pub fn on_user_query(&self, query: String) {
#[expect(clippy::unwrap_used)]