From a2288b75983b33f148f55149ac7d64285d0563dc Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 11 Mar 2026 00:28:33 -0400 Subject: [PATCH] Simplify shorten_path and format call in progress UI Use std::path::Path::strip_prefix instead of manual string manipulation, and simplify redundant format! wrapper. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/arc-workflows/src/cli/progress.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/crates/arc-workflows/src/cli/progress.rs b/lib/crates/arc-workflows/src/cli/progress.rs index 68d7fde05..ac68afa47 100644 --- a/lib/crates/arc-workflows/src/cli/progress.rs +++ b/lib/crates/arc-workflows/src/cli/progress.rs @@ -122,13 +122,8 @@ fn last_line_truncated(s: &str, max: usize) -> String { fn shorten_path(path: &str, working_directory: Option<&str>) -> String { if let Some(wd) = working_directory { - let wd_prefix = if wd.ends_with('/') { - wd.to_string() - } else { - format!("{wd}/") - }; - if let Some(rel) = path.strip_prefix(&wd_prefix) { - return rel.to_string(); + if let Ok(rel) = std::path::Path::new(path).strip_prefix(wd) { + return rel.display().to_string(); } } if let Ok(cwd) = std::env::current_dir() { @@ -1122,7 +1117,7 @@ impl ProgressUI { .insert_after(stage.last_bar(), ProgressBar::new_spinner()); bar.set_style(style_subagent_info()); let dim = Style::new().dim(); - bar.set_message(format!("{}", dim.apply_to(format!("\u{25b8} {branch}")))); + bar.set_message(dim.apply_to(format!("\u{25b8} {branch}")).to_string()); stage.tool_calls.push_back(ToolCallEntry { display_name: branch.to_string(), tool_call_id: branch.to_string(),