mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-13 19:51:24 +08:00
feat(desktop-notify): route OSC 9 notifications through Ghostty (#2114)
Ghostty natively supports the OSC 9 desktop-notification escape (ESC ] 9 ; <message> BEL), the same sequence already used for iTerm2. Previously only TERM_PROGRAM === 'iTerm.app' took the escape path, so Ghostty users fell through to the osascript path. That makes Script Editor the notification owner, and clicking the notification just launches Script Editor instead of focusing the terminal. Adding 'ghostty' to the OSC 9-capable check makes Ghostty the owner, so clicking the notification focuses the Ghostty window/tab where Claude Code is running. Verified on Ghostty (TERM_PROGRAM=ghostty). Co-authored-by: 高野智史 <satoshitakano@takanosatoshinoMacBook-Pro-522.local> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
4197ea545f
commit
80c63c88f0
@@ -154,20 +154,25 @@ function isUnderMultiplexer() {
|
|||||||
/**
|
/**
|
||||||
* Send a macOS notification.
|
* Send a macOS notification.
|
||||||
*
|
*
|
||||||
* On iTerm2 (and not inside tmux/screen), prefers the native escape sequence
|
* On terminals that support the OSC 9 notification sequence (iTerm2 and
|
||||||
* (ESC ] 9 ; <message> BEL) written to the parent terminal's tty. This makes
|
* Ghostty), and when not inside tmux/screen, prefers the native escape
|
||||||
* iTerm2 the notification owner, so clicking the notification focuses the
|
* sequence (ESC ] 9 ; <message> BEL) written to the parent terminal's tty.
|
||||||
* exact iTerm2 tab where Claude Code is running. The default osascript path
|
* This makes the terminal the notification owner, so clicking the
|
||||||
* makes Script Editor the owner instead, which causes clicks to launch
|
* notification focuses the exact tab/window where Claude Code is running.
|
||||||
* Script Editor.
|
* The default osascript path makes Script Editor the owner instead, which
|
||||||
|
* causes clicks to launch Script Editor.
|
||||||
*
|
*
|
||||||
* Falls back to osascript when not running under iTerm2, when tty discovery
|
* Falls back to osascript when not running under an OSC 9-capable terminal,
|
||||||
* fails, or when running inside a multiplexer that would swallow OSC 9.
|
* when tty discovery fails, or when running inside a multiplexer that would
|
||||||
|
* swallow OSC 9.
|
||||||
* AppleScript strings do not support backslash escapes, so we replace double
|
* AppleScript strings do not support backslash escapes, so we replace double
|
||||||
* quotes with curly quotes and strip backslashes before embedding.
|
* quotes with curly quotes and strip backslashes before embedding.
|
||||||
*/
|
*/
|
||||||
function notifyMacOS(title, body) {
|
function notifyMacOS(title, body) {
|
||||||
if (process.env.TERM_PROGRAM === 'iTerm.app' && !isUnderMultiplexer()) {
|
const osc9Capable =
|
||||||
|
process.env.TERM_PROGRAM === 'iTerm.app' ||
|
||||||
|
process.env.TERM_PROGRAM === 'ghostty';
|
||||||
|
if (osc9Capable && !isUnderMultiplexer()) {
|
||||||
try {
|
try {
|
||||||
const tty = findTerminalTTY();
|
const tty = findTerminalTTY();
|
||||||
if (tty) {
|
if (tty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user