Skip to content

Commit f128fc0

Browse files
Arseyclaude
andauthored
Add Launch at Login setting (#187)
Registers the app as a login item via SMAppService with a toggle in Settings > General. State is re-read on appear so changes made in System Settings > Login Items stay in sync, and the toggle reverts if registration fails. Claude-Session: https://claude.ai/code/session_01QLDiNzrDds62dnD9NoCEJV Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent c23262f commit f128fc0

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

App/Views/SettingsView.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ServiceManagement
12
import SwiftUI
23

34
struct SettingsView: View {
@@ -68,13 +69,38 @@ struct GeneralSettingsView: View {
6869
@ObservedObject var serverController: ServerController
6970
@State private var showingResetAlert = false
7071
@State private var selectedClients = Set<String>()
72+
@State private var launchAtLogin = SMAppService.mainApp.status == .enabled
7173

7274
private var trustedClients: [String] {
7375
serverController.getTrustedClients()
7476
}
7577

7678
var body: some View {
7779
Form {
80+
Section {
81+
VStack(alignment: .leading, spacing: 4) {
82+
Toggle("Launch at Login", isOn: $launchAtLogin)
83+
.onChange(of: launchAtLogin) { _, enabled in
84+
do {
85+
if enabled {
86+
try SMAppService.mainApp.register()
87+
} else {
88+
try SMAppService.mainApp.unregister()
89+
}
90+
} catch {
91+
launchAtLogin = SMAppService.mainApp.status == .enabled
92+
}
93+
}
94+
95+
Text("Opens iMCP automatically when you log in.")
96+
.font(.caption)
97+
.foregroundStyle(.secondary)
98+
}
99+
.onAppear {
100+
launchAtLogin = SMAppService.mainApp.status == .enabled
101+
}
102+
}
103+
78104
Section {
79105
VStack(alignment: .leading, spacing: 12) {
80106
HStack {

0 commit comments

Comments
 (0)