Skip to content

fix(tui): emit forward-slash mention labels on windows - #500

Closed
emal-avala wants to merge 1 commit into
mainfrom
fix/windows-mention-labels
Closed

fix(tui): emit forward-slash mention labels on windows#500
emal-avala wants to merge 1 commit into
mainfrom
fix/windows-mention-labels

Conversation

@emal-avala

Copy link
Copy Markdown
Member

Summary

Test (windows-latest) is currently red on main, and a release PR (#496, v0.28.0) is open against it. Three tests fail:

ui::modern::mentions::tests::expand_inlines_a_single_file
ui::modern::mentions::tests::expand_inlines_multiple_files_once_each
ui::modern::app::tests::submit_inlines_mentions_but_transcript_keeps_the_typed_text

assertion failed: out.prompt.contains("<file path=\"src/main.rs\">")

This is a product bug, not a test bug. display_path labels an inlined file with whatever to_string_lossy returns, so on Windows the model receives

<file path="src\main.rs">

for a file the user mentioned as @src/main.rs. The model quotes that label back in subsequent tool calls, so the path shape it was shown disagrees with the one it was asked about.

Fix

Join the relative path's components with /:

rel.components()
    .map(|c| c.as_os_str().to_string_lossy())
    .collect::<Vec<_>>()
    .join("/")

Joining components rather than substituting characters is the point. A backslash is a legal filename character on Unix, so a blanket replace('\\', "/") would mangle a real file named we\ird.txt. Component-joining never sees it as a separator, so one implementation is correct on both platforms with no cfg gate.

Why these tests only started failing now

They had not run on Windows at all since the mentions work landed. An unused variable: dir error in the same module failed the build under -D warnings, which killed the whole agent bin test target — so every test in that binary was skipped on Windows. #497 fixed the build error and surfaced these three (534 passed, 3 failed).

Verification

  • file_labels_use_forward_slashes_on_every_platform — pins the label shape, runs on all platforms.
  • a_backslash_inside_a_unix_filename_survives#[cfg(unix)], creates a file literally named we\ird.txt and asserts the label is not rewritten. This is the case the naive fix gets wrong.
  • 32 mentions tests pass; clippy --all-targets -- -D warnings and fmt --check clean.

Three tests fail on windows-latest on main:

  ui::modern::mentions::tests::expand_inlines_a_single_file
  ui::modern::mentions::tests::expand_inlines_multiple_files_once_each
  ui::modern::app::tests::submit_inlines_mentions_but_transcript_keeps_the_typed_text

  assertion failed: out.prompt.contains("<file path=\"src/main.rs\">")

This is a product bug, not a test bug. `display_path` labelled an inlined
file with whatever `to_string_lossy` produced, so a Windows session hands
the model `<file path="src\main.rs">` for a file the user mentioned as
`@src/main.rs`. The model quotes that label back in later tool calls, so
the shape it was shown disagrees with the shape it was asked about.

Join the relative path's components with `/` instead. Joining components
rather than substituting characters is what keeps this correct on Unix,
where a backslash is a legal filename character: it stays inside one
component and is never mistaken for a separator.

These tests had not run on Windows since the mentions work landed — an
unused-variable error in the same module failed the build before the test
binary existed, so the whole agent bin target was skipped.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 503c9bd65a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

fs::write(dir.path().join("we\\ird.txt"), "hi\n").unwrap();
let out = expand_mentions("see @we\\ird.txt", dir.path()).expect("expanded");
assert!(
out.prompt.contains("we\\ird.txt"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Assert against the generated file label

This assertion also matches the unchanged user-text prefix (see @we\ird.txt), so it passes even if display_path mangles the generated label to we/ird.txt. Consequently, the test does not protect the Unix filename behavior it claims to verify; assert on the complete <file path="we\ird.txt"> tag instead.

Useful? React with 👍 / 👎.

@emal-avala

Copy link
Copy Markdown
Member Author

Superseded by #499, which merged the identical components-join fix for display_path (this branch now rebases to an empty diff). One thing worth salvaging from this version: the doc comment here explains why joining components beats character substitution (backslash is a legal filename character on unix) — happy to fold that wording into the merged comment in a docs touch-up if wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant