diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 06bf1bc8..54c48047 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -1,3 +1,4 @@ +use std::path::PathBuf; use std::sync::mpsc::SendError; use std::sync::mpsc::Sender; use std::sync::Arc; @@ -34,7 +35,6 @@ pub(crate) struct ChatWidget<'a> { bottom_pane: BottomPane<'a>, input_focus: InputFocus, config: Config, - cwd: std::path::PathBuf, } #[derive(Clone, Copy, Eq, PartialEq)] @@ -48,15 +48,10 @@ impl ChatWidget<'_> { config: Config, app_event_tx: Sender, initial_prompt: Option, - initial_images: Vec, + initial_images: Vec, ) -> Self { let (codex_op_tx, mut codex_op_rx) = unbounded_channel::(); - // Determine the current working directory up‑front so we can display - // it alongside the Session information when the session is - // initialised. - let cwd = std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")); - let app_event_tx_clone = app_event_tx.clone(); // Create the Codex asynchronously so the UI loads as quickly as possible. let config_for_agent_loop = config.clone(); @@ -105,7 +100,6 @@ impl ChatWidget<'_> { }), input_focus: InputFocus::BottomPane, config, - cwd: cwd.clone(), }; let _ = chat_widget.submit_welcome_message(); @@ -193,7 +187,7 @@ impl ChatWidget<'_> { fn submit_user_message_with_images( &mut self, text: String, - image_paths: Vec, + image_paths: Vec, ) -> std::result::Result<(), SendError> { let mut items: Vec = Vec::new(); @@ -233,7 +227,7 @@ impl ChatWidget<'_> { EventMsg::SessionConfigured { model } => { // Record session information at the top of the conversation. self.conversation_history - .add_session_info(&self.config, model, self.cwd.clone()); + .add_session_info(&self.config, model); self.request_redraw()?; } EventMsg::AgentMessage { message } => { diff --git a/codex-rs/tui/src/conversation_history_widget.rs b/codex-rs/tui/src/conversation_history_widget.rs index d8abb9f1..3cd3e61d 100644 --- a/codex-rs/tui/src/conversation_history_widget.rs +++ b/codex-rs/tui/src/conversation_history_widget.rs @@ -184,8 +184,8 @@ impl ConversationHistoryWidget { /// Note `model` could differ from `config.model` if the agent decided to /// use a different model than the one requested by the user. - pub fn add_session_info(&mut self, config: &Config, model: String, cwd: PathBuf) { - self.add_to_history(HistoryCell::new_session_info(config, model, cwd)); + pub fn add_session_info(&mut self, config: &Config, model: String) { + self.add_to_history(HistoryCell::new_session_info(config, model)); } pub fn add_active_exec_command(&mut self, call_id: String, command: Vec) { diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index f9bb1817..5b9d7315 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -144,18 +144,14 @@ impl HistoryCell { HistoryCell::BackgroundEvent { lines } } - pub(crate) fn new_session_info( - config: &Config, - model: String, - cwd: std::path::PathBuf, - ) -> Self { + pub(crate) fn new_session_info(config: &Config, model: String) -> Self { let mut lines: Vec> = Vec::new(); lines.push(Line::from("codex session:".magenta().bold())); lines.push(Line::from(vec!["↳ model: ".bold(), model.into()])); lines.push(Line::from(vec![ "↳ cwd: ".bold(), - cwd.display().to_string().into(), + config.cwd.display().to_string().into(), ])); lines.push(Line::from(vec![ "↳ approval: ".bold(),