Skip to content

refactor(invocation): use path_slash for argv[0] normalization - #3379

Merged
max-sixty merged 2 commits into
mainfrom
nightly/clean-28776270208
Jul 7, 2026
Merged

refactor(invocation): use path_slash for argv[0] normalization#3379
max-sixty merged 2 commits into
mainfrom
nightly/clean-28776270208

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Nightly code-quality sweep finding.

invocation_path() in src/invocation.rs hand-rolled .to_string_lossy().replace('\\', "/") to produce a forward-slash display path. That is the exact anti-pattern the "Use Existing Dependencies" table in CLAUDE.md flags — the sanctioned tool for path normalization is path_slash::PathExt::to_slash_lossy(), which is already used throughout src/ (e.g. src/path.rs, src/commands/config/state.rs, src/diagnostic.rs).

This swaps the manual replacement for to_slash_lossy(), extracted into a small pure helper normalize_invocation_path(&OsStr) so the logic is unit-testable (the public invocation_path() reads std::env::args_os() and can't be exercised directly).

The switch is behavior-preserving for every realistic argv[0]: on Unix, values like wt, ./wt, target/debug/wt, and /usr/local/bin/wt carry no backslashes, so normalization is a pass-through; on Windows, both the old replacement and to_slash_lossy() render \ separators as /. The one semantic difference is strictly more correct — to_slash_lossy() is platform-aware, so a literal \ in a Unix path (a valid filename character there, not a separator) is now left untouched rather than mangled. This function is display-only (it feeds wt config show debug output and shell-integration warnings), so no snapshots change; the test filters in tests/common/mod.rs already normalize both raw and forward-slash forms.

Test: added normalize_invocation_path_passes_through_forward_slash_paths (runs everywhere) plus a #[cfg(windows)] case pinning the \/ normalization. The pure helper had no prior unit coverage.

Replace the hand-rolled .to_string_lossy().replace('\\', "/") in
invocation_path() with path_slash::PathExt::to_slash_lossy(), the tool
CLAUDE.md's dependency table sanctions for path normalization. Extract a
pure normalize_invocation_path(&OsStr) helper so the logic is unit-testable.

Behavior-preserving for realistic argv[0]; the platform-aware helper is
strictly more correct for literal backslashes in Unix paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Jul 6, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 9dd7230 into main Jul 7, 2026
36 checks passed
@max-sixty
max-sixty deleted the nightly/clean-28776270208 branch July 7, 2026 06:26
max-sixty added a commit that referenced this pull request Jul 8, 2026
…indow (#3386)

Five commits landed on `main` during #3385's CI wait, so they ship
inside v0.66.0's tree but weren't in its changelog (the step-12 drift
check in the release skill caught this). This adds the user-facing three
to the 0.66.0 section:

- **Codex activity markers**
([#3364](#3364), closes
[#3362](#3362), thanks
@ofek for reporting)
- **SCP-style SSH remotes with custom usernames**
([#3371](#3371), thanks
@fcoury-oai)
- **Windows app-alias Settings path**
([#3372](#3372), thanks
@ofek)

Excluded as internal: #3360 (trait docstrings), #3379 (argv[0] display
refactor). Every entry verified against the actual diffs.

The v0.66.0 tag will point at this PR's squash commit so the tagged tree
carries the complete changelog.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> _This was written by Claude Code on behalf of Maximilian Roos_

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants