fix(acp): finish prompt turn when extension/custom command is handled locally

Extension commands (e.g. /sonnet) and TypeScript custom commands that
consume the input without calling the LLM return early from
session.prompt() with no agent turn. In ACP mode this left the pending
prompt promise unresolved, hanging the client forever.

Change session.prompt() to return Promise<boolean>: true when the LLM
was invoked, false when the command was fully handled locally.
#runPromptOrCommand calls #finishPrompt immediately on a false return so
the ACP turn completes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Theo Mathieu
2026-06-07 20:37:21 +02:00
committed by can1357
parent b0063a08f0
commit 416c9947bd
6 changed files with 28 additions and 12 deletions
@@ -21,7 +21,7 @@ describe("submitInteractiveInput", () => {
checkShutdownRequested: vi.fn(async () => {}),
};
const session = {
prompt: vi.fn(async () => {}),
prompt: vi.fn(async () => true),
promptCustomMessage: vi.fn(async () => {}),
};
const input = createInput({ text: "resume now", started: true, synthetic: true });
@@ -42,7 +42,7 @@ describe("submitInteractiveInput", () => {
checkShutdownRequested: vi.fn(async () => {}),
};
const session = {
prompt: vi.fn(async () => {}),
prompt: vi.fn(async () => true),
promptCustomMessage: vi.fn(async () => {}),
};
const input = createInput();
@@ -63,7 +63,7 @@ describe("submitInteractiveInput", () => {
checkShutdownRequested: vi.fn(async () => {}),
};
const session = {
prompt: vi.fn(async () => {}),
prompt: vi.fn(async () => true),
promptCustomMessage: vi.fn(async () => {}),
};
const input = createInput({ text: "continue goal", customType: "goal-continuation" });