Skip to content

macOS notifications show as 'Script Editor' instead of terminal app — no click-to-focus #23446

@dexion

Description

@dexion

Problem

On macOS, desktop notifications from OpenCode appear to come from "Script Editor" (AppleScript) instead of the terminal emulator (iTerm2, Terminal.app, etc.). Clicking the notification opens Script Editor instead of focusing the correct terminal tab.

This happens because OpenCode uses osascript -e 'display notification...' as a fallback, and macOS attributes the notification to the osascript process (Script Editor) rather than the terminal.

Expected Behavior

  • Notifications should be attributed to the terminal emulator (iTerm2, Terminal.app, etc.)
  • Clicking a notification should focus the correct terminal tab/window
  • On iTerm2 specifically, notifications should use OSC 9 escape sequences for native integration

Current State

I found PR #23212 (feat(tui): add terminal notifications by @kitlangton) which addresses this by adding:

  • OSC 9 escape sequences (\x1b]9;message\x07) for iTerm2, Ghostty, Apple Terminal, Warp
  • OSC 777 for Kitty, WezTerm, VTE-based terminals
  • Bell (\x07) as fallback
  • Auto-detection based on TERM_PROGRAM

However, this PR is:

  • Draft status
  • Has merge conflicts
  • Open since April 18

Suggested Fix

The notification resolution logic from PR #23212 looks correct:

// For iTerm2
if (env.TERM_PROGRAM === "iTerm.app") return "osc9"  // \x1b]9;title:body\x07

// For Kitty/WezTerm
if (env.KITTY_WINDOW_ID || env.TERM === "xterm-kitty") return "osc777"  // \x1b]777;notify;title;body\x07

// Fallback
return "bell"  // \x07

Additionally, for terminals that don't support OSC sequences, consider using terminal-notifier with -activate <bundle-id>:

  • iTerm2: com.googlecode.iterm2
  • Terminal.app: com.apple.Terminal
  • Warp: dev.warp.Warp-Stable

⚠️ Do NOT use -sender flag — it conflicts with -activate on macOS Sequoia 15.x+ and breaks click-to-focus.

Environment

  • macOS (Sequoia/Tahoe)
  • iTerm2
  • OpenCode v1.14.18
  • Installed via Homebrew

Related

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions