fix: enable terminal title control via change_title MCP tool#161
Open
michelhelsdingen wants to merge 2 commits intoslopus:mainfrom
Open
fix: enable terminal title control via change_title MCP tool#161michelhelsdingen wants to merge 2 commits intoslopus:mainfrom
michelhelsdingen wants to merge 2 commits intoslopus:mainfrom
Conversation
…us#11) ## THE FIX Forward SIGTERM, SIGINT, SIGHUP to child Claude CLI process. This ensures child processes are killed when parent is terminated. ## ROOT CAUSE When switching between local/remote modes, the parent process was killed but child Claude CLI processes remained alive ("orphaned"). These orphaned processes continued to hold stdin, causing: - Duplicate/garbled characters when typing - "Competing processes" fighting for terminal input ## SOLUTION (from GitHub slopus/happy#430) ```javascript 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')); ``` ## FILES CHANGED - scripts/claude_version_utils.cjs - binary launcher signal forwarding - src/claude/claudeLocal.ts - TypeScript launcher signal forwarding ## TESTED ✅ Fresh local mode - typing works ✅ Switch to remote mode - typing works ✅ Switch back to local mode - typing works (was broken) ✅ Multiple mode switches - stable ## IMPORTANT This is the ONLY fix needed. No stdin cleanup, no removeAllListeners(), no setRawMode changes required. Signal forwarding alone solves it. Closes slopus#11 References: slopus/happy#430, PR slopus#127 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
Re-apply terminal title feature (originally df7262c) that was lost when upstream main diverged. Sets iTerm2/Terminal.app window title via OSC escape sequences when change_title is invoked. - Add CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1 to launcher to prevent Claude Code from overwriting the terminal title - Add setTerminalTitle() using OSC 0 escape sequence for direct window title control - change_title now sets both terminal title and Happy app title Tested: title updates work in iTerm2, remote→local mode switch still functions correctly (no stdin regression). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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.
Summary
setTerminalTitle()function using OSC escape sequences to set iTerm2/Terminal.app window title whenchange_titleMCP tool is invokedCLAUDE_CODE_DISABLE_TERMINAL_TITLE=1env var to launcher to prevent Claude Code from overwriting the terminal titlechange_titlenow updates both the terminal window title (for desktop) and the Happy server (for mobile app)Context
The
change_titleMCP tool currently only sends the title to the Happy server for the mobile app. Desktop users (iTerm2, Terminal.app) don't see the title reflected in their terminal tabs/windows. This makes it hard to distinguish between multiple Happy sessions.This fix uses standard OSC 0 escape sequences (
\x1b]0;title\x07) which work with iTerm2, Terminal.app, and most modern terminal emulators.Test plan
change_titleis called🤖 Generated with Claude Code
via Happy