Preserve worker correlation on stock version preflight rejection

This commit is contained in:
wassname2
2026-09-21 11:59:05 +08:00
parent 46577f9cd9
commit 87a9b72680
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -923,7 +923,7 @@ export default function mainSupervisor(pi: ExtensionAPI) {
// Stock open sends startup only to a newly created context; existing panes receive nothing.
const pane = await openProjectPane({ cwd: ctx.cwd, message: workerAssignment(plan, self[0].id, requestId, params.task, model), focus: false, signal });
// Stock v1 emits these codes only before pane split/run. Other errors may follow a partial open.
const unopened = !pane.ok && ["INVALID_PROJECT_ROOT", "INVALID_BINDING", "BINDING_READ_FAILED", "PANE_OWNERSHIP_UNVERIFIED"].includes(pane.error.code);
const unopened = !pane.ok && ["INVALID_PROJECT_ROOT", "HERDR_UNSUPPORTED_VERSION", "INVALID_BINDING", "BINDING_READ_FAILED", "PANE_OWNERSHIP_UNVERIFIED"].includes(pane.error.code);
if ((pane.ok || unopened) && state.plan === plan && state.worker?.requestId === requestId) {
if (unopened || pane.ok && pane.data.disposition === "already-open" && superseded) {
state.worker = superseded; state.workerStopped = previouslyStopped;
+3
View File
@@ -1355,6 +1355,9 @@ it("retains worker history and report routing after definite pre-open failure, n
const reply = await tool.execute("failed", { task: "Proposed replacement" }, undefined, undefined, f.ctx);
expect(reply.content[0].text).toContain("INVALID_PROJECT_ROOT");
expect(f.entries.at(-1).data.worker).toEqual(previous);
vi.mocked(openProjectPane).mockResolvedValueOnce({ ok: false, error: { code: "HERDR_UNSUPPORTED_VERSION", message: "Stock version preflight rejected" } });
await tool.execute("preflight", { task: "Proposed replacement" }, undefined, undefined, f.ctx);
expect(f.entries.at(-1).data.worker).toEqual(previous);
const view = await f.tools.get("worker_view").execute("view", {}, undefined, undefined, f.ctx);
expect(view.content[0].text).toContain("Existing approved work");
f.event({ type: "message", fromSessionId: "old-worker", payload: { type: "stopped", to: previous.parentId, requestId: previous.requestId, plan: f.path, entryId: "still-routed", kind: "blocker", text: "Original worker reports a failure" } });