Skip to content

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

Description

@0xMudit

What happened

The statusline never abbreviates home-relative paths on Windows: shortenCwd (packages/cli/src/pi-transcript.ts:1520-1525) is POSIX-only:

if (home && cwd.startsWith(home + '/')) return `~${cwd.slice(home.length)}`;

On win32, os.homedir() returns C:\Users\<name> and process.cwd() uses backslashes, so cwd.startsWith(home + '/') is false for every subdirectory of the profile directory — only the exact-home case matches. The statusline shows the full absolute path (C:\Users\<name>\Videos\...) instead of ~/Videos/..., silently no-oping the documented feature (/Users/alice/workspace/project~/workspace/project) on Windows rather than degrading explicitly.

How to reproduce

  1. On Windows, run maka (TUI) from any directory under %USERPROFILE%
  2. The statusline's last segment shows the full absolute path instead of a ~/-relative form

Suggested fix

Normalize separators before comparing (e.g. compare separator-normalized forms of cwd and home, or use path.relative(home, cwd) and reject results starting with ..), then emit ~/<rest> with native separators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions