Skip to content

feat(notification): bridge desktop native notifications with app icon and window focus - #674

Merged
Fairy-happy merged 2 commits into
V0.12.0from
feat/native-desktop-notifications
Oct 13, 2026
Merged

Fairy-happy merged 2 commits into
V0.12.0from
feat/native-desktop-notifications

Conversation

@yaojin3616

Copy link
Copy Markdown
Contributor

Summary

Addresses notification presentation and click-activation issues in DSH Desktop:

  1. App icon in notifications: HTML5 notifications sent from http://127.0.0.1:<port> were previously handled by Chromium without the application's bundle icon, causing macOS/Windows to show a generic or fallback icon. The bridge now routes notifications through Electron's native Notification with desktopIconPath().
  2. Focus / activate on click: Clicking HTML5 notifications in Chromium dispatches a DOM event but lacks OS-level window activation privileges in Electron, leaving the desktop window in the background or minimized. The bridge now listens to native notification click events, restores minimized windows, calls mainWindow.show(), mainWindow.focus(), and app.focus({ steal: true }) on macOS.
  3. Event forwarding: Dispatches click and close events back to the renderer so web-side notification.onclick and notification.onclose continue to function seamlessly.

Implementation

  • src/main/desktop-notification.ts: Main process handler managing native Notification instances, click activation, and teardown.
  • src/preload/desktop-notification.ts: Intercepts window.Notification in the main world and bridges creation, click, and close events via IPC.
  • test/desktop-notification.test.ts: Unit tests verifying IPC registration, payload validation, notification lifecycle, and window activation on click.

Verification

  • npm run typecheck passes.
  • npm run build passes.
  • npx vitest run test/desktop-notification.test.ts passes (4/4 tests).

@Fairy-happy
Fairy-happy merged commit 022c9e1 into V0.12.0 Oct 13, 2026
@Fairy-happy
Fairy-happy deleted the feat/native-desktop-notifications branch October 13, 2026 03:55
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