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:
10
codex-rs/Cargo.lock
generated
10
codex-rs/Cargo.lock
generated
@@ -863,6 +863,7 @@ dependencies = [
|
|||||||
"codex-rmcp-client",
|
"codex-rmcp-client",
|
||||||
"core_test_support",
|
"core_test_support",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"dunce",
|
||||||
"env-flags",
|
"env-flags",
|
||||||
"escargot",
|
"escargot",
|
||||||
"eventsource-stream",
|
"eventsource-stream",
|
||||||
@@ -1200,6 +1201,7 @@ dependencies = [
|
|||||||
"crossterm",
|
"crossterm",
|
||||||
"diffy",
|
"diffy",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"dunce",
|
||||||
"image",
|
"image",
|
||||||
"insta",
|
"insta",
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
@@ -1798,6 +1800,12 @@ version = "0.0.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5"
|
checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dunce"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dupe"
|
name = "dupe"
|
||||||
version = "0.9.1"
|
version = "0.9.1"
|
||||||
@@ -4064,7 +4072,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"socket2 0.5.10",
|
"socket2 0.5.10",
|
||||||
"tracing",
|
"tracing",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ derive_more = "2"
|
|||||||
diffy = "0.4.2"
|
diffy = "0.4.2"
|
||||||
dirs = "6"
|
dirs = "6"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
|
dunce = "1.0.4"
|
||||||
env-flags = "0.1.1"
|
env-flags = "0.1.1"
|
||||||
env_logger = "0.11.5"
|
env_logger = "0.11.5"
|
||||||
escargot = "0.5"
|
escargot = "0.5"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ codex-protocol = { workspace = true }
|
|||||||
codex-app-server-protocol = { workspace = true }
|
codex-app-server-protocol = { workspace = true }
|
||||||
codex-otel = { workspace = true, features = ["otel"] }
|
codex-otel = { workspace = true, features = ["otel"] }
|
||||||
dirs = { workspace = true }
|
dirs = { workspace = true }
|
||||||
|
dunce = { workspace = true }
|
||||||
env-flags = { workspace = true }
|
env-flags = { workspace = true }
|
||||||
eventsource-stream = { workspace = true }
|
eventsource-stream = { workspace = true }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
//! 3. We do **not** walk past the Git root.
|
//! 3. We do **not** walk past the Git root.
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use dunce::canonicalize as normalize_path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
@@ -109,7 +110,7 @@ pub async fn read_project_docs(config: &Config) -> std::io::Result<Option<String
|
|||||||
/// is zero, returns an empty list.
|
/// is zero, returns an empty list.
|
||||||
pub fn discover_project_doc_paths(config: &Config) -> std::io::Result<Vec<PathBuf>> {
|
pub fn discover_project_doc_paths(config: &Config) -> std::io::Result<Vec<PathBuf>> {
|
||||||
let mut dir = config.cwd.clone();
|
let mut dir = config.cwd.clone();
|
||||||
if let Ok(canon) = dir.canonicalize() {
|
if let Ok(canon) = normalize_path(&dir) {
|
||||||
dir = canon;
|
dir = canon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ color-eyre = { workspace = true }
|
|||||||
crossterm = { workspace = true, features = ["bracketed-paste", "event-stream"] }
|
crossterm = { workspace = true, features = ["bracketed-paste", "event-stream"] }
|
||||||
diffy = { workspace = true }
|
diffy = { workspace = true }
|
||||||
dirs = { workspace = true }
|
dirs = { workspace = true }
|
||||||
|
dunce = { workspace = true }
|
||||||
image = { workspace = true, features = ["jpeg", "png"] }
|
image = { workspace = true, features = ["jpeg", "png"] }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
lazy_static = { workspace = true }
|
lazy_static = { workspace = true }
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ use unicode_width::UnicodeWidthStr;
|
|||||||
|
|
||||||
use super::account::StatusAccountDisplay;
|
use super::account::StatusAccountDisplay;
|
||||||
|
|
||||||
|
fn normalize_agents_display_path(path: &Path) -> String {
|
||||||
|
dunce::simplified(path).display().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn compose_model_display(
|
pub(crate) fn compose_model_display(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
entries: &[(&str, String)],
|
entries: &[(&str, String)],
|
||||||
@@ -59,13 +63,13 @@ pub(crate) fn compose_agents_summary(config: &Config) -> String {
|
|||||||
let up = format!("..{}", std::path::MAIN_SEPARATOR);
|
let up = format!("..{}", std::path::MAIN_SEPARATOR);
|
||||||
format!("{}{}", up.repeat(ups), file_name)
|
format!("{}{}", up.repeat(ups), file_name)
|
||||||
} else if let Ok(stripped) = p.strip_prefix(&config.cwd) {
|
} else if let Ok(stripped) = p.strip_prefix(&config.cwd) {
|
||||||
stripped.display().to_string()
|
normalize_agents_display_path(stripped)
|
||||||
} else {
|
} else {
|
||||||
p.display().to_string()
|
normalize_agents_display_path(&p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.display().to_string()
|
normalize_agents_display_path(&p)
|
||||||
};
|
};
|
||||||
rels.push(display);
|
rels.push(display);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user