fix: preserve switch intent when ExitCodeError is caught in local launcher#974
Open
easyfan wants to merge 1 commit intoslopus:mainfrom
Open
fix: preserve switch intent when ExitCodeError is caught in local launcher#974easyfan wants to merge 1 commit intoslopus:mainfrom
easyfan wants to merge 1 commit intoslopus:mainfrom
Conversation
…ncher
When switching from local to remote mode (triggered from mobile), calling
doSwitch() sets exitReason = { type: 'switch' } and sends SIGTERM to the
claude PTY process. The process then exits with code 143, throwing an
ExitCodeError — which the catch block was unconditionally overwriting
exitReason with { type: 'exit', code: 143 }, causing the whole process
to terminate instead of transitioning to remote mode.
Fix: guard the ExitCodeError handler to only set exitReason when it hasn't
already been set. If exitReason is already set (e.g. due to doSwitch),
we break without overwriting — the SIGTERM exit code is expected and
should not be treated as an unexpected failure.
Fixes slopus#941
Diagnosed and fixed with Claude Code via Happy.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Contributor
|
Nice catch, merging — thanks @easyfan! if you ever have 15 min to show us how you use Happy (or what's annoying), would really help us figure out what to build next: https://calendar.app.google/pozvqGvveyKpVUFh9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #941.
When the user sends a message from the mobile app while in local (PTY) mode,
doSwitch()is called which:exitReason = { type: 'switch' }abort()The PTY process exits with code 143 (SIGTERM), throwing an
ExitCodeError. The catch block was unconditionally overwritingexitReasonwith{ type: 'exit', code: 143 }, so instead of transitioning to remote mode, the entire process terminated.Fix
Guard the
ExitCodeErrorhandler: ifexitReasonis already set (meaningdoSwitchordoAbortalready handled the intent), break without overwriting. The SIGTERM exit code in this case is expected — it's the result of us sending the signal ourselves.if (e instanceof ExitCodeError) { + if (exitReason) { + break; // preserve existing exit reason (e.g. switch intent) — SIGTERM is expected + } session.client.closeClaudeSessionTurn('failed'); exitReason = { type: 'exit', code: e.exitCode }; break; }Testing
Reproduced by running
happylocally, sending a message from the iOS app, and observing the process terminate instead of switching to remote mode. With this fix applied, the transition to remote mode completes correctly.Diagnosed and fixed with Claude Code via Happy.