Skip to content

only show OS notifications when the app is hidden#5155

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
feat/os-notifications-only-when-hidden
Jul 20, 2026
Merged

only show OS notifications when the app is hidden#5155
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
feat/os-notifications-only-when-hidden

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request improves the notification system for both macOS and Windows by making notifications more context-aware and reducing redundant OS toasts when the application window is visible. It introduces a new mechanism to suppress native notifications while the user is actively viewing the app, ensuring that only in-app notifications are shown in this case. The changes also add support for specifying notification levels and controlling in-app fallback behavior.

Notification delivery improvements:

  • Updated DeliverNotification in MacOsNotificationBridge.cs to accept a RuntimeNotificationLevel and an allowInAppFallback flag, allowing finer control over notification type and delivery method. Now, if the main window is visible, notifications are shown in-app instead of as OS toasts.
  • All notification methods in MacOsNotificationBridge.cs (ShowProgress, ShowSuccess, ShowError, ShowUpdatesAvailableNotification, ShowUpgradingPackagesNotification, ShowSelfUpdateAvailableNotification, ShowNewShortcutsNotification) now specify the notification level and, where appropriate, disable in-app fallback to ensure consistent behavior.

Windows notification logic:

  • Modified Show in WindowsAppNotificationBridge.cs to only show native OS toasts if the main window is not on screen, preventing duplicate notifications when the user is already looking at the app.

Main window state tracking:

  • Added a static, thread-safe _isOnScreen property to MainWindow.axaml.cs to track whether the window is visible and not minimized, and exposed it via IsWindowOnScreen for use by notification bridges.
  • Hooked into window visibility and state changes to keep _isOnScreen up to date, ensuring notification logic always reflects the current UI state.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Suppresses native Windows and macOS notifications while the main window is visible, using in-app notifications where appropriate.

Changes:

  • Tracks whether the main window is visible and not minimized.
  • Routes macOS notifications by level and fallback policy.
  • Prevents Windows OS toasts while the app is on screen.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
MainWindow.axaml.cs Tracks thread-safe on-screen window state.
WindowsAppNotificationBridge.cs Suppresses native toasts while visible.
MacOsNotificationBridge.cs Adds notification levels and context-aware delivery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit c5841b5 into main Jul 20, 2026
6 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the feat/os-notifications-only-when-hidden branch July 20, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants