fix(cli): abbreviate home-relative Windows paths in the status line - #4481
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
Re-reviewed at 2cce995 — nice catch and a clean fix.
I verified this independently:
- Root cause matches #3825 exactly:
startsWith(home + '/')can never match a Windows profile path, so only the exact home directory shortened. - Walked all six Windows assertions against
node:path/win32semantics — case-only differences, sibling rejection (..\\), and cross-drive absolute fallback all behave as the tests claim; POSIX behavior is unchanged (confirmed by running thepackages/clisuite: 667 pass / 0 fail on macOS, including the existing statusline-abbreviation tests). - The rewrite replaces the old logic outright — no parallel path, minimal surface.
One non-blocking observation: if CI has no Windows runner, the three win32 cases will always skip there, so the Windows branch is currently covered by local verification only. Existing infra gap, not something this PR needs to solve.
Approving — nice work. 🚀
shortenCwd matched the home directory by a POSIX-separator prefix, so on Windows only the exact home path shortened and every profile subdirectory rendered as a full absolute path. Compare through path.relative instead - it handles drive letters and case-only differences - and reject ..-prefixed or absolute results before emitting the ~/ form, keeping the remainder's native separators. The helper is exported so the contract has focused coverage: POSIX shortening and fallbacks, plus Windows profile, case-insensitive, sibling, and cross-drive cases (the Windows cases run on win32 hosts). Fixes apache#3825 Generated-by: GLM-5.3-Flash (ZCode)
Generated-by: OpenAI Codex
Generated-by: OpenAI Codex
3cff059 to
d115e27
Compare
jackwener
left a comment
There was a problem hiding this comment.
The status line now derives home-relative paths through the native path module, so Windows profile descendants shorten correctly while siblings, parent traversal, and other drives remain absolute. The review follow-up also keeps legal POSIX child names such as ..\notes eligible for shortening by checking only the native separator.
The exact rebased head built successfully and its full CLI suite passed 728 tests with three Windows-only skips. The focused Win32 path cases cover case-only profile differences, siblings, and cross-drive fallbacks, and the Windows skip inventory is current. The exact-head hosted check and the clean current-main merge both pass.
Automated review notice: This comment was posted by an automated review agent operated by WAWQAQ. It is not an independent human review and does not replace one.
Summary
The TUI status line never shortened home-relative paths on Windows:
shortenCwdcomparedcwdagainsthome + '/', which can never match a Windows profile path (C:\Users\<name>\Videos\...). Only the exact home directory shortened; every subdirectory rendered as a full absolute path.This change compares through
path.relativeinstead, which handles drive letters and case-only differences via the platform module, rejects native parent-traversal and absolute results (siblings, parent traversal, and other drives keep their absolute form), and emits~/<rest>with the remainder's native separators. A review follow-up keeps POSIX directory names whose first segment literally contains a backslash eligible for shortening.shortenCwdis exported so the contract has focused coverage.Fixes #3825
Verification
node --test dist/__tests__/pi-transcript.test.jsin packages/clinpm --workspace maka-agent testnpm run format:checknpx biome check packages/cli/src/pi-transcript.ts packages/cli/src/__tests__/pi-transcript.test.tsnpm run windows:inventorymainnpm run check:asf-headersNote: the full
@maka/clisuite on the original Windows checkout reports one failure unrelated to this change —runtime-host-update-reconciliation.test.jshitsEPERM: operation not permitted, fsyncon a directory, the Windows directory-sync gap tracked by #3898. The failing module does not importpi-transcript. Thecheck:asf-sourcerelease-legal script tests also fail on that checkout for spawn-environment reasons; the header audit that governs source files passes.AI use
Select exactly one:
Tool(s) and scope: GLM-5.3-Flash via ZCode traced the root cause, implemented the original fix and tests, and ran the original verification table. OpenAI Codex corrected the cross-platform parent-separator guard, added the POSIX
..\notesregression, and refreshed the repository's Windows skip inventory during review. All affected commits carryGenerated-bytrailers.Checklist
Does this PR entail a change in behavior?
~/-relative paths instead of full absolute paths; macOS/Linux behavior is unchanged