Skip to content

fix(settings): make launch-at-login reflect actual system state#14

Merged
PatelUtkarsh merged 1 commit into
mainfrom
fix/launch-at-login
May 19, 2026
Merged

fix(settings): make launch-at-login reflect actual system state#14
PatelUtkarsh merged 1 commit into
mainfrom
fix/launch-at-login

Conversation

@PatelUtkarsh
Copy link
Copy Markdown
Owner

Summary

The Launch at Login toggle used @AppStorage as its source of truth, so it could disagree with what macOS Login Items actually said. If SMAppService.register() failed or the OS put the app in .requiresApproval, the toggle still showed "on". Errors went to print(), which is invisible because AudioType is an LSUIElement (no console attached).

Changes

  • Source of truth is now SMAppService.mainApp.status. Toggle reads .enabled; refreshes on .onAppear and on NSApplication.didBecomeActiveNotification (so toggling the setting in System Settings is picked up).
  • Failures surface as a red inline caption, matching the API key save-error pattern.
  • .requiresApproval shows a hint plus an "Open Login Items" button that deep-links to the correct System Settings panel.
  • Dropped the misleading launchAtLogin UserDefaults key.

Verification

  • swift build clean.
  • Manual: toggle on -> Login Items shows app; toggle off -> removed. Disabling via System Settings while AudioType runs and reopening Settings shows the toggle off.

The toggle used @AppStorage as its source of truth, so it could disagree
with macOS Login Items. If register() failed or the OS put the app in
.requiresApproval, the UI showed it as on regardless. Errors were
print()ed, which goes nowhere because AudioType is LSUIElement.

- Source of truth is now SMAppService.mainApp.status. The toggle reads
  .enabled, refreshes on appear and when the app becomes active.
- Failures surface inline (red caption), matching the API key fields.
- .requiresApproval shows a hint and an 'Open Login Items' button that
  jumps straight to the right System Settings panel.
- Drop the misleading UserDefaults key.
@PatelUtkarsh PatelUtkarsh merged commit eb953a2 into main May 19, 2026
1 check passed
@PatelUtkarsh PatelUtkarsh deleted the fix/launch-at-login branch May 19, 2026 05:20
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.

1 participant