Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(mcp): resolve CLAUDISH_PANE_ROOT before comparing pane paths to it
Jack Rudenko8f6ff7ebf159
diff --git a/packages/cli/src/pane/pane-launch.test.ts b/packages/cli/src/pane/pane-launch.test.tsindex 67db6b97..6275f5bd 100644--- a/packages/cli/src/pane/pane-launch.test.ts+++ b/packages/cli/src/pane/pane-launch.test.ts@@ -11,6 +11,7 @@ import {SHELL_SHIM,buildClaudishPaneArgv,buildPaneEnv,+ createLaunchDirs,ensureSockRoot,isValidPaneId,launcherScript,@@ -20,7 +21,7 @@ import {sockRootFor,versionAtLeast,} from "./pane-launch.js";-import { WATCHER_ARGV0, WATCHER_SCRIPT, watcherArgv } from "./process-identity.js";+import { WATCHER_ARGV0, WATCHER_SCRIPT, isLaunchDirPath, watcherArgv } from "./process-identity.js";const dirs: string[] = [];afterEach(() => {@@ -219,6 +220,16 @@ describe("ids, socket paths and the socket root", () => {expect(sockRootFor({})).toMatch(/^\/tmp\/claudish-mux-\d+$/);});+ test("a trailing-slash or relative root is resolved once, so the launch-dir check still matches", () => {+ expect(sockRootFor({ CLAUDISH_PANE_ROOT: "/tmp/cpt-1/" })).toBe("/tmp/cpt-1");+ expect(sockRootFor({ CLAUDISH_PANE_ROOT: "rel/root" })).toBe(join(process.cwd(), "rel/root"));+ const base = tmp();+ const root = ensureSockRoot(`${join(base, "r")}/`);+ expect(root).toBe(join(base, "r"));+ const dirs = createLaunchDirs(root);+ expect(isLaunchDirPath(root, dirs.ctlDir)).toBe(true);+ });+test("ensureSockRoot creates 0700 dirs and refuses a symlink or a group/world-readable dir", () => {const base = tmp();const root = join(base, "root");diff --git a/packages/cli/src/pane/pane-launch.ts b/packages/cli/src/pane/pane-launch.tsindex fc0cfe09..c0fd82ae 100644--- a/packages/cli/src/pane/pane-launch.ts+++ b/packages/cli/src/pane/pane-launch.ts@@ -18,7 +18,7 @@import { type ChildProcess, execFileSync, spawn } from "node:child_process";import { randomBytes } from "node:crypto";import { chmodSync, lstatSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";-import { join } from "node:path";+import { join, resolve } from "node:path";import { CLAUDISH_EXITING_FLAGS, CLAUDISH_FLAG_ARITY, classifyPassthroughTokens } from "../cli.js";import { ENV } from "../config.js";import { findMagmuxBinaryOrNull } from "../launcher/magmux-binary.js";@@ -39,7 +39,9 @@ function uid(): number {*/export function sockRootFor(env: Record<string, string | undefined> = process.env): string {const override = env[ENV.CLAUDISH_PANE_ROOT]?.trim();- return override ? override : `/tmp/claudish-mux-${uid()}`;+ // resolved once: every path check compares against this exact spelling, and the+ // watcher's shell globs ("$ROOT"/launch-??????) never match `/x/` or `./x`+ return override ? resolve(override) : `/tmp/claudish-mux-${uid()}`;}/** The default socket root of this process. */@@ -62,7 +64,8 @@ function assertPrivateDir(p: string): void {}/** Create (0700) and verify the socket root and its `panes/` record dir. Returns `root`. */-export function ensureSockRoot(root: string = sockRootFor()): string {+export function ensureSockRoot(given: string = sockRootFor()): string {+ const root = resolve(given);try {mkdirSync(root, { mode: 0o700 });} catch (e) {