mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-09 03:20:56 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
72b96b1864
commit
a2288b7598
1 changed files with 3 additions and 8 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue