Conversation
`shortenCwd` tested containment with `cwd.startsWith(home + '/')`. On win32 `os.homedir()` reports `C:\Users\<name>` and `process.cwd()` uses backslashes, so the test was false for every subdirectory of the profile and the statusline printed the full absolute path instead of `~\Videos\clip`. Exact-home still matched, which is why the feature looked partly alive. Decide containment on separator-normalized copies of both paths, and slice the tail out of the original `cwd` so it keeps the separators the platform actually produced. `path.relative` is avoided on purpose: it follows the host platform, so a Windows path would be misread on a POSIX runner. A `..` segment now falls back to the full path rather than emitting a `~/..` form that no longer names the same directory. Comparison stays case-sensitive, like the other path helpers in the tree. The helper is exported so the regression table can inject home and cwd as plain strings and assert the Windows cases without a Windows runner; a second test drives `renderMakaPiStatusLine` through the real `os.homedir()` to cover the wiring. Statusline layout and every other segment are untouched. Closes apache#3825 Generated-by: Cursor Cloud Agent Co-authored-by: riba2534 <riba2534@qq.com>
Owner
Author
|
Opened against upstream: apache#3867 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shortenCwdinpackages/cli/src/pi-transcript.tsdecided home-containment withcwd.startsWith(home + '/'). On win32os.homedir()reportsC:\Users\<name>andprocess.cwd()uses backslashes, so that test was false for every subdirectory of the profile: the TUI statusline printed the full absolute path where it should have shown~\Videos\clip. Exact-home still matched, which is why the feature from apache#1064 / apache#1066 looked partly alive rather than broken.Containment is now decided on separator-normalized copies of both paths, and the emitted tail is sliced out of the original
cwdso it keeps whichever separators the platform actually produced (~\Videos\clipon Windows,~/workspace/projecton POSIX). Mixed separators within one Windows path match too.Two deliberate choices worth a reviewer's attention:
path.relativeis not used. It follows the host platform, soC:\Users\alicewould be misread on a POSIX runner — the same platform coupling that caused the bug, just inverted. A separator-normalized prefix test plus an explicit..rejection is the OS-independent equivalent, and it is what lets the regression test cover Windows without a Windows runner.isPathWithininpackages/storage/src/project-catalog.ts, the..${sep}containment checks insession-bundle-policy.tsandruntime-host-cli-installation.tsare all case-sensitive), so inventing a Windows-only policy here would be a new and unreviewed rule.A
..segment now falls back to the unabbreviated path instead of emitting a~/..form that no longer names the same directory. Statusline layout, every other segment, and the renderer are untouched; the change is confined toshortenCwdand its tests.Fixes apache#3825
Verification
shortenCwdis exported so the regression table can injecthomeandcwdas plain strings — the Windows expectations hold on a Linux runner. A second test drivesrenderMakaPiStatusLinewithjoin(homedir(), 'workspace', 'project')and asserts against the platform's ownsep, covering the production wiring on any OS.RED — with the original
home + '/'body (test kept as-is):GREEN —
npm --workspace maka-agent test(clean + build +node --test dist/**/*.test.js):Also run, all clean:
npm --workspace maka-agent run typecheck,npm run lint,npm run format:check, andnpx biome checkon both touched files.Not run: the root
npm testacross every workspace and the Windows CI jobs. Nothing outsidepackages/cliimportspi-transcript, and the abbreviation is pure string logic, so the CLI suite is the relevant blast radius. The Windows behavior is asserted from injected strings rather than a Windows runner by design.AI use
Select exactly one:
Tool(s) and scope: Cursor Cloud Agent (Claude Opus 5) investigated the report, wrote the
shortenCwdreplacement and the regression tests, and ran the checks above. Human contributor of record: riba2534. Commits carry aGenerated-by: Cursor Cloud Agenttrailer.Checklist
Does this PR entail a change in behavior?