canonicalize display of Agents.md paths on Windows. (#4577)

Canonicalize path on Windows to 
- remove unattractive path prefixes such as `\\?\`
- simplify it (`../AGENTS.md` vs
`C:\Users\iceweasel\code\coded\Agents.md`)
before: <img width="1110" height="45" alt="Screenshot 2025-10-01 123520"
src="https://github.com/user-attachments/assets/48920ae6-d89c-41b8-b4ea-df5c18fb5fad"
/>

after: 
<img width="585" height="46" alt="Screenshot 2025-10-01 123612"
src="https://github.com/user-attachments/assets/70a1761a-9d97-4836-b14c-670b6f13e608"
/>
This commit is contained in:
iceweasel-oai
2025-10-01 14:33:19 -07:00
committed by GitHub
parent 07c1db351a
commit 6f97ec4990
6 changed files with 21 additions and 5 deletions

View File

@@ -11,6 +11,10 @@ use unicode_width::UnicodeWidthStr;
use super::account::StatusAccountDisplay;
fn normalize_agents_display_path(path: &Path) -> String {
dunce::simplified(path).display().to_string()
}
pub(crate) fn compose_model_display(
config: &Config,
entries: &[(&str, String)],
@@ -59,13 +63,13 @@ pub(crate) fn compose_agents_summary(config: &Config) -> String {
let up = format!("..{}", std::path::MAIN_SEPARATOR);
format!("{}{}", up.repeat(ups), file_name)
} else if let Ok(stripped) = p.strip_prefix(&config.cwd) {
stripped.display().to_string()
normalize_agents_display_path(stripped)
} else {
p.display().to_string()
normalize_agents_display_path(&p)
}
}
} else {
p.display().to_string()
normalize_agents_display_path(&p)
};
rels.push(display);
}