-
Notifications
You must be signed in to change notification settings - Fork 235
Open
Description
When switching from local mode to remote mode (or vice versa), the terminal flickers between two states and. Keystrokes are sometimes captured by one mode, sometimes by the other, making the session unusable.
Environment
- happy-coder: 0.13.0
- Claude Code: 2.1.1 (installed via homebrew)
- Node.js: v24.12.0
- macOS: 15.1 (Darwin 25.1.0)
- Terminal: iTerm2
I am not sure whether maybe I am just holding it wrong.
It seems that two processes are competing for the input/output.
Either way, the following local fix seems to solve the issue
diff --git a/scripts/claude_version_utils.cjs b/scripts/claude_version_utils.cjs
index 2184917..1a6b638 100644
--- a/scripts/claude_version_utils.cjs
+++ b/scripts/claude_version_utils.cjs
@@ -497,6 +497,18 @@ function runClaudeCli(cliPath) {
stdio: 'inherit',
env: process.env
});
+
+ // Forward signals to child process so it gets killed when parent is killed
+ // This prevents orphaned Claude processes when switching between local/remote modes
+ const forwardSignal = (signal) => {
+ if (child.pid && !child.killed) {
+ child.kill(signal);
+ }
+ };
+ process.on('SIGTERM', () => forwardSignal('SIGTERM'));
+ process.on('SIGINT', () => forwardSignal('SIGINT'));
+ process.on('SIGHUP', () => forwardSignal('SIGHUP'));
+
child.on('exit', (code) => {
process.exit(code || 0);
});
In case it is not just a me-problem I am happy to create a PR.
Metadata
Metadata
Assignees
Labels
No labels