Skip to content

macOS: tie wx notifications to main window and improve failure visibility#69

Closed
dominicletz wants to merge 3 commits intomainfrom
cursor/issue-feature-design-38ed
Closed

macOS: tie wx notifications to main window and improve failure visibility#69
dominicletz wants to merge 3 commits intomainfrom
cursor/issue-feature-design-38ed

Conversation

@dominicletz
Copy link
Copy Markdown
Collaborator

Summary

This change improves macOS desktop notifications for Elixir Desktop by wiring wxNotificationMessage to the same wxFrame as the Phoenix/LiveView window, treating a false return from show/2 as a first-class failure with actionable logging, and making macOS-specific branches testable from Linux CI via ELIXIR_DESKTOP_OS=macos.

Refs #38

Root cause (why this is not a band-aid)

wxWidgets documents that notifications are associated with the top-level parent of the window passed to setParent, or with the application’s default main window if setParent is never called. The BEAM process often has no meaningful “main window” from the OS’s perspective when running under beam.smp during development, so Notification Center can accept the API call yet deliver nothing visible—or associate the toast with the wrong identity. Passing the actual Desktop.Window frame as the parent aligns the notification with the same UI surface the user sees, which matches how macOS expects user notifications to be scoped.

This does not replace the separate packaging concern (matching Info.plist in the .app bundle with metadata on beam.smp for production); it addresses the in-process wx association and silent failure parts of the same issue.

Changes

  • Desktop.Fallback.notification_new/3 optional parent: on macOS, call :wxNotificationMessage.setParent/2 when available.
  • Desktop.Window passes frame when creating/reusing notifications; module doc notes macOS troubleshooting.
  • notification_show/4 logs a warning when show/2 returns false, with a pointer to issue Notifications not showing on OSX #38 and System Settings.
  • Desktop.OS: ELIXIR_DESKTOP_OS=macos override for tests; public macos?/0.
  • Safer notification_new / notification_show when NO_WX leaves refs nil (avoids crashing connect on nil).

Tests

  • test/os_test.exsELIXIR_DESKTOP_OS=macos forces Desktop.OS.type/0 == MacOS.
  • test/fallback_notification_test.exsnotification_new/3 with NO_WX=1 does not raise (regression guard for nil notification path).

CI should run mix test and mix lint on the merge branch.

Open in Web Open in Cursor 

- Call wxNotificationMessage:setParent/2 on macOS so Notification Center ties
  the toast to the app window (wx default main window can be wrong for BEAM).
- Log when show/2 returns false with pointers to issue #38 and settings.
- Add ELIXIR_DESKTOP_OS=macos for testable macOS branches; add OS.macos?/0.
- Guard notification_new/show when NO_WX yields nil notification refs.

Refs #38

Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>
@dominicletz dominicletz added the cursor-waiting Cursor issue-workflow (cursor-automation.com) label Apr 30, 2026 — with Cursor
@cursor-automation
Copy link
Copy Markdown

@gemini review this PR

@cursor-automation cursor-automation Bot added cursor-waiting-for-ci Cursor issue-workflow (cursor-automation.com) and removed cursor-waiting Cursor issue-workflow (cursor-automation.com) labels Apr 30, 2026
cursoragent and others added 2 commits April 30, 2026 14:31
Bind frame in show_notification cast (was undefined), recreate wx
notification when a stored id maps to nil, no-op notification_close/1
for nil, fix doc typo, and drop duplicate :dismiss callback on non-Linux.

Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>
Igniter.Project.Module.module_name/2 is specced as (Igniter.t(), String.t()).
Using the atom MainWindow broke Dialyzer (invalid call, no_return on igniter/1,
and spurious unused_fun on private helpers). Use "MainWindow" consistently.

Unblocks CI for #69

Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>
@dominicletz dominicletz added the cursor-waiting-for-human Cursor issue-workflow (cursor-automation.com) label May 1, 2026 — with Cursor
@dominicletz dominicletz removed the cursor-waiting-for-ci Cursor issue-workflow (cursor-automation.com) label May 1, 2026
@cursor-automation cursor-automation Bot added cursor-ignore Cursor issue-workflow (cursor-automation.com) and removed cursor-waiting-for-human Cursor issue-workflow (cursor-automation.com) labels May 1, 2026
@dominicletz dominicletz removed the cursor-ignore Cursor issue-workflow (cursor-automation.com) label May 1, 2026
@dominicletz dominicletz closed this May 1, 2026
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