Uh oh!
There was an error while loading. Please reload this page.
feat(tui): add terminal notifications via OSC escape sequences - #23447
feat(tui): add terminal notifications via OSC escape sequences#23447dexion wants to merge 1 commit into
Conversation
Send desktop notifications using terminal-native OSC escape sequences instead of osascript, fixing the macOS issue where notifications appeared as 'Script Editor' alerts with no click-to-focus support. - OSC 9 for iTerm2, Ghostty, Apple Terminal, Warp (native integration) - OSC 777 for Kitty, WezTerm, VTE-based terminals - Bell fallback for unsupported terminals - Auto-detects terminal via TERM_PROGRAM environment variable - Configurable via notification_method in tui.json (auto|osc9|osc777|bell|off) - Extracts shared wrapOscSequence helper for tmux/screen passthrough - Refactors clipboard.ts OSC 52 to reuse the shared helper Events that trigger notifications: - session.idle: response ready - permission.asked: permission required - question.asked: question asked Fixesanomalyco#23446
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs Found1. #23212 — "feat(tui): add terminal notifications"
2. #20963 — "feat(tui): built-in system notifications for session completion"
The current PR (#23447) is the proper approach as it avoids the merge conflicts from #23212 while implementing the same terminal notification functionality using OSC escape sequences. |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes#23446
Type of change
What does this PR do?
macOS desktop notifications from OpenCode appear as "Script Editor" alerts with no click-to-focus. This happens because the app uses
osascript -e 'display notification...'which macOS attributes to the Script Editor process.This PR adds terminal-native notifications via OSC escape sequences that work directly through the terminal emulator (iTerm2, Kitty, etc.), requiring no external tools.
How it works:
util/notify.ts— resolves notification method per terminal and formats OSC sequencesutil/osc.ts— shared helper that wraps OSC sequences for tmux/screen passthroughapp.tsx— subscribes tosession.idle,permission.asked,question.askedeventsclipboard.ts— refactors OSC 52 clipboard to reuse the sharedwrapOscSequencehelpertui-schema.ts+tui-migrate.ts— adds configurablenotification_methodoptionTerminal detection (
"auto"— default):\x1b]9;msg\x07)\x1b]777;notify;title;body\x07)\x07)\x07)Adapted from @kitlangton's draft PR #23212, but without the large
provider.tsEffect/Schema refactor that caused merge conflicts.How did you verify your code works?
Manual testing on macOS with iTerm2:
Verified that:
notification_method: "off"suppresses all notificationsnotification_method: "bell"works as fallback in unsupported terminalsScreenshots / recordings
N/A — terminal behavior change, no UI changes in the TUI itself.
Checklist