Skip to content

Addressing PR comments#34

Draft
Codex wants to merge 2 commits intomasterfrom
codex/fix-wsl-import-issue
Draft

Addressing PR comments#34
Codex wants to merge 2 commits intomasterfrom
codex/fix-wsl-import-issue

Conversation

@Codex
Copy link

@Codex Codex AI commented Mar 16, 2026

Original prompt

This section details on the original issue you should resolve

<issue_title>WSL support: Cannot import Claude Code sessions from WSL filesystem</issue_title>
<issue_description>## Problem

When running Harnss on Windows with Claude Code installed inside WSL, the "Resume CC Chat" feature shows "No Claude Code sessions found" because session JSONL files are stored in the WSL filesystem (~/.claude/projects/ inside WSL), not on the Windows filesystem.

Root cause

cc-import.ts:getCCProjectDir() constructs the session path using os.homedir() (Windows home) + project path hash. But when the project lives in WSL:

  1. Sessions are at \\wsl$\Ubuntu\home\user\.claude\projects\-home-user\
  2. Harnss looks at C:\Users\user\.claude\projects\... — wrong location
  3. The path hash also differs: WSL project /home/user hashes to -home-user, but Windows path \\wsl$\Ubuntu\home\user would hash differently

Additional issue: Claude binary resolution

claude-binary.ts uses where claude on Windows, which won't find Claude installed inside WSL (~/.local/bin/claude). A WSL fallback (wsl.exe -e which claude) would enable live sessions.

Environment

  • Windows 11 + WSL2 (Ubuntu 24.04)
  • Harnss v0.20.0
  • Claude Code installed in WSL only
  • 752 session JSONL files in ~/.claude/projects/-home-user/

Proposed fix

1. Session import (cc-import.ts)

Detect WSL project paths (\\wsl$\ or \\wsl.localhost\) and resolve the .claude directory from the WSL user's home:

function getCCProjectDir(projectPath: string): string {
  const normalized = projectPath.replace(/\\/g, "/");
  
  // Detect WSL paths: //wsl$/Distro/... or //wsl.localhost/Distro/...
  const wslMatch = normalized.match(/^\/\/wsl(?:\.localhost|\$)\/([^/]+)(\/.*)/i);
  if (wslMatch && process.platform === "win32") {
    const distro = wslMatch[1];
    const wslAbsPath = wslMatch[2];
    const hash = wslAbsPath.replace(/\//g, "-");
    const homeMatch = wslAbsPath.match(/^(\/home\/[^/]+)/);
    const wslHome = homeMatch ? homeMatch[1] : "/root";
    const wslPrefix = `\\\\wsl.localhost\\${distro}`;
    return path.join(wslPrefix, wslHome.replace(/\//g, "\\"), ".claude", "projects", hash);
  }

  const hash = projectPath.replace(/\//g, "-");
  return path.join(os.homedir(), ".claude", "projects", hash);
}

2. Binary resolution (claude-binary.ts)

Add WSL fallback to the resolution chain:

function resolveFromWsl(): ClaudeBinaryResolution | null {
  if (process.platform \!== "win32") return null;
  try {
    const output = execFileSync("wsl.exe", ["-e", "which", "claude"], {
      encoding: "utf-8", timeout: 10000, windowsHide: true,
    }).trim();
    if (output && output.startsWith("/")) {
      return { strategy: "wsl", path: `wsl:${output}` };
    }
    return null;
  } catch { return null; }
}

Then create a .cmd wrapper (wsl.exe -e /path/to/claude %*) that the SDK can spawn.

3. CWD translation

When spawning Claude for a WSL project, translate the CWD:
\\wsl.localhost\Ubuntu\home\user\project/home/user/project

Full patch

I have a working 168-line patch across 3 files. Happy to open a PR if there's interest.</issue_description>

<agent_instructions>Use instructions from the issue and implement proper WSL support.</agent_instructions>

Comments on the Issue (you are @codex[agent] in this section)

@OpenSource03 > I have a working 168-line patch across 3 files. Happy to open a PR if there's interest.

I can fix it, but If you have a fix ready, please feel free to open the PR :)</comment_new>

@Codex Codex AI changed the title [WIP] Fix WSL support for importing Claude Code sessions Add WSL-aware CC session import and Claude binary resolution Mar 16, 2026
@Codex Codex AI requested a review from OpenSource03 March 16, 2026 02:41
@OpenSource03
Copy link
Owner

@codex[agent] make sure there is option in our settings to configure preferred Claude executable.

@chatgpt-codex-connector
Copy link

To use Codex here, create an environment for this repo.

@Codex
Copy link
Author

Codex AI commented Mar 16, 2026

@codex[agent] make sure there is option in our settings to configure preferred Claude executable.

There’s already a Claude executable picker in Settings → Engines: set “Claude binary source” to Custom and enter the path in the “Custom Claude path” field (present in current build, commit e8652e6).

@Codex Codex AI changed the title Add WSL-aware CC session import and Claude binary resolution Addressing PR comments Mar 16, 2026
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.

WSL support: Cannot import Claude Code sessions from WSL filesystem

2 participants