feat(tui): built-in system notifications for session completion#20963
Open
nianyi778 wants to merge 4 commits intoanomalyco:devfrom
Open
feat(tui): built-in system notifications for session completion#20963nianyi778 wants to merge 4 commits intoanomalyco:devfrom
nianyi778 wants to merge 4 commits intoanomalyco:devfrom
Conversation
- Add Notification service with zero dependencies (darwin/linux/win32) - macOS notifications attributed to Terminal.app (fixes click target) - Add terminal focus detection to avoid notifications when focused - Add 'notifications' config option to tui.json (default: true) - Listen to session.idle for completion notifications - Update session.error to also show system notifications - Fix documentation plugin example (osascript attribution) - Beautify TUI toast: full borders + variant icons (✓✗ℹ⚠)
- Add .catch() to session.idle notification to prevent crashes - Use proper escapeForOsascript function for macOS - Add more terminals to detection list (vscode, code) - Restore escapeXml for Windows branch
6 tasks
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 #7242
Closes #13334
Closes #18366
Type of change
What does this PR do?
The TUI had no built-in system notifications — users had to wire up a plugin themselves just to get notified when a session finished. This adds a native notification service (
src/notification/index.ts) that calls platform system tools directly (no extra deps):osascripton macOS,notify-sendon Linux, PowerShell on Windows.Two problems this fixes:
macOS notification attribution: the existing plugin docs used bare
display notificationwhich attributes the toast to Script Editor, not Terminal. Changed totell application "Terminal" to display notificationso clicking opens the right app.Sub-agent noise (Sub-Agents Constantly Trigger OS Notifications #13334): notifications now only fire when the terminal is not in focus.
terminalIsFocused()checks the frontmost app on macOS against a list of known terminal apps, so background sessions notify but foreground ones stay quiet.Config: added
notifications: booleantotui.json(defaulttrue) so users can opt out.Also tidied up toast UI: full borders on all sides and variant icons (✓ ✗ ℹ ⚠) so toasts are easier to scan at a glance.
How did you verify your code works?
Tested manually on macOS — ran a session in the background, confirmed notification fired and was attributed to Terminal.app. Also confirmed no notification when terminal was focused.
Screenshots / recordings
UI-only change is the toast border/icon improvement — no significant visual recording needed.
Checklist