Skip to content

WSL project paths decode to /mnt/d/... instead of D:\ on Windows #118

@kevinkre

Description

@kevinkre

Problem

Many Claude Code users run CC inside WSL while using the DevTools Windows app for visualization. This is a really common setup — WSL is the recommended way to run Claude Code on Windows.

In this configuration, project folder names in ~/.claude/projects/ encode WSL POSIX paths (e.g., -mnt-d-mcp-foo decoding to /mnt/d/mcp/foo). The DevTools app successfully discovers these projects (especially after using the "Using Linux/WSL?" button in Settings), but the decoded paths remain in POSIX format rather than being translated to Windows drive-letter paths (D:/mcp/foo).

This affects:

  • Project names displayed in the UI
  • Any "open in editor" or external tool integration that needs a valid Windows path
  • The extractCwd() authoritative path resolution from session JSONL files (which also contain WSL paths)

Suggested Fix

Add a translateWslMountPath() function that converts /mnt/X/... to X:/... when process.platform === 'win3 2'. Apply it in two places:

  1. pathDecoder.tsdecodePath() — the fallback path decoder
  2. metadataExtraction.tsextractCwd() — the authoritative session-based path resolution

The translation is gated behind process.platform === 'win32' so it's a no-op on Linux/macOS.

Diff

I've prototyped this locally with tests (all 48 passing). Happy to submit as a PR if that's preferred.

src/main/utils/pathDecoder.ts — add translateWslMountPath() and call it in decodePath():

// After the dash-to-slash replacement in decodePath():
decodedPath = translateWslMountPath(decodedPath);

// New exported function:
export function translateWslMountPath(posixPath: string): string {
  if (process.platform !== 'win32') {
    return posixPath;
  }
  const wslMountRegex = /^\/mnt\/([a-zA-Z])(\/.*)?$/;
  const match = wslMountRegex.exec(posixPath);
  if (match) {
    const drive = match[1].toUpperCase();
    const rest = match[2] ?? '';
    return `${drive}:${rest}`;
  }
  return posixPath;
}

src/main/utils/metadataExtraction.ts — add a local translateWslPath() helper and apply it to the cwd r
eturned by extractCwd():

function translateWslPath(posixPath: string): string {
  if (process.platform !== 'win32') { return posixPath; }
  const match = /^\/mnt\/([a-zA-Z])(\/.*)?$/.exec(posixPath);
  if (match) { return `${match[1].toUpperCase()}:${match[2] ?? ''}`; }
  return posixPath;
}

// In extractCwd(), wrap the return:
return translateWslPath(entry.cwd);

Tests — 6 new test cases for translateWslMountPath with platform stubbing via vi.stubGlobal, plus a pass
through test confirming decodePath doesn't translate on non-Windows.

Thanks for the great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions