feat(tui): add terminal notifications via OSC escape sequences#23447
Closed
dexion wants to merge 1 commit intoanomalyco:devfrom
Closed
feat(tui): add terminal notifications via OSC escape sequences#23447dexion wants to merge 1 commit intoanomalyco:devfrom
dexion wants to merge 1 commit intoanomalyco:devfrom
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 Fixes anomalyco#23446
Contributor
|
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. |
Contributor
|
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. |
Contributor
|
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. |
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.
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