diff --git a/codex-rs/tui/src/chatwidget/tests/helpers.rs b/codex-rs/tui/src/chatwidget/tests/helpers.rs index c63b617ab3..46d9595bfb 100644 --- a/codex-rs/tui/src/chatwidget/tests/helpers.rs +++ b/codex-rs/tui/src/chatwidget/tests/helpers.rs @@ -63,6 +63,25 @@ pub(super) fn normalize_snapshot_paths(text: impl Into) -> String { } } +/// Normalizes platform-specific test paths without collapsing box alignment. +pub(super) fn normalize_box_snapshot_paths(text: &str) -> String { + text.lines() + .map(|rendered| { + let normalized = normalize_snapshot_paths(rendered); + let padding = rendered + .chars() + .count() + .saturating_sub(normalized.chars().count()); + if let Some((content, suffix)) = normalized.rsplit_once('│') { + format!("{content}{}│{suffix}", " ".repeat(padding)) + } else { + normalized + } + }) + .collect::>() + .join("\n") +} + pub(super) fn normalized_backend_snapshot(value: &T) -> String { let platform_test_cwd = test_path_display("/tmp/project"); let rendered = format!("{value}"); @@ -79,7 +98,7 @@ pub(super) fn normalized_backend_snapshot(value: &T) -> St .and_then(|line| line.strip_suffix('"')) { let width = content.chars().count(); - let normalized = normalize_snapshot_paths(content); + let normalized = normalize_box_snapshot_paths(content); format!("\"{normalized:width$}\"") } else { normalize_snapshot_paths(line) diff --git a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs index 6383aa6ace..2a6688a765 100644 --- a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs +++ b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs @@ -1649,24 +1649,7 @@ async fn startup_header_handoff_visible_states_snapshot() { if cell.as_any().is::() => { let rendered = lines_to_single_string(&cell.display_lines(width)); - let normalized = normalize_snapshot_paths(&rendered); - // Keep box alignment after shortening Windows test paths. - break normalized - .lines() - .zip(rendered.lines()) - .map(|(normalized, rendered)| { - let padding = rendered - .chars() - .count() - .saturating_sub(normalized.chars().count()); - if let Some(content) = normalized.strip_suffix('│') { - format!("{content}{}│", " ".repeat(padding)) - } else { - normalized.to_string() - } - }) - .collect::>() - .join("\n"); + break normalize_box_snapshot_paths(&rendered); } Ok(_) => continue, other => panic!("expected queued configured header, got {other:?}"),