Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: TUI should use cwd from Config (#808)

Michael Bolincd12f0c24a04
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
index 06bf1bc8b4..54c4804750 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<AppEvent>,
initial_prompt: Option<String>,
- initial_images: Vec<std::path::PathBuf>,
+ initial_images: Vec<PathBuf>,
) -> Self {
let (codex_op_tx, mut codex_op_rx) = unbounded_channel::<Op>();
- // 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<std::path::PathBuf>,
+ image_paths: Vec<PathBuf>,
) -> std::result::Result<(), SendError<AppEvent>> {
let mut items: Vec<InputItem> = 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 d8abb9f107..3cd3e61dd9 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<String>) {
diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs
index f9bb18179c..5b9d73150a 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<Line<'static>> = 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(),