fix(acp): stop cancelled steps while reading the opening screen

Merged
JX
27m ago
+50-1

What and why

  • A cancelled ACP step no longer waits for its opening screen. runStep races the screen read against the step signal with the existing untilAborted helper, so it rejects with the step's original reason while ctx.observe is still pending (packages/acp/src/executor.ts:77).
  • runStep checks the signal before it starts the screen read (packages/acp/src/executor.ts:75), so a step aborted after the previous turn settles never calls observe.
  • The cancelled step sends no prompt, and the session stays held for the next step.
  • The previous-turn wait from #1761 is unchanged. The runner's outer deadline is unchanged too; this changes when the executor promise settles, and does not stop an engine operation that ignores its own cancellation.

Issue

Fixes #1765

Verified

Ran it locally: yes

  • pnpm --filter @e2e-dev/acp exec vitest run tests/executor.test.ts, with packages/acp/src/executor.ts from main and then from this branch, on Node v24.22.2 and main 0a5ee163:
mainthis branch
× ends a cancelled step without waiting for its opening screen: runStep has not rejected 1 s after the abort (Number of calls: 0)passes: rejects with the same STEP_TIMEOUT object, one session, one prompt for the cancelled pair, then the next step passes on the same session
1 failed, 38 passed39 passed
  • does not read the screen for an already-aborted step passes on main as well: since #1761, ready() rejects first for a step aborted before runStep. It pins the contract that observe is never called; it does not isolate the pre-check, which guards an abort that lands after the previous turn settles.

  • Earlier standalone reproduction against the published @e2e-dev/acp@0.1.2 (scripted ACP agent, held observation, no model account): main stays pending until the screen is released; the fix rejects with the identical reason (stoppedBeforeScreenRelease=true sameReason=true, sessions=1 prompts=2).

  • Not run: a live ACP agent (Claude Code or Codex) on the testbed, which needs a model account.

  • Local validation of the reviewed content: pnpm build, pnpm check, pnpm test and ACP typecheck passed; all 50 ACP tests passed. CI on the updated PR head must be checked separately.