Skip to content

feat: Add native OS notifications for Claude Code CLI completion#105

Merged
phuongnd08 merged 5 commits intosahithvibudhi:mainfrom
phamvmnhut:feat/notify-claude-done-task
Dec 29, 2025
Merged

feat: Add native OS notifications for Claude Code CLI completion#105
phuongnd08 merged 5 commits intosahithvibudhi:mainfrom
phamvmnhut:feat/notify-claude-done-task

Conversation

@phamvmnhut
Copy link
Copy Markdown
Contributor

@phamvmnhut phamvmnhut commented Dec 20, 2025

Summary

  • Add native OS notifications when Claude Code CLI completes tasks or asks questions
  • Implement notification settings UI with permission status checking
  • Separate APIs: notification:* (general) and claude-notification:* (Claude-specific)
  • Add comprehensive tests for notification manager, settings, and UI components

Key Features

  • Native OS notifications for task completion and questions
  • Session-based state tracking in main process (avoids React lifecycle issues)
  • State detection from terminal output (completion/question patterns)
  • System permission checking (macOS ncprefs.plist integration)
  • Settings UI with permission status, test notification, and enable/disable toggle
  • Notification click handling - switches to correct project and worktree

New Components

Component Description
NotificationManager Core notification logic with session tracking
NotificationSettingsTab Settings UI with permission status display
GlobalSettings App settings dialog with tabs

API Design

  • notification:* - General notification APIs (settings, permissions, test)
  • claude-notification:* - Claude-specific APIs (session enable/disable, user input tracking)

Files Changed (22 files, +2847 lines)

  • New: notification-manager.ts, notification-settings.ts, GlobalSettings.tsx, NotificationSettingsTab.tsx
  • Modified: ipc-handlers.ts, preload/index.ts, ClaudeTerminal.tsx, shell-manager.ts, ProjectContext.tsx
  • Tests: notification-manager.test.ts, notification-settings.test.ts, NotificationSettingsTab.test.tsx, ProjectContext.test.tsx

Test plan

  • Unit tests for NotificationManager (session tracking, state detection, ANSI stripping)
  • Unit tests for NotificationSettingsManager (persistence, defaults)
  • UI tests for NotificationSettingsTab (29 tests covering all states)
  • ProjectContext tests (notification click handler, project operations)
  • All 179 tests passing
  • Manual test: Enable notifications, run Claude, switch away, verify notification appears
  • Manual test: Click notification to return to app and focus terminal

🤖 Generated with Claude Code

phamvmnhut and others added 5 commits December 20, 2025 14:54
Implement a notification system that alerts users when Claude Code CLI
completes tasks or asks questions while the app is in the background.

Key features:
- Native OS notifications (macOS, Windows, Linux supported)
- Session-based state tracking in main process (avoids React lifecycle issues)
- State detection from terminal output (completion/question patterns)
- System notification permission checking (macOS ncprefs.plist integration)
- Separated APIs: notification:* (general) and claude-notification:* (Claude-specific)

New components:
- NotificationManager: Core notification logic and session tracking
- NotificationSettingsTab: Settings UI with permission status
- GlobalSettings: General app settings dialog with tabs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for notification-settings.ts:
- Settings persistence and loading
- Default settings initialization
- Settings update and save
- Reset to defaults
- Corrupted file handling
- Single initialization enforcement

Expand notification-manager.test.ts:
- ANSI stripping (escape codes, OSC sequences)
- Completion patterns (send, ↵ send, case insensitivity)
- Question patterns ([Y/n], [y/N], yes/no, Tab/Arrow navigation)
- Permission status checking
- Test notification functionality
- Multiple session independence
- Edge cases (non-existent sessions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive tests for the notification settings UI:
- Rendering with different visibility states
- Permission status display (authorized, blocked, not supported, unknown)
- Enable/disable toggle functionality
- Test notification button behavior
- Refresh permission status button
- Open system settings button
- Error handling for API failures
- Toast notifications for user feedback

Update test setup with notification API mocks for both general
notification APIs and Claude-specific notification APIs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add listener in ProjectContext to handle claude-notification:clicked event:
- Find the project containing the clicked worktree path
- Switch to that project tab
- Select the correct worktree

Add comprehensive tests for ProjectContext:
- Notification click handler tests (switch project, select worktree)
- Basic project operations tests (add, remove, switch, update worktrees)

Update test setup with additional mocks:
- recentProjects API
- shell.terminateForWorktree API

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@phamvmnhut
Copy link
Copy Markdown
Contributor Author

Hi @sahithvibudhi , hope you're doing well! I wanted to follow up on this PR which adds native OS notifications for Claude Code CLI completion. It's been open for about a week now, and I wanted to check if you've had a chance to review it.

If there are any concerns, changes needed, or if this feature doesn't align with the project's direction, I'd appreciate any feedback. I'm happy to iterate on it based on your input. Thanks for your time!

@phuongnd08
Copy link
Copy Markdown
Collaborator

@phamvmnhut can you explain this PR with screenshots/video?

@phuongnd08
Copy link
Copy Markdown
Collaborator

phuongnd08 commented Dec 28, 2025

I can see if I can merge it if @sahithvibudhi is not around, given the benefit is explained clearly

@phamvmnhut
Copy link
Copy Markdown
Contributor Author

@phuongnd08 , Here's a brief explanation of this feature: When Claude Code CLI completes tasks or asks questions, it should show a notification in the macOS notification center to help you easily keep track of all running Claude Code instances regardless of which tab or tree you're in, with a toggle button to enable or disable this notification feature for each task.
image

@phuongnd08 phuongnd08 merged commit 419e8bd into sahithvibudhi:main Dec 29, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants