Skip to content

Commit 6f97ec4

Browse files
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" />
1 parent 07c1db3 commit 6f97ec4

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

codex-rs/Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ derive_more = "2"
9797
diffy = "0.4.2"
9898
dirs = "6"
9999
dotenvy = "0.15.7"
100+
dunce = "1.0.4"
100101
env-flags = "0.1.1"
101102
env_logger = "0.11.5"
102103
escargot = "0.5"

codex-rs/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ codex-protocol = { workspace = true }
2727
codex-app-server-protocol = { workspace = true }
2828
codex-otel = { workspace = true, features = ["otel"] }
2929
dirs = { workspace = true }
30+
dunce = { workspace = true }
3031
env-flags = { workspace = true }
3132
eventsource-stream = { workspace = true }
3233
futures = { workspace = true }

codex-rs/core/src/project_doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! 3. We do **not** walk past the Git root.
1515
1616
use crate::config::Config;
17+
use dunce::canonicalize as normalize_path;
1718
use std::path::PathBuf;
1819
use tokio::io::AsyncReadExt;
1920
use tracing::error;
@@ -109,7 +110,7 @@ pub async fn read_project_docs(config: &Config) -> std::io::Result<Option<String
109110
/// is zero, returns an empty list.
110111
pub fn discover_project_doc_paths(config: &Config) -> std::io::Result<Vec<PathBuf>> {
111112
let mut dir = config.cwd.clone();
112-
if let Ok(canon) = dir.canonicalize() {
113+
if let Ok(canon) = normalize_path(&dir) {
113114
dir = canon;
114115
}
115116

codex-rs/tui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ color-eyre = { workspace = true }
4444
crossterm = { workspace = true, features = ["bracketed-paste", "event-stream"] }
4545
diffy = { workspace = true }
4646
dirs = { workspace = true }
47+
dunce = { workspace = true }
4748
image = { workspace = true, features = ["jpeg", "png"] }
4849
itertools = { workspace = true }
4950
lazy_static = { workspace = true }

codex-rs/tui/src/status/helpers.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ use unicode_width::UnicodeWidthStr;
1111

1212
use super::account::StatusAccountDisplay;
1313

14+
fn normalize_agents_display_path(path: &Path) -> String {
15+
dunce::simplified(path).display().to_string()
16+
}
17+
1418
pub(crate) fn compose_model_display(
1519
config: &Config,
1620
entries: &[(&str, String)],
@@ -59,13 +63,13 @@ pub(crate) fn compose_agents_summary(config: &Config) -> String {
5963
let up = format!("..{}", std::path::MAIN_SEPARATOR);
6064
format!("{}{}", up.repeat(ups), file_name)
6165
} else if let Ok(stripped) = p.strip_prefix(&config.cwd) {
62-
stripped.display().to_string()
66+
normalize_agents_display_path(stripped)
6367
} else {
64-
p.display().to_string()
68+
normalize_agents_display_path(&p)
6569
}
6670
}
6771
} else {
68-
p.display().to_string()
72+
normalize_agents_display_path(&p)
6973
};
7074
rels.push(display);
7175
}

0 commit comments

Comments
 (0)