Skip to content

Commit 083bbbc

Browse files
committed
fix(resume-picker): add correct insta windows snapshots
Insta expects OS-specific snapshots to be named `@windows.snap`; rename the resume picker snapshots accordingly so Windows CI finds them.
1 parent 9866ec7 commit 083bbbc

6 files changed

+86
-13
lines changed

codex-rs/tui/src/resume_picker.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,20 @@ mod tests {
11271127
use std::sync::Arc;
11281128
use std::sync::Mutex;
11291129

1130+
/// Snapshot output differs on Windows because paths render with Windows separators.
1131+
/// Keep the UX OS-native and use OS-specific snapshot variants.
1132+
macro_rules! assert_snapshot_os {
1133+
($name:expr, $value:expr) => {{
1134+
#[cfg(target_os = "windows")]
1135+
insta::with_settings!({ snapshot_suffix => "windows" }, {
1136+
assert_snapshot!($name, $value);
1137+
});
1138+
1139+
#[cfg(not(target_os = "windows"))]
1140+
assert_snapshot!($name, $value);
1141+
}};
1142+
}
1143+
11301144
fn head_with_ts_and_user_text(ts: &str, texts: &[&str]) -> Vec<serde_json::Value> {
11311145
vec![
11321146
json!({ "timestamp": ts }),
@@ -1486,7 +1500,7 @@ mod tests {
14861500
terminal.flush().expect("flush");
14871501

14881502
let snapshot = terminal.backend().to_string();
1489-
assert_snapshot!("resume_picker_screen", snapshot);
1503+
assert_snapshot_os!("resume_picker_screen", snapshot);
14901504
}
14911505

14921506
#[tokio::test]
@@ -1652,7 +1666,7 @@ mod tests {
16521666
terminal.flush().expect("flush");
16531667

16541668
let snapshot = terminal.backend().to_string();
1655-
assert_snapshot!("resume_picker_screen_filtered", snapshot);
1669+
assert_snapshot_os!("resume_picker_screen_filtered", snapshot);
16561670
}
16571671

16581672
#[test]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: tui/src/resume_picker.rs
3+
expression: snapshot
4+
---
5+
Resume a previous session
6+
Type to search
7+
Showing sessions from all directories (--all) · Current directory: /tmp/project
8+
Updated Branch CWD Conversation
9+
No sessions yet
10+
11+
12+
13+
enter to resume esc to start new ctrl + c to quit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: tui/src/resume_picker.rs
3+
expression: snapshot
4+
---
5+
Resume a previous session
6+
Type to search
7+
Filtering to current directory: /tmp/project · Use --all to show sessions from a
8+
Updated Branch Conversation
9+
No sessions yet
10+
11+
12+
13+
enter to resume esc to start new ctrl + c to quit

codex-rs/tui2/src/resume_picker.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use tokio_stream::StreamExt;
2727
use tokio_stream::wrappers::UnboundedReceiverStream;
2828
use unicode_width::UnicodeWidthStr;
2929

30-
use crate::diff_render::display_path_for;
3130
use crate::key_hint;
3231
use crate::text_formatting::truncate_text;
3332
use crate::tui::FrameRequester;
@@ -726,13 +725,7 @@ fn render_filter_hint_line(state: &PickerState) -> Line<'static> {
726725
let cwd = state
727726
.display_cwd
728727
.as_ref()
729-
.map(|path| {
730-
if path.is_absolute() {
731-
path.display().to_string()
732-
} else {
733-
display_path_for(path, Path::new("/"))
734-
}
735-
})
728+
.map(|path| path.display().to_string())
736729
.unwrap_or_else(|| String::from("unknown"));
737730

738731
if state.show_all_flag {
@@ -1100,7 +1093,7 @@ fn calculate_column_metrics(rows: &[Row], include_cwd: bool) -> ColumnMetrics {
11001093
let cwd_raw = row
11011094
.cwd
11021095
.as_ref()
1103-
.map(|p| display_path_for(p, std::path::Path::new("/")))
1096+
.map(|p| p.display().to_string())
11041097
.unwrap_or_default();
11051098
right_elide(&cwd_raw, 24)
11061099
} else {
@@ -1133,6 +1126,20 @@ mod tests {
11331126
use std::sync::Arc;
11341127
use std::sync::Mutex;
11351128

1129+
/// Snapshot output differs on Windows because paths render with Windows separators.
1130+
/// Keep the UX OS-native and use OS-specific snapshot variants.
1131+
macro_rules! assert_snapshot_os {
1132+
($name:expr, $value:expr) => {{
1133+
#[cfg(target_os = "windows")]
1134+
insta::with_settings!({ snapshot_suffix => "windows" }, {
1135+
assert_snapshot!($name, $value);
1136+
});
1137+
1138+
#[cfg(not(target_os = "windows"))]
1139+
assert_snapshot!($name, $value);
1140+
}};
1141+
}
1142+
11361143
fn head_with_ts_and_user_text(ts: &str, texts: &[&str]) -> Vec<serde_json::Value> {
11371144
vec![
11381145
json!({ "timestamp": ts }),
@@ -1492,7 +1499,7 @@ mod tests {
14921499
terminal.flush().expect("flush");
14931500

14941501
let snapshot = terminal.backend().to_string();
1495-
assert_snapshot!("resume_picker_screen", snapshot);
1502+
assert_snapshot_os!("resume_picker_screen", snapshot);
14961503
}
14971504

14981505
#[tokio::test]
@@ -1658,7 +1665,7 @@ mod tests {
16581665
terminal.flush().expect("flush");
16591666

16601667
let snapshot = terminal.backend().to_string();
1661-
assert_snapshot!("resume_picker_screen_filtered", snapshot);
1668+
assert_snapshot_os!("resume_picker_screen_filtered", snapshot);
16621669
}
16631670

16641671
#[test]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: tui2/src/resume_picker.rs
3+
expression: snapshot
4+
---
5+
Resume a previous session
6+
Type to search
7+
Showing sessions from all directories (--all) · Current directory: /tmp/project
8+
Updated Branch CWD Conversation
9+
No sessions yet
10+
11+
12+
13+
enter to resume esc to start new ctrl + c to quit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: tui2/src/resume_picker.rs
3+
expression: snapshot
4+
---
5+
Resume a previous session
6+
Type to search
7+
Filtering to current directory: /tmp/project · Use --all to show sessions from a
8+
Updated Branch Conversation
9+
No sessions yet
10+
11+
12+
13+
enter to resume esc to start new ctrl + c to quit

0 commit comments

Comments
 (0)