openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Fix the autocomplete Apple Events permission popup on app launch

Open Al629176 opened this issue 7 months ago • 2 comments

Summary

Fix system popup error shown on app open: OpenHuman autocomplete is not authorized to send Apple Events to System Events.

Problem

When opening the app, a macOS system notification/error appears:

OpenHuman autocomplete error unable to query focused text context: execution error: Not authorised to send Apple events to System Events. (-1743)

This creates a poor first-launch experience and makes the app look broken.

Expected Behavior

  • App should not show scary system error popups on launch.
  • If macOS Accessibility/Automation permission is needed, user should see a clear in-app permission prompt.
  • Autocomplete should fail gracefully until permission is granted.
  • If autocomplete is hidden/disabled, it should not run or request context in the background.

Scope

  • Identify why autocomplete/text-context querying runs on app startup.
  • Gate Apple Events/System Events access behind explicit permission checks.
  • Prevent background autocomplete from running if feature is disabled/hidden.
  • Add a friendly permission/onboarding message with steps to grant macOS permission.
  • Suppress noisy system notifications for expected permission-denied state.
  • Add logs for permission state without repeatedly alerting the user.

Acceptance Criteria

  • Opening the app does not trigger the Apple Events permission error popup.
  • Permission-denied state is handled gracefully inside the app.
  • Autocomplete does not run in background if disabled/hidden.
  • User gets clear guidance only when they intentionally enable/use autocomplete.
  • No repeated notification spam for the same permission issue.

Al629176 avatar Apr 27 '26 12:04 Al629176

gating apple events behind 'permission checks' won't fix this alone. -1743 fires the moment you send the event, not when you query for permission. the API you actually want is AEDeterminePermissionToAutomateTarget with askUserIfNeeded=false. it returns errAEEventWouldRequireUserConsent (-1744) before any system popup, so you can disable the autocomplete pipeline cleanly on first launch. without that gate, even the 'graceful' path still fires the dialog once, which is exactly the symptom here. log the result, cache it, only re-check on app foreground.

m13v avatar Apr 29 '26 16:04 m13v

Hi @Al629176 bro, on which build was this error occuring?

oxoxDev avatar May 04 '26 09:05 oxoxDev