feat: add restoreWindow option for incoming call notifications

FA
2d ago
+80-0

Proposed changes

Adds an opt-in restoreWindow flag for incoming call notifications (notificationType: 'voice'). When it is set, the main process restores (if minimized), shows and focuses the root window, including when it is hidden in the tray. Default behavior is unchanged.

Why: incoming voice calls are easy to miss while the app is minimized or in the tray — the OS toast alone often goes unnoticed. This lets the web client ask for the window to come back for incoming calls.

The web client side (setting the flag for incoming calls) is in RocketChat/Rocket.Chat#42146.

Changes

  • restoreWindow?: boolean added to ExtendedNotificationOptions and CustomNotificationOptions, and forwarded by dispatchCustomNotification in the preload
  • handleCreateEvent restores the root window only for notificationType: 'voice' notifications with restoreWindow: true; text notifications and notifications without the flag ignore it
  • Uses the existing focusSecondaryWindow helper (restore if minimized, then show and focus), so a window hidden in the tray comes back too
  • Runs only when a notification is created, after the tag check, so an update with the same tag does not focus the window again
  • Not awaited: the toast is not delayed by the 300 ms getRootWindow() lookup; failures are only logged

Testing

  • jest src/notifications: 7 suites, 44 tests pass (the two restore tests fail against dev's code, as expected)
  • tsc --noEmit passes; ESLint clean on the changed files

šŸ¤– Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Incoming voice notifications can request that the app window be restored, shown, and focused. Custom notifications can pass this setting through their options.
  • Tests
    • Added coverage for minimized and already visible windows, repeated restoration requests, and cases where window restoration is not requested.