fix(acp): stop cancelled steps while reading the opening screen
What and why
- A cancelled ACP step no longer waits for its opening screen.
runStepraces the screen read against the step signal with the existinguntilAbortedhelper, so it rejects with the step's original reason whilectx.observeis still pending (packages/acp/src/executor.ts:77). runStepchecks the signal before it starts the screen read (packages/acp/src/executor.ts:75), so a step aborted after the previous turn settles never callsobserve.- 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, withpackages/acp/src/executor.tsfrom main and then from this branch, on Node v24.22.2 and main0a5ee163:
| main | this 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 passed | 39 passed |
-
does not read the screen for an already-aborted steppasses on main as well: since #1761,ready()rejects first for a step aborted beforerunStep. It pins the contract thatobserveis 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 testand ACP typecheck passed; all 50 ACP tests passed. CI on the updated PR head must be checked separately.