#15909: Guard notifications on macOS; fix focus issue and build fixes
app: macos
stale
size: XS
Cluster:
macOS Notification and Menu Fixes
Fixes https://github.com/openclaw/openclaw/issues/15911
Some build fixes and version updates for a smoother dev setup on macOS
- PermissionManager: add canAccessNotificationCenter() and avoid calling UNUserNotificationCenter when the app has no bundle identifier
- make ensureCapability return boolean results and propagate them;
- add macOS-specific handling to exclude .ephemeral authorization (accept .authorized/.provisional on macOS) and mirror that behavior in the batch capability checks.
- ChatComposer: defer clearing shouldFocus with DispatchQueue.main.async to avoid mutating state while making the text view first responder (fixes a focus/race issue).
- Package.swift: add a macOS-only comment and update the platforms list to include macOS v15 and iOS v18.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Improved macOS notification handling and fixed a SwiftUI state mutation race condition. The PR guards `UNUserNotificationCenter` access with a bundle identifier check (apps without bundle IDs can't use the notification center), excludes `.ephemeral` authorization status on macOS (iOS-only), updates platform requirements to include iOS v18 for shared dependency compatibility, and defers `shouldFocus` state clearing with `DispatchQueue.main.async` to prevent mutating state during view updates.
Key changes:
- Added `canAccessNotificationCenter()` guard to prevent crashes when bundle identifier is nil
- Made `ensureCapability()` return boolean results for proper error propagation
- Platform-specific handling: `.ephemeral` excluded on macOS, only `.authorized` and `.provisional` accepted
- Fixed ChatComposer focus race by deferring state mutation to next run loop
- Updated Package.swift platforms to include iOS v18 (needed for OpenClawKit shared dependency)
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk - the changes are defensive improvements
- The changes are well-scoped defensive improvements (guard clauses, platform-specific handling, async state mutation fix). All changes follow established Swift/SwiftUI patterns and address real edge cases. The only minor issue is a potentially confusing comment in Package.swift where the file states it's macOS-only but includes iOS platform - this is for dependency compatibility but could be clearer.
- No files require special attention
<sub>Last reviewed commit: e3d2b12</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19828: feat: reply notifications for macOS and web UI
by fal3 · 2026-02-18
79.2%
#9926: fix(macos): guard UNUserNotificationCenter when no bundle identifier
by webcpu · 2026-02-05
79.1%
#11048: fix: address repository issues (env, author, CI comments, security ...
by cavula · 2026-02-07
78.2%
#3337: fix(macos-app): patch SwiftPM Bundle.module accessor for app bundle
by skymoore · 2026-01-28
77.4%
#3474: fix(macos): menu bar activity badge not showing during agent work
by elektricM · 2026-01-28
76.9%
#22458: Codex/macos chat corner clip
by apethree · 2026-02-21
74.8%
#7121: feat(macos): update app icon OpenClaw branding
by rishavgoenka · 2026-02-02
74.3%
#18792: docs: add macOS source-run troubleshooting for setup/auth issues
by yash27-lab · 2026-02-17
74.2%
#17386: fix: Site shows MacOS 14+ but only works on 15+
by MisterGuy420 · 2026-02-15
74.1%
#22773: fix(ios): support Xcode 16+ team detection and fix ntohl build error
by brianleach · 2026-02-21
74.1%