- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[v3] Windows notifications improvements #4230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v3] Windows notifications improvements #4230
Conversation
WalkthroughThis update refactors notification handling across both the example application and platform-specific services. In the example app, all startup notification logic is removed except for the notification response callback. On macOS, the notification service now calls a new delegate initialization function during startup and adds error handling for this step. The Windows notification service is enhanced to register the toast activator COM class factory, store the executable path, update the registry, and refactor activation callback logic. Several function declarations and signatures are updated or reordered, and imports are adjusted accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Example App
participant NotificationService as Platform Notification Service
participant OS as Operating System
App->>NotificationService: Register notification response callback
Note over App,NotificationService: (All other app-side notification logic removed)
Note over NotificationService: On Startup (macOS)
NotificationService->>OS: Check notification availability & bundle ID
NotificationService->>OS: Call ensureDelegateInitialized()
OS-->>NotificationService: Return success or error
Note over NotificationService: On Startup (Windows)
NotificationService->>OS: Retrieve executable path
NotificationService->>OS: Update registry with exe path
NotificationService->>OS: Register COM class factory
OS-->>NotificationService: Return success or error
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)v3/pkg/services/notifications/notifications_windows.go (1)
🔇 Additional comments (10)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
v3/pkg/services/notifications/notifications_windows.go (3)
13-17
: Blank import ofunsafe
– use regular import for clarity
unsafe
has no side‑effects; the only reason it must appear in the import list is to satisfy the//go:linkname
directive.
Using a blank identifier hides the real dependency and can be confusing when the file is read in isolation.
Prefer:import "unsafe" // required for go:linknameso the intent is explicit and static‑analysis tools still see a real reference.
29-29
:exePath
never changes after Startup – tag it as immutable
exePath
is written once and thereafter only read.
Declare it asexePath string // immutable, set in Startup
or even mark the field unexported and//nolint:structcheck
if tooling complains.
This small hint prevents accidental writes in the future.
60-62
:go:linkname
is brittle across versions and modulesLinking against an unexported symbol in another module couples the two repos at the ABI level.
Ifgo-toast
refactors, you get a silent compile‑time break.
Consider asking the upstream project to exportregisterClassFactory
or wrap the call behind a build‑tagged shim held in this repo so the surface is under your control.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
v3/examples/notifications/main.go
(2 hunks)v3/pkg/services/notifications/notifications_darwin.go
(1 hunks)v3/pkg/services/notifications/notifications_darwin.h
(1 hunks)v3/pkg/services/notifications/notifications_darwin.m
(1 hunks)v3/pkg/services/notifications/notifications_windows.go
(7 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
v3/examples/notifications/main.go (2)
v3/internal/runtime/desktop/@wailsio/runtime/src/window.ts (1)
Name
(267-269)v3/pkg/services/notifications/notifications.go (1)
NotificationResult
(105-108)
v3/pkg/services/notifications/notifications_windows.go (2)
v3/pkg/application/application.go (1)
Get
(52-54)v3/pkg/services/notifications/notifications.go (1)
NotificationResponse
(92-101)
🔇 Additional comments (8)
v3/pkg/services/notifications/notifications_darwin.m (1)
94-108
: Return type change enhances cross-language compatibility.The function correctly uses
dispatch_once
to ensure thread-safe initialization of the notification delegate. The return type change fromBOOL
tobool
better aligns with the C99 standard boolean type, making the interface more consistent with Go's boolean handling in CGO.v3/pkg/services/notifications/notifications_darwin.go (1)
68-70
: Good addition of delegate initialization error handling.This change adds proper error handling for notification delegate initialization during startup. By checking the return value from
ensureDelegateInitialized()
, the code can now detect and report initialization failures, improving the service's reliability.v3/pkg/services/notifications/notifications_darwin.h (1)
9-10
: Function declaration order improved and new delegate initialization function added.The reordering of function declarations and addition of
ensureDelegateInitialized
properly exposes the new initialization capability to the rest of the codebase. This aligns well with the implementation changes in the corresponding .m and .go files.v3/examples/notifications/main.go (2)
54-54
: Explicit window naming improves application structure.Adding a specific name to the window (
"main"
) helps with window identification and management, particularly when working with events or when the application might have multiple windows.
64-73
: Notification handling simplified to focus on response callbacks.The notification initialization and sending logic has been removed in favor of a more streamlined approach that only handles notification responses. This simplification:
- Makes the example clearer by focusing on a single responsibility
- Relies on the notification service's own initialization
- Properly handles errors and sends events to the frontend
This change aligns well with the PR objective to enhance notification handling and simplify usage.
v3/pkg/services/notifications/notifications_windows.go (3)
108-125
: Good: consolidated result constructionThe new block neatly separates the error path from the happy path and reuses the existing
NotificationResponse
type.
This improves readability and avoids partial initialisation.
170-171
: ExplicitActivationType
improves intentSetting
ActivationType: toast.Foreground
makes the behaviour crystal‑clear and guards against upstream default changes.
👍
205-206
: Same commendation as aboveExplicitly forcing foreground activation for action‑rich toasts keeps UX consistent across basic and advanced notifications.
|
Thanks for this!!! 🙏 |
Description
Windows changes:
Minor changes on macOS:
Updated the example to be easier to understand. Create the service, attach a callback, go!
Type of change
Please select the option that is relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor
.If you checked Linux, please specify the distro and version.
Test Configuration
Checklist:
website/src/pages/changelog.mdx
with details of this PRSummary by CodeRabbit