Skip to content

feat(permissions): add NSAlert-based permission prompts with throttling#80

Merged
missuo merged 6 commits into
missuo:mainfrom
thedavidweng:cursor/m2-permission-alerts-ab4a
Apr 13, 2026
Merged

feat(permissions): add NSAlert-based permission prompts with throttling#80
missuo merged 6 commits into
missuo:mainfrom
thedavidweng:cursor/m2-permission-alerts-ab4a

Conversation

@thedavidweng

@thedavidweng thedavidweng commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Add user-facing NSAlert permission prompts when required macOS permissions are missing, with per-permission "Don't Remind Again" throttling. All alert text uses the localization infrastructure from #79.

Depends on: #79 (localization infrastructure)

Motivation

Currently, when critical permissions (Microphone, Accessibility, Input Monitoring) are missing, Koe only logs to the console (NSLog) and/or plays an error sound. Users have no clear indication of why the app isn't working or how to fix it. This PR adds visible, actionable prompts consistent with the existing showAlert: pattern used in SPUpdateManager.

Changes

SPPermissionManager.h/.m

  • New SPPermissionType enum: Microphone, Accessibility, InputMonitoring, SpeechRecognition
  • New showPermissionAlertForType:settingsURL: — shows a localized NSAlert with:
    • Open Settings button — deep-links to the exact System Settings pane
    • Dismiss button
    • Don't Remind Again button — persisted per-permission in NSUserDefaults
  • New resetDontRemindForType: for clearing the suppression flag

SPAppDelegate.m

Integration at startup after checkAllPermissionsWithCompletion::

Permission Previous behavior New behavior
Microphone denied NSLog + error sound, no UI Alert with reason + link to Microphone settings
Accessibility missing Log only Alert explaining paste degradation + link to Accessibility settings
Input Monitoring missing Warning log Alert explaining hotkey failure + link to Input Monitoring settings
Speech Recognition denied Log only (apple-speech) Alert explaining ASR failure + link to Speech Recognition settings

Throttling

  • KoePermissionDontRemind_<N> key per permission type in NSUserDefaults
  • Once "Don't Remind Again" is clicked → permanently suppressed for that permission
  • Can be reset programmatically via resetDontRemindForType:
  • Avoids the "alert every launch" annoyance described in the design plan

Testing

cursoragent and others added 6 commits April 12, 2026 22:32
- Add SPLocalization utility for runtime language switching via
  NSUserDefaults (KoeInterfaceLanguage key)
- Add en.lproj/Localizable.strings with all user-facing strings
- Add zh-Hans.lproj/Localizable.strings with Chinese translations
- Update Info.plist to declare CFBundleLocalizations
- Support 'Follow System', 'English', and 'Simplified Chinese' modes
- KoeLocalizedString() macro for convenient access throughout ObjC code

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
Replace all hardcoded English strings in the status bar menu with
KoeLocalizedString() calls. Covers:
- Status text (Ready, Listening, Connecting, etc.)
- Permission labels and states
- Statistics display
- Menu actions (Setup Wizard, Quit, etc.)
- Microphone submenu items

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
Replace all hardcoded English strings in update alerts with
KoeLocalizedString() calls. Covers update available, up-to-date,
failed, incompatible, and button labels.

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
Replace hardcoded English strings in notification titles and the Edit
menu with KoeLocalizedString() calls.

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
Add Interface Language dropdown in the About pane with options:
- Follow System (default for new installs)
- English
- 简体中文

Language preference is stored in NSUserDefaults and takes effect
immediately for KoeLocalizedString() calls. A dialog informs the
user that some system UI elements may require an app restart.

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
Add showPermissionAlertForType: to SPPermissionManager with:
- Localized title and message for each permission type
- 'Open Settings' button that deep-links to the right System Settings pane
- 'Don't Remind Again' button backed by NSUserDefaults
- Alert throttling: once dismissed with 'Don't Remind Again', the alert
  won't appear again for that permission type

Integrate into SPAppDelegate:
- Microphone denied → alert with settings link (blocks startup)
- Accessibility missing → alert with settings link
- Input Monitoring missing → alert with settings link
- Speech Recognition denied (apple-speech provider) → alert

Co-authored-by: Davy <thedavidweng@users.noreply.github.com>
@missuo missuo merged commit 5a9a12e into missuo:main Apr 13, 2026
@thedavidweng thedavidweng deleted the cursor/m2-permission-alerts-ab4a branch April 13, 2026 07:53
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.

3 participants