Skip to content

fix: enable terminal title control via change_title MCP tool#161

Open
michelhelsdingen wants to merge 2 commits intoslopus:mainfrom
michelhelsdingen:main
Open

fix: enable terminal title control via change_title MCP tool#161
michelhelsdingen wants to merge 2 commits intoslopus:mainfrom
michelhelsdingen:main

Conversation

@michelhelsdingen
Copy link

Summary

  • Add setTerminalTitle() function using OSC escape sequences to set iTerm2/Terminal.app window title when change_title MCP tool is invoked
  • Add CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1 env var to launcher to prevent Claude Code from overwriting the terminal title
  • change_title now updates both the terminal window title (for desktop) and the Happy server (for mobile app)

Context

The change_title MCP 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

  • Verified title appears in iTerm2 tab/window after change_title is called
  • Verified remote → local mode switch still works without stdin regression
  • Verified Happy mobile app still receives title updates

🤖 Generated with Claude Code
via Happy

michelhelsdingen and others added 2 commits February 6, 2026 13:50
…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>
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.

1 participant