Skip to content

Closes #3825: fix(cli): statusline never abbreviates home-relative paths on Windows - #4298

Open
evgenyponomarev wants to merge 1 commit into
apache:mainfrom
evgenyponomarev:sloppy/issue-3825-66e6f4e428ea
Open

Closes #3825: fix(cli): statusline never abbreviates home-relative paths on Windows#4298
evgenyponomarev wants to merge 1 commit into
apache:mainfrom
evgenyponomarev:sloppy/issue-3825-66e6f4e428ea

Conversation

@evgenyponomarev

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Aug 31, 2026

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, '/');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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.

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

Labels

effort/S Under 100 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): statusline never abbreviates home-relative paths on Windows

2 participants