Mailspring/app/internal_packages
Ben Gotow f81017ee52
Adopt newer features of the Electron Notification API, Windows toasts with XML (#2549)
* Add implementation plan for enhanced notification system

Plan covers migrating from Web Notification API to Electron's main
process Notification module to enable macOS inline reply, action
buttons, and Windows rich toast notifications.

* Implement enhanced notification system with main process IPC

Migrate from Web Notification API to Electron's main process
Notification module to enable platform-specific features:

- macOS: inline reply support via hasReply, action buttons
- Windows: rich toast notifications via toastXml
- Linux: urgency levels, persistent notifications

Key changes:
- Add notification-ipc.ts: Main process handlers following
  quickpreview-ipc.ts pattern
- Update native-notifications.ts: IPC bridge with callback
  management for notification events
- Update unread-notifications: Add "Mark as Read" and "Archive"
  action buttons, implement _handleNotificationAction method
- Register IPC handlers in application.ts

The notification system now properly forwards reply, action, click,
and close events from main process back to renderer via
windowManager.sendToAllWindows().

* Improve Windows toast notifications following Microsoft best practices

- Add hint-maxLines="1" to sender name to prevent wrapping
- Add hint-style="captionSubtle" to message snippet for visual hierarchy
- Add group attribute for notification stacking per thread
- Add reply text input with Send button for Windows toast
- Add activationType="background" for action buttons
- Create dedicated buildWindowsSummaryToastXml for multi-message notifications
- Add displaySummaryNotification method for summary notifications
- Update _notifyAll to use summary notification with sender names

References:
- https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts
- https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/toast-ux-guidance

* Address PR feedback: improve XML escaping, add types, consolidate helpers

- Replace manual XML escaping with browser DOM APIs (XMLSerializer)
  to properly handle full UTF-8 range including international text
- Add IIPCNotificationOptions interface for type safety in IPC calls
- Consolidate sender list formatting into formatSenderList helper
  with proper English formatting ("X", "X and Y", "X, Y, and Z")
- Remove implementation plan document (now complete)

* Add icon path validation to prevent arbitrary file access

Validate that notification icon paths are within allowed directories
before passing them to nativeImage.createFromPath(). This prevents
the renderer from potentially specifying arbitrary file paths.

Allowed paths:
- Application's static resources (resourcePath/static/)
- System icon directories on Linux (/usr/share/icons/, etc.)
- System temp directory (for converted PNG icons on Linux)

Uses path.resolve() to prevent directory traversal attacks, following
the same pattern as quickpreview-ipc.ts.

* Remove unused notification code

- Remove _macNotificationsByTag: legacy field from old node-mac-notifier
  implementation, never used in new IPC-based approach
- Remove closeNotificationsForThread: never called; the renderer already
  handles notification dismissal via individual NotificationHandle.close()
  calls when threads are marked as read

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 15:45:17 -06:00
..
account-sidebar
activity Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
attachments
category-mapper
category-picker Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
composer Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
composer-signature Remove unused files 2026-01-03 20:34:23 -06:00
composer-templates
contacts Upgrade TypeScript from version 3 to 5 (#2547) 2026-01-06 12:41:35 -06:00
custom-fonts
custom-sounds
draft-list Remove unused files 2026-01-03 20:34:23 -06:00
events Upgrade ical.js and ical-expander to latest versions (#2520) 2026-01-01 22:47:59 -06:00
github-contact-card
link-tracking
list-unsubscribe Update app dependencies (Phase 1 & 2 security and minor updates) (#2513) 2026-01-01 22:15:14 -06:00
main-calendar Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
message-autoload-images Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
message-list Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
message-view-on-github
mode-switch
notifications Upgrade TypeScript from version 3 to 5 (#2547) 2026-01-06 12:41:35 -06:00
onboarding Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
open-tracking
participant-profile Upgrade TypeScript from version 3 to 5 (#2547) 2026-01-06 12:41:35 -06:00
personal-level-indicators
phishing-detection
preferences Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
print
remove-tracking-pixels
screenshot-mode
send-and-archive
send-later Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
send-reminders Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
system-tray Update remaining mock emails, etc. to use rel=nofollow for CASA compliance 2024-09-28 11:06:49 -05:00
theme-picker
thread-list Fix thread list context menu not checking for empty items array (#2550) 2026-01-07 12:22:55 -06:00
thread-search Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
thread-sharing Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
thread-snooze Upgrade TypeScript from version 3 to 5 (#2547) 2026-01-06 12:41:35 -06:00
translation Upgrade lru-cache from v4.0.1 to v10.4.3 (#2517) 2026-01-01 22:30:07 -06:00
ui-dark
ui-darkside
ui-less-is-more
ui-light
ui-taiga
ui-ubuntu
undo-redo Replace componentWillReceiveProps usage (#2546) 2026-01-06 15:27:45 -06:00
unread-notifications Adopt newer features of the Electron Notification API, Windows toasts with XML (#2549) 2026-01-07 15:45:17 -06:00