Skip to content

feat(tui): built-in system notifications for session completion#20963

Open
nianyi778 wants to merge 4 commits intoanomalyco:devfrom
nianyi778:feat/tui-system-notifications
Open

feat(tui): built-in system notifications for session completion#20963
nianyi778 wants to merge 4 commits intoanomalyco:devfrom
nianyi778:feat/tui-system-notifications

Conversation

@nianyi778
Copy link
Copy Markdown

Issue for this PR

Closes #7242
Closes #13334
Closes #18366

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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): osascript on macOS, notify-send on Linux, PowerShell on Windows.

Two problems this fixes:

  1. macOS notification attribution: the existing plugin docs used bare display notification which attributes the toast to Script Editor, not Terminal. Changed to tell application "Terminal" to display notification so clicking opens the right app.

  2. 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: boolean to tui.json (default true) 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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant