()
| 266 | } |
| 267 | |
| 268 | async function doInitialize(): Promise<void> { |
| 269 | const socket = getClaudeSocketName() |
| 270 | |
| 271 | // Create a new session with our custom socket |
| 272 | // Pass CLAUDE_CODE_SKIP_PROMPT_HISTORY via -e so it's set in the initial shell environment |
| 273 | // |
| 274 | // On Windows, the tmux server inherits WSL_INTEROP from the short-lived |
| 275 | // wsl.exe that spawns it; once `new-session -d` detaches and wsl.exe exits, |
| 276 | // that socket stops servicing requests. Any cli.exe launched inside the pane |
| 277 | // then hits `UtilAcceptVsock: accept4 failed 110` (ETIMEDOUT). Observed on |
| 278 | // 2026-03-25: server PID 386 (started alongside /init at WSL boot) inherited |
| 279 | // /run/WSL/383_interop — init's own socket, which listens but doesn't handle |
| 280 | // interop. /run/WSL/1_interop is a stable symlink WSL maintains to the real |
| 281 | // handler; pin the server to it so interop survives the spawning wsl.exe. |
| 282 | const result = await execTmux([ |
| 283 | '-L', |
| 284 | socket, |
| 285 | 'new-session', |
| 286 | '-d', |
| 287 | '-s', |
| 288 | 'base', |
| 289 | '-e', |
| 290 | 'CLAUDE_CODE_SKIP_PROMPT_HISTORY=true', |
| 291 | ...(getPlatform() === 'windows' |
| 292 | ? ['-e', 'WSL_INTEROP=/run/WSL/1_interop'] |
| 293 | : []), |
| 294 | ]) |
| 295 | |
| 296 | if (result.code !== 0) { |
| 297 | // Session might already exist from a previous run with same PID (unlikely but possible) |
| 298 | // Check if the session exists |
| 299 | const checkResult = await execTmux([ |
| 300 | '-L', |
| 301 | socket, |
| 302 | 'has-session', |
| 303 | '-t', |
| 304 | 'base', |
| 305 | ]) |
| 306 | if (checkResult.code !== 0) { |
| 307 | throw new Error( |
| 308 | `Failed to create tmux session on socket ${socket}: ${result.stderr}`, |
| 309 | ) |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // Register cleanup to kill the tmux server on exit |
| 314 | registerCleanup(killTmuxServer) |
| 315 | |
| 316 | // Set CLAUDE_CODE_SKIP_PROMPT_HISTORY in the tmux GLOBAL environment (-g). |
| 317 | // Without -g this would only apply to the 'base' session, and new sessions |
| 318 | // created by TungstenTool (e.g. 'test', 'verify') would not inherit it. |
| 319 | // Any Claude Code instance spawned on this socket will inherit this env var, |
| 320 | // preventing test/verification sessions from polluting the user's real |
| 321 | // command history and --resume session list. |
| 322 | await execTmux([ |
| 323 | '-L', |
| 324 | socket, |
| 325 | 'set-environment', |
no test coverage detected