Skip to content

fix(app): keep Spotlight, Shortcuts and notification clicks from opening Settings - #546

Merged
ggbond268 merged 3 commits into
mactools-app:mainfrom
nikoelt:pr/app-system-events
Nov 19, 2026
Merged

ggbond268 merged 3 commits into
mactools-app:mainfrom
nikoelt:pr/app-system-events

Conversation

@nikoelt

@nikoelt nikoelt commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result

Running a MacTools action from Spotlight or Shortcuts goes through the system App Intents service (linkd). That service reopens the app, which MacTools treated as a request to show Settings, and later asks the app to quit, which stopped features such as Keep Awake. Clicking one of MacTools' own notifications also reopens the app, so Settings opened then too.

Now:

  • A reopen or quit from the App Intents service is ignored, so Settings stays shut and Keep Awake keeps running.
  • A reopen from Notification Centre is ignored.
  • A plugin notification that names a file (MacTools.revealFileURL, an existing absolute path) shows that file in Finder when clicked. Nothing is opened or run.
  • Spotlight and Shortcuts are told about MacTools' actions again only when the list of actions actually changes, since linkd limits how often it accepts updates.

Changes

  • MacToolsAppDelegate:
    • recognizes the sending process of reopen and quit Apple Events: linkd for the App Intents service, and Notification Centre or usernoted for notification clicks.
    • handles the default action of a plugin notification by revealing its file.
    • sets the notification delegate in applicationWillFinishLaunching, before instance coordination starts, so a click that launches MacTools is handled.
  • MacToolsAppIntentCoordinator: publishes the actions to Spotlight and Shortcuts only when they differ from the last ones published.
  • MacToolsAppIntents: action lookups from Spotlight and Shortcuts count as activity.
  • Tests: the service's reopen and quit are ignored while other senders still open Settings; actions are republished only when they change; lookups count as activity.
  • Two app changelog fragments.

There is no change to permissions or stored data, and no PluginKit change.

Verification

  • MacToolsAppDelegateTests and MacToolsAppIntentCoordinatorTests, within the full XCTest suite: pass, 3,327 tests, 0 failures (6 skipped by upstream's own settings)
  • make script-tests: pass (changelog, localization, website data, backup inventory, and 275 tooling tests)
  • Not yet checked by hand on macOS 27:
    • Run a MacTools action from Spotlight; Settings stays shut and Keep Awake keeps running.
    • Click a MacTools notification; Settings stays shut.
    • Click a finished-download notification; Finder shows the file.

UI evidence

Not applicable: nothing on screen changes, except that Settings no longer opens.

Checklist

  • Core behavior and relevant risks are verified using existing tests, focused additions, or manual checks; results or limitations are recorded.
  • UI evidence is attached where applicable; shared components, themes, localization, and accessibility are respected.
  • User-facing documentation and changelog fragments are updated when required.
  • Plugin metadata, runtime contracts, action policies, and minimum-host compatibility agree.
  • Licensing and third-party notices are complete; no credentials, local configuration, or unrelated generated files are included.

🤖 Generated with Claude Code

…ng Settings

Spotlight and Shortcuts run MacTools actions through the system App
Intents service (linkd), which reopens the app and later asks it to quit.
Neither is a person asking for Settings, and quitting stopped features
such as Keep Awake; MacTools now ignores both. A click on one of MacTools'
own notifications also reopens the app: it no longer opens Settings, and
a notification that names a file (a finished download) shows that file
in Finder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ggbond268

Copy link
Copy Markdown
Collaborator

Thanks for the fix! One remaining issue is the notification delegate's registration timing.

The delegate is still assigned in MacToolsAppRuntime.start, after asynchronous instance coordination. If MacTools is closed and the user clicks an existing file notification, the response may arrive before the delegate is installed, leaving the click unhandled instead of revealing the file in Finder.

Please register UNUserNotificationCenter.current().delegate = self synchronously in applicationWillFinishLaunching, before starting the coordination task. Apple requires the delegate to be set before launch finishes.

I haven't verified this cold-start flow manually yet. A useful check would be to quit MacTools, click an existing file notification, and confirm that Finder reveals the file while Settings stays closed.

The delegate was set when the runtime started, after instance
coordination, so a click on a notification that launched MacTools could
arrive with no delegate and the file was not shown. It is now set in
applicationWillFinishLaunching, as Apple requires; the click handler
needs nothing from the runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikoelt

nikoelt commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. Fixed in 3168ad1: the delegate is now set in applicationWillFinishLaunching, before the instance-coordination task starts, so a click that launches MacTools has a delegate to arrive at. The click handler needs nothing from the runtime, so it can run that early.

MacToolsAppDelegateTests pass, as does the full XCTest suite on the branch (3,262 tests, 0 failures; 6 skipped by upstream's own settings).

nikoelt added a commit to nikoelt/MacTools that referenced this pull request Nov 18, 2026
…and-downloads

# Conflicts:
#	docs/plugins/preferences-backup-inventory.md
@ggbond268
ggbond268 merged commit ab282b7 into mactools-app:main Nov 19, 2026
2 checks passed
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