Closes #3825: fix(cli): statusline never abbreviates home-relative paths on Windows - #4298
Closes #3825: fix(cli): statusline never abbreviates home-relative paths on Windows#4298evgenyponomarev wants to merge 1 commit into
Conversation
hqhq1025
left a comment
There was a problem hiding this comment.
I found one correctness issue in the path-containment check. I reviewed the complete two-file diff and the status-line caller, and reproduced both failure modes through the production helper on this exact commit.
Local verification passed: clean npm ci, npm run build:test, full workspace typecheck, the complete CLI test suite (646/646), the focused shortens cwd tests, changed-file Biome, git diff --check, and a clean merge-tree against current main. The hosted label check is green; hosted test is still running. I could not execute this on a native Windows host.
Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
| const home = homeDir ?? homedir(); | ||
| if (home && cwd.startsWith(home + '/')) return `~${cwd.slice(home.length)}`; | ||
| if (home && cwd === home) return '~'; | ||
| const normalizedHome = home.replace(/\\/g, '/'); |
There was a problem hiding this comment.
[P2] Preserve platform path semantics when checking containment. Replacing every backslash before comparison is unsafe for both supported path families. On this exact commit, shortenCwd('C:\\Users\\Alice\\work', 'c:\\users\\alice') returns the full absolute path even though Windows treats it as inside the home directory. Conversely, shortenCwd('/home/alice\\sibling/project', '/home/alice') returns ~\\sibling/project, although on POSIX the backslash is an ordinary filename character and that path is a sibling, not a descendant. This therefore still misses valid Windows paths and introduces a false home-relative display on POSIX. Please make containment platform-aware (including Windows case handling) and add regressions for both cases.
Closes #3825.
Verified against the pinned tree: the patch applies cleanly and the issue's post-fix check passes.
Scope: this repository does not build as a whole in the sandbox that produced this, so the check ran over the packages this patch touches and their dependencies. The rest of the repository was not built or tested here - please treat CI as the first check over the whole tree.
Written by an AI coding agent (Sloppy) and opened under my account.