From 8ca35bce33ecb340399e05164d7f0015215352d5 Mon Sep 17 00:00:00 2001 From: wassname2 Date: Tue, 15 Sep 2026 17:37:57 +0800 Subject: [PATCH] Preserve worker binding through the existing solo transition --- src/index.ts | 4 +--- test/goals.test.ts | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 44c5270..879c7a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -697,9 +697,7 @@ export default function mainSupervisor(pi: ExtensionAPI) { } const noted = /^-\s*worker session:\s*(\S+)/im.exec(foldPlan(text))?.[1]; if (!(await confirmOwnership(ctx, target, text))) return; - const worker = noted ? { sessionFile: resolve(ctx.cwd, noted) } : state.workerStopped ? state.worker : undefined; - state = { mode: "solo", plan: target, worker, workerStopped: true }; - generation++; notice = true; fullPlanContextDue = true; save(); refresh(ctx); watchPlan(ctx); + if (noted && !state.worker) state.worker = { sessionFile: resolve(ctx.cwd, noted) }; enterSolo(ctx); return; } diff --git a/test/goals.test.ts b/test/goals.test.ts index 7275e47..a2cda24 100644 --- a/test/goals.test.ts +++ b/test/goals.test.ts @@ -665,7 +665,9 @@ it("external attach solo cannot turn a noted worker or stop checkbox into owners it("retains current solo authority and stopped-session reference when external adoption is blocked", async () => { const f = fixture(); await f.draft(); await f.command("ready"); await f.launch({ id: "child", sessionFile: "/tmp/prior.jsonl" }); - f.ctx.ui.select.mockResolvedValueOnce("Worker confirmed stopped"); await f.command("solo"); + const binding = f.entries.at(-1).data.worker; + f.ctx.ui.select.mockResolvedValueOnce("Worker confirmed stopped"); await f.command(`attach ${f.path} solo`); + expect(f.entries.at(-1).data.worker).toEqual(binding); const other = join(f.ctx.cwd, "another.md"); writeFileSync(other, "- [ ] goal: next\n## Log\n"); const before = f.entries.at(-1), messageCount = f.messages.length; f.ctx.ui.select.mockResolvedValueOnce("Previous supervisor confirmed stopped");