Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(pane): list a live owner's pane as kept when only kill(pid, 0) vouches for it
Jack Rudenkof01a155ed881
diff --git a/packages/cli/src/pane/pane-registry.test.ts b/packages/cli/src/pane/pane-registry.test.tsindex d7c9cce2..ce1ca42b 100644--- a/packages/cli/src/pane/pane-registry.test.ts+++ b/packages/cli/src/pane/pane-registry.test.ts@@ -810,11 +810,23 @@ describe("with the process table unavailable (a sandbox refuses ps): owners judgconst rec = await ownerPane(t, "lv", "live");expect(await withProcessTableUnavailable(() => livePaneCount(t.sockRoot))).toBe(1);const r = await withProcessTableUnavailable(() => sweepOrphanPanes(t.sockRoot));- expect(r).toEqual({ reaped: [], cleaned: [], kept: [] });+ // alive by kill(pid, 0) alone is unverified, so the pane is listed as kept+ expect(r).toEqual({ reaped: [], cleaned: [], kept: [rec.paneId] });expect(readRecord(t.sockRoot, rec.paneId)).not.toBeNull();for (const p of filesOf(rec)) expect(existsSync(p)).toBe(true);});+ test("a record a sandboxed owner wrote (no ownerStart), swept later with a working ps: kept", async () => {+ // the owner could not read its lstart; its pane id still embeds its start time+ const t = env();+ const rec = await ownerPane(t, "sb", "live");+ updateRecord(t.sockRoot, rec.paneId, { ownerStart: "" });+ expect(await livePaneCount(t.sockRoot)).toBe(1);+ const r = await sweepOrphanPanes(t.sockRoot);+ expect(r).toEqual({ reaped: [], cleaned: [], kept: [] });+ for (const p of filesOf(rec)) expect(existsSync(p)).toBe(true);+ });+test("a dead owner whose magmux is gone: not counted, and the sweep removes its files", async () => {const t = env();const rec = await ownerPane(t, "dd", "dead");diff --git a/packages/cli/src/pane/pane-registry.ts b/packages/cli/src/pane/pane-registry.tsindex 83ed3244..a93a546d 100644--- a/packages/cli/src/pane/pane-registry.ts+++ b/packages/cli/src/pane/pane-registry.ts@@ -485,7 +485,10 @@ async function killVerified(rec: PaneRecord, root: string): Promise<SweepTargetsasync function sweepRecord(rec: PaneRecord, root: string, out: SweepResult): Promise<void> {const table = readProcessTable();- if (ownerAlive(rec, table)) return;+ if (ownerAlive(rec, table)) {+ if (!table) out.kept.push(rec.paneId); // alive by kill(pid, 0) alone: unverified+ return;+ }if (!table) {await sweepUnidentifiable(rec, root, out);return;diff --git a/packages/cli/src/pane/process-identity.test.ts b/packages/cli/src/pane/process-identity.test.tsindex 687220a3..f314ddf2 100644--- a/packages/cli/src/pane/process-identity.test.ts+++ b/packages/cli/src/pane/process-identity.test.ts@@ -412,7 +412,7 @@ describe("the process table when ps cannot run (macOS refuses the setuid ps in aconst modulePath = join(import.meta.dir, "process-identity.ts");const script =`import { readProcessTable, readProcessTableAsync } from ${JSON.stringify(modulePath)};\n` +- `const sync = readProcessTable();\n` ++ "const sync = readProcessTable();\n" +`void readProcessTableAsync().then((t) => { console.log(String(sync) + " " + String(t)); process.exit(0); });\n` +"setInterval(() => {}, 1000);\n" +`setTimeout(() => { console.log("timeout"); process.exit(3); }, 10000);\n`;