Skip to content

fix(server): treat signal-killed Claude subprocess as interrupted - #5142

Open
marcoamt wants to merge 1 commit into
pingdotgg:mainfrom
marcoamt:fix/claude-shutdown-runtime-error
Open

fix(server): treat signal-killed Claude subprocess as interrupted#5142
marcoamt wants to merge 1 commit into
pingdotgg:mainfrom
marcoamt:fix/claude-shutdown-runtime-error

Conversation

@marcoamt

@marcoamt marcoamt commented Jul 31, 2026

Copy link
Copy Markdown

What Changed

ClaudeAdapter now recognizes "terminated by signal SIGTERM/SIGINT" messages from the Claude Agent SDK's ProcessTransport as a graceful interruption instead of surfacing a runtime.error. Added a regression test asserting no runtime.error is emitted and the turn completes with state interrupted.

Why

When the OS delivers SIGTERM/SIGINT directly to the Claude subprocess (e.g. on desktop app quit) ahead of our own stopSession()-driven close, the SDK's error message for the signal-killed process was being treated as a runtime error instead of a normal interruption.

UI Changes

When Cmd+Q app and reopen a Claude Code thread it looks like screenshot

Screenshot 2026-07-31 alle 22 56 46

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Open in Devin Review

Note

Fix isClaudeInterruptedMessage to treat SIGTERM/SIGINT-killed subprocesses as interrupted

When the Claude CLI subprocess is killed by SIGTERM or SIGINT before stopSession() completes, the Claude Agent SDK surfaces an error message containing 'terminated by signal sigterm' or 'terminated by signal sigint'. Previously these were treated as runtime errors; now isClaudeInterruptedMessage matches these substrings and returns interrupted state instead.

Macroscope summarized e6c7331.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 02ac6546-f416-40d8-853d-97d2cf9fe9ea

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 31, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 8f898ff

Straightforward bug fix that adds two string patterns to an existing pattern-matching function. The change correctly classifies SIGTERM/SIGINT subprocess terminations as 'interrupted' rather than runtime errors, following the same pattern already used for similar cases. Includes comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

- ClaudeAdapter now recognizes "terminated by signal SIGTERM/SIGINT" from the Claude Agent SDK's ProcessTransport as a graceful interruption instead of surfacing a runtime.error
- Covers the case where the OS delivers the signal directly to the subprocess (e.g. desktop app quit) ahead of our own stopSession()-driven close
- Add regression test asserting no runtime.error is emitted and the turn completes with state "interrupted"
@marcoamt
marcoamt force-pushed the fix/claude-shutdown-runtime-error branch from 8f898ff to e6c7331 Compare July 31, 2026 20:43
@marcoamt marcoamt changed the title {"title": "fix(server): treat signal-killed Claude subprocess as interrupted", "body": "placeholder"} fix(server): treat signal-killed Claude subprocess as interrupted Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant