diff --git a/codex-rs/tui/src/resume_picker.rs b/codex-rs/tui/src/resume_picker.rs index f502a20f91..c6f57d723b 100644 --- a/codex-rs/tui/src/resume_picker.rs +++ b/codex-rs/tui/src/resume_picker.rs @@ -1127,6 +1127,20 @@ mod tests { use std::sync::Arc; use std::sync::Mutex; + /// Snapshot output differs on Windows because paths render with Windows separators. + /// Keep the UX OS-native and use OS-specific snapshot variants. + macro_rules! assert_snapshot_os { + ($name:expr, $value:expr) => {{ + #[cfg(target_os = "windows")] + insta::with_settings!({ snapshot_suffix => "windows" }, { + assert_snapshot!($name, $value); + }); + + #[cfg(not(target_os = "windows"))] + assert_snapshot!($name, $value); + }}; + } + fn head_with_ts_and_user_text(ts: &str, texts: &[&str]) -> Vec { vec![ json!({ "timestamp": ts }), @@ -1486,7 +1500,7 @@ mod tests { terminal.flush().expect("flush"); let snapshot = terminal.backend().to_string(); - assert_snapshot!("resume_picker_screen", snapshot); + assert_snapshot_os!("resume_picker_screen", snapshot); } #[tokio::test] @@ -1652,7 +1666,7 @@ mod tests { terminal.flush().expect("flush"); let snapshot = terminal.backend().to_string(); - assert_snapshot!("resume_picker_screen_filtered", snapshot); + assert_snapshot_os!("resume_picker_screen_filtered", snapshot); } #[test] diff --git a/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen@windows.snap b/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen@windows.snap new file mode 100644 index 0000000000..bd3ddc3c68 --- /dev/null +++ b/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen@windows.snap @@ -0,0 +1,13 @@ +--- +source: tui/src/resume_picker.rs +expression: snapshot +--- +Resume a previous session +Type to search +Showing sessions from all directories (--all) · Current directory: /tmp/project + Updated Branch CWD Conversation +No sessions yet + + + +enter to resume esc to start new ctrl + c to quit diff --git a/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen_filtered@windows.snap b/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen_filtered@windows.snap new file mode 100644 index 0000000000..0b50fecbae --- /dev/null +++ b/codex-rs/tui/src/snapshots/codex_tui__resume_picker__tests__resume_picker_screen_filtered@windows.snap @@ -0,0 +1,13 @@ +--- +source: tui/src/resume_picker.rs +expression: snapshot +--- +Resume a previous session +Type to search +Filtering to current directory: /tmp/project · Use --all to show sessions from a + Updated Branch Conversation +No sessions yet + + + +enter to resume esc to start new ctrl + c to quit diff --git a/codex-rs/tui2/src/resume_picker.rs b/codex-rs/tui2/src/resume_picker.rs index 20e0227a9e..7e21371131 100644 --- a/codex-rs/tui2/src/resume_picker.rs +++ b/codex-rs/tui2/src/resume_picker.rs @@ -27,7 +27,6 @@ use tokio_stream::StreamExt; use tokio_stream::wrappers::UnboundedReceiverStream; use unicode_width::UnicodeWidthStr; -use crate::diff_render::display_path_for; use crate::key_hint; use crate::text_formatting::truncate_text; use crate::tui::FrameRequester; @@ -726,13 +725,7 @@ fn render_filter_hint_line(state: &PickerState) -> Line<'static> { let cwd = state .display_cwd .as_ref() - .map(|path| { - if path.is_absolute() { - path.display().to_string() - } else { - display_path_for(path, Path::new("/")) - } - }) + .map(|path| path.display().to_string()) .unwrap_or_else(|| String::from("unknown")); if state.show_all_flag { @@ -1100,7 +1093,7 @@ fn calculate_column_metrics(rows: &[Row], include_cwd: bool) -> ColumnMetrics { let cwd_raw = row .cwd .as_ref() - .map(|p| display_path_for(p, std::path::Path::new("/"))) + .map(|p| p.display().to_string()) .unwrap_or_default(); right_elide(&cwd_raw, 24) } else { @@ -1133,6 +1126,20 @@ mod tests { use std::sync::Arc; use std::sync::Mutex; + /// Snapshot output differs on Windows because paths render with Windows separators. + /// Keep the UX OS-native and use OS-specific snapshot variants. + macro_rules! assert_snapshot_os { + ($name:expr, $value:expr) => {{ + #[cfg(target_os = "windows")] + insta::with_settings!({ snapshot_suffix => "windows" }, { + assert_snapshot!($name, $value); + }); + + #[cfg(not(target_os = "windows"))] + assert_snapshot!($name, $value); + }}; + } + fn head_with_ts_and_user_text(ts: &str, texts: &[&str]) -> Vec { vec![ json!({ "timestamp": ts }), @@ -1492,7 +1499,7 @@ mod tests { terminal.flush().expect("flush"); let snapshot = terminal.backend().to_string(); - assert_snapshot!("resume_picker_screen", snapshot); + assert_snapshot_os!("resume_picker_screen", snapshot); } #[tokio::test] @@ -1658,7 +1665,7 @@ mod tests { terminal.flush().expect("flush"); let snapshot = terminal.backend().to_string(); - assert_snapshot!("resume_picker_screen_filtered", snapshot); + assert_snapshot_os!("resume_picker_screen_filtered", snapshot); } #[test] diff --git a/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen@windows.snap b/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen@windows.snap new file mode 100644 index 0000000000..38d2c6c6ad --- /dev/null +++ b/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen@windows.snap @@ -0,0 +1,13 @@ +--- +source: tui2/src/resume_picker.rs +expression: snapshot +--- +Resume a previous session +Type to search +Showing sessions from all directories (--all) · Current directory: /tmp/project + Updated Branch CWD Conversation +No sessions yet + + + +enter to resume esc to start new ctrl + c to quit diff --git a/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen_filtered@windows.snap b/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen_filtered@windows.snap new file mode 100644 index 0000000000..55dfb214bc --- /dev/null +++ b/codex-rs/tui2/src/snapshots/codex_tui2__resume_picker__tests__resume_picker_screen_filtered@windows.snap @@ -0,0 +1,13 @@ +--- +source: tui2/src/resume_picker.rs +expression: snapshot +--- +Resume a previous session +Type to search +Filtering to current directory: /tmp/project · Use --all to show sessions from a + Updated Branch Conversation +No sessions yet + + + +enter to resume esc to start new ctrl + c to quit