Skip to content

fix(workspace): use path.isAbsolute() for Windows path compatibility#413

Open
Lygggggg wants to merge 2 commits intozts212653:mainfrom
Lygggggg:fix/workspace-windows-path
Open

fix(workspace): use path.isAbsolute() for Windows path compatibility#413
Lygggggg wants to merge 2 commits intozts212653:mainfrom
Lygggggg:fix/workspace-windows-path

Conversation

@Lygggggg
Copy link
Copy Markdown
Contributor

@Lygggggg Lygggggg commented Apr 10, 2026

Closes #414

Summary

  • Workspace panel shows empty on Windows because repoRoot.startsWith('/') rejects Windows absolute paths like C:\...
  • Replace with path.isAbsolute() (already imported) which handles both Windows and Unix paths
  • One-line fix, no new dependencies

Root Cause

GET /api/workspace/worktrees?repoRoot=C:\... returns 400 because the path validation assumes Unix-style absolute paths. Frontend catch { /* ignore */ } silently swallows the error, resulting in an empty workspace panel (no files, no changes, no git info).

Changes

  1. packages/api/src/routes/workspace.ts:283startsWith('/')isAbsolute()
  2. packages/api/test/workspace-windows-path.test.js — regression test (7 cases)

Test Evidence

▶ workspace worktrees repoRoot validation (Windows compat)
  ✔ accepts Unix absolute path (1.186ms)
  ✔ accepts Windows absolute path with backslash (0.2177ms)
  ✔ accepts Windows absolute path with forward slash (1.3559ms)
  ✔ accepts UNC path (0.2021ms)
  ✔ rejects relative path (0.2148ms)
  ✔ rejects dot-relative path (0.1911ms)
  ✔ rejects parent-relative path (0.2409ms)
✔ 7 pass, 0 fail

Test plan

  • Regression test covers Windows/Unix/UNC/relative paths
  • On Windows: open a project, verify workspace panel shows files/changes/git
  • On macOS/Linux: verify no regression (Unix paths still work)

🤖 Generated with Claude Code

The worktrees endpoint rejected Windows absolute paths (e.g. C:\...)
because it checked repoRoot.startsWith('/') which only matches Unix
paths. Replace with Node.js path.isAbsolute() which handles both
Windows and Unix paths correctly. isAbsolute was already imported
but unused for this check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lygggggg Lygggggg requested a review from zts212653 as a code owner April 10, 2026 01:59
Verify that isAbsolute() correctly accepts Windows absolute paths
(C:\..., C:/..., UNC \server\share) and rejects relative paths.
Prevents regression of the startsWith('/') bug.

Closes zts212653#414

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace panel empty on Windows: repoRoot path validation rejects Windows absolute paths

1 participant