Skip to content

fix: persist explicit goal cancellation across OpenCode lifecycles - #64

Merged
danyel117 merged 2 commits into
mainfrom
codex/goal-acp-cancellation
Oct 5, 2026
Merged

danyel117 merged 2 commits into
mainfrom
codex/goal-acp-cancellation

Conversation

@danyel117

@danyel117 danyel117 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

When OpenCode aborts a goal from an ACP client, the plugin can leave the goal active: V1 starts another continuation on the following idle, and V2 can restart it after an unrelated prompt or reload. Persist explicit user cancellation through an atomic active-only state mutation, invalidate continuation preparation and late results, and check goal/attempt ownership again immediately before delivery.

V1 recognizes the named session/assistant MessageAbortedError; V2 recognizes session.execution.interrupted with reason user. Paused and limited goals are preserved when an unrelated manual turn is cancelled; explicit goal stop still closes them. V2 shutdown, superseded and other interruptions retain their existing temporary suppression behavior. Ordinary error text is not treated as cancellation, and another location's events cannot cancel the owner's goal. Explicit new goals remain usable in the same session.

Related to #59. This is the cancellation delivery; it does not close the broader ACP synchronization and phase-planning report.

Validation:

  • GitHub CI passed all five checks on final head aa99843: lint, typecheck, build, 334 tests with coverage, and V2 lifecycle smoke. Run: https://github.com/prevalentWare/opencode-goal-plugin/actions/runs/37315558294
  • Independent Opus review (opencode/claude-opus-5-5) returned APPROVE on aa99843 after the paused/limited-goal finding was fixed. Review session: ses_ef3c9c41affewThQww1HjYtqiu. No blocking findings remain.
  • Full local gate passed: lint, typecheck, 334 tests / 1369 expectations, build, pack dry run and diff check. The tarball includes the rebuilt server and required TUI files.
  • The cancellation regressions failed before the fix and pass afterward, including persistence/reload, late recovery rejection, replacement, auto-continue disabled and location ownership. Opus identified cancellation of paused/limited goals; all 12 added V1/V2 regressions failed before correction and pass afterward. A queued-pause regression verifies the active-only status check is atomic; explicit stop still closes paused goals.
  • Native OpenCode 2.0.21 ACP smoke on macOS, using isolated configuration/state and a deterministic local provider: cancel during a foreground Python worker returned stopReason: cancelled, terminated the worker, persisted cancelled, and produced zero automatic continuations after cancellation or an unrelated prompt. The same smoke against the base revision failed because cancellation was not persisted.
  • A second native ACP fixture confirmed normal automatic continuation still completes a goal (status: complete, autoTurns: 1).

Remaining boundaries:

  • A registered /goal ACP request in OpenCode 2.0.21 returned end_turn while its submitted execution was still running. The host's command-action response/stream handling needs a separate fix; this plugin cannot keep that ACP request open or emit host ACP plan updates.
  • Structured phase/task persistence is follow-up work. No Zed GUI or Windows acceptance is claimed, and no new timeout is introduced.
  • The repository's older smoke:v2 script is incompatible with the installed 2.0.21 API (/api/plugin/await-activation returns 404); the native ACP fixtures above were used instead. CI and the existing script are unchanged.

Rollback: revert this PR as one behavior unit, including the source, generated server, regression tests and README behavior together. No persistence format or existing public state API changed.

@danyel117
danyel117 marked this pull request as ready for review October 5, 2026 13:19
@danyel117
danyel117 merged commit eb978c6 into main Oct 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant