Skip to content

fix(opencode): report shell signal exits without waiting for timeout - #59956

Open
KalininVD wants to merge 5 commits into
anomalyco:v1from
KalininVD:shell-signal-exit
Open

KalininVD wants to merge 5 commits into
anomalyco:v1from
KalininVD:shell-signal-exit

Conversation

@KalininVD

@KalininVD KalininVD commented Oct 28, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #59925

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On v1, kill -TERM $$ in the Bash tool waits for the configured timeout and can then report ChildProcess.kill. The spawner fails exitCode on signal termination, but Effect.raceAll keeps waiting for a successful result.

Convert that failure into a completed race result, report the signal alongside captured output, and include it in the final TUI output metadata. Keep exit: null for signal termination and preserve the existing timeout and abort paths.

The issue does not reproduce in v2.2.0. No code was ported from v2.2.0 because its Shell API uses different contracts.

How did you verify your code works?

Linux, Bun 1.4.4; Node 24.15.0 for the full package suite. From packages/opencode:

  • bun typecheck passed.
  • bun test --timeout 30000 test/tool/shell.test.ts test/cli/run/run-process.test.ts: 40 passed, including signals, timeout, abort, output capture, and CLI continuation.
  • The three new SIGTERM/SIGSEGV/SIGKILL tests fail with upstream shell.ts and pass with this fix.
  • bun run test: 3647 passed, 22 skipped, 1 todo, 3 failed. Both worktree timeouts and the file-permissions failure also reproduce with upstream shell.ts. The permissions test passes with umask 0022 instead of the host's 0002.
  • bun run script/build.ts --single --skip-install --skip-embed-web-ui and its --version smoke passed in a temporary source copy.
  • Manually tested the compiled Linux binary in the interactive TUI with a real model, comparing stock 1.19.5 with this build. Verified SIGTERM handling, timeout and user cancellation with and without command output, and an ordinary non-zero exit.

Windows/macOS and browser e2e were not run locally.

Screenshots / recordings

Manually verified the signal message and shell metadata rendering in the interactive TUI. No screenshot or recording attached.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

opencode and others added 5 commits October 28, 2026 06:17
Exercise SIGTERM, SIGSEGV and SIGKILL with real shell processes, preserving stdout/stderr and requiring a result before the command timeout. These regression tests currently fail because signal exits are ignored by the success-only race.
Treat a failed exitCode effect as a terminal outcome before racing it against timeout and cancellation. Preserve captured output and the termination cause instead of trying to kill an already-exited process.

Add a subprocess CLI regression proving that JSON tool output contains the signal and the session can continue. Fixes anomalyco#59925.
@Antonio-Faure

Copy link
Copy Markdown

Flagging for triage: the linked issue #59925 was closed as not planned because v1 only receives critical fixes. This PR only touches packages/opencode (v1), and the reporter confirmed the behaviour does not reproduce on v2.2.0. Closing this and reopening only if v2 reproduces may be the cleaner path.

This branch has not been deployed

No deployments
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.

2 participants