fix: show macOS Dock badges for unread messages - #964
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change centralizes unread-count badge updates, applies badges on count changes and window focus, adds platform-specific tests, and documents macOS, Windows, and Linux badge behavior. ChangesUnread app badge synchronization
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Unread-message counts now synchronize to native app badges across supported desktop platforms, including clearing and focus restoration. The covered behavior presents no remaining actionable merge risk. Sequence Diagram(s)sequenceDiagram
participant Renderer as useAppTrayUnreadSync
participant IPC as setTrayUnread IPC
participant Main as refreshUnreadAppBadge
participant Native as Native badge API
Renderer->>IPC: Send combined unread count
IPC->>Main: Update lastTrayUnreadCount
Main->>Native: Apply or clear platform badge
Native-->>Main: Complete badge update
Main->>Native: Reapply badge on window focus
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 8 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
When Mesh Client has unread messages, macOS can show the in-app count without a Dock badge because setting the badge does not initialize notification authorization. This change initializes Electron's native macOS notification support before setting a nonzero unread badge, restores the latest count when the window regains focus, and clears it when all messages are read.
Windows retains its red taskbar overlay and Linux retains launcher counts where supported. Native badge updates are independent of tray updates, and the existing restart-nudge badge keeps its priority. macOS still honors the user's notification and badge settings; troubleshooting now explains where to enable them.
The Electron test launcher now explicitly loads the built Mesh Client renderer so an unrelated development server on port 5173 cannot replace the app under test.
Validation:
pnpm run buildpnpm run check:prpnpm exec playwright test e2e/unread-badge.spec.tson macOS: actual preload IPC sets the Dock count, focus restores it, and zero clears it.The native macOS test checks Electron's Dock badge state. Windows/Linux native visuals and a packaged app's first-time macOS permission prompt were not exercised locally.
Summary by CodeRabbit
New Features
Bug Fixes
Tests