import SwiftUI import JobleyKit import JobleyUI struct MacSettings: View { @ObservedObject var updates: AppUpdates var body: some View { TabView { AccountSettings().tabItem { Label("Account", systemImage: "person.crop.circle") } AgentSettingsTab().tabItem { Label("Agents", systemImage: "cpu") } AboutSettings(updates: updates).tabItem { Label("About", systemImage: "info.circle") } } .frame(width: 560, height: 520) } } struct AccountSettings: View { @EnvironmentObject var desk: DeskModel @AppStorage(APIClient.serverDefaultsKey) private var server = "" var body: some View { AccountForm(curator: desk.curator, server: $server) } } struct AccountForm: View { @ObservedObject var curator: CuratorModel @Binding var server: String var body: some View { Form { Section { if let me = curator.me { LabeledContent("Signed in as", value: me.isCurator ? "Curator" : "Moderator · \(me.name)") LabeledContent("Candidates", value: curator.canSeeCandidates ? "Can see" : "Hidden") Button("Sign out", role: .destructive) { curator.signOut() } } else { PasskeySignIn(curator: curator) } } header: { Text("Sign in") } footer: { Text("Curators and moderators sign in with a passkey. Your sign-in is kept in your Mac's Keychain, never in a file or sent to an agent.") } if curator.me != nil { Section { PasskeyList(curator: curator) } header: { Text("Passkeys") } footer: { Text("Add a second passkey, on another device or a security key, so you can always get back in. The last one can't be removed.") } } Section { TextField("Server", text: $server, prompt: Text(APIClient.productionBase.absoluteString)) } header: { Text("Server") } footer: { Text("Leave empty for Jobley. Restart the app after changing it.") } } .formStyle(.grouped) } } /// "Let agents make changes" and the log of what agents changed (the house MCP pattern). struct AgentSettingsTab: View { @AppStorage(AgentSettings.allowWritesKey) private var allowWrites = false @State private var log: [AgentLogEntry] = [] var command: String { (Bundle.main.executablePath ?? "/Applications/Jobley.app/Contents/MacOS/Jobley") + " --mcp" } var body: some View { Form { Section { Toggle("Let agents make changes", isOn: $allowWrites) } footer: { Text("Agents can read the board and the review queue. With this on they can also tidy a post's wording and leave notes. They can never publish, send back or unpublish a post, and never see candidates.") } Section("Connect an agent") { Text(command).font(Theme.mono(11)).textSelection(.enabled) Button("Copy command") { Clipboard.copy(command) } Link("How to set it up", destination: URL(string: "https://jobley.ai/mcp/")!) } Section("What agents changed") { if log.isEmpty { Text("Nothing yet.").foregroundStyle(.secondary) } ForEach(log.prefix(50)) { entry in VStack(alignment: .leading, spacing: 2) { Text(entry.summary).font(.callout) Text("\(entry.agent) · \(entry.tool) · \(entry.at.formatted(date: .abbreviated, time: .shortened))").font(.caption).foregroundStyle(.secondary) } } } } .formStyle(.grouped) .onAppear { log = AgentLog.entries() } } } struct AboutSettings: View { @ObservedObject var updates: AppUpdates var body: some View { Form { Section("About") { LabeledContent("Version", value: "\(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") (\(Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? ""))") Link("Source code (public domain, Unlicense)", destination: AppLinks.source) if updates.isAvailable { CheckForUpdatesButton(updates: updates) } } } .formStyle(.grouped) } }