Jobley / app · jobley.ai / Apps / Mac / MacSettings.swift
| 1 | import SwiftUI |
| 2 | import JobleyKit |
| 3 | import JobleyUI |
| 4 | |
| 5 | struct MacSettings: View { |
| 6 | @ObservedObject var updates: AppUpdates |
| 7 | |
| 8 | var body: some View { |
| 9 | TabView { |
| 10 | AccountSettings().tabItem { Label("Account", systemImage: "person.crop.circle") } |
| 11 | AgentSettingsTab().tabItem { Label("Agents", systemImage: "cpu") } |
| 12 | AboutSettings(updates: updates).tabItem { Label("About", systemImage: "info.circle") } |
| 13 | } |
| 14 | .frame(width: 560, height: 520) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | struct AccountSettings: View { |
| 19 | @EnvironmentObject var desk: DeskModel |
| 20 | @AppStorage(APIClient.serverDefaultsKey) private var server = "" |
| 21 | |
| 22 | var body: some View { |
| 23 | AccountForm(curator: desk.curator, server: $server) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | struct AccountForm: View { |
| 28 | @ObservedObject var curator: CuratorModel |
| 29 | @Binding var server: String |
| 30 | |
| 31 | var body: some View { |
| 32 | Form { |
| 33 | Section { |
| 34 | if let me = curator.me { |
| 35 | LabeledContent("Signed in as", value: me.isCurator ? "Curator" : "Moderator · \(me.name)") |
| 36 | LabeledContent("Candidates", value: curator.canSeeCandidates ? "Can see" : "Hidden") |
| 37 | Button("Sign out", role: .destructive) { curator.signOut() } |
| 38 | } else { |
| 39 | PasskeySignIn(curator: curator) |
| 40 | } |
| 41 | } 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.") } |
| 42 | if curator.me != nil { |
| 43 | Section { |
| 44 | PasskeyList(curator: curator) |
| 45 | } 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.") } |
| 46 | } |
| 47 | Section { |
| 48 | TextField("Server", text: $server, prompt: Text(APIClient.productionBase.absoluteString)) |
| 49 | } header: { Text("Server") } footer: { Text("Leave empty for Jobley. Restart the app after changing it.") } |
| 50 | } |
| 51 | .formStyle(.grouped) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | /// "Let agents make changes" and the log of what agents changed (the house MCP pattern). |
| 56 | struct AgentSettingsTab: View { |
| 57 | @AppStorage(AgentSettings.allowWritesKey) private var allowWrites = false |
| 58 | @State private var log: [AgentLogEntry] = [] |
| 59 | |
| 60 | var command: String { (Bundle.main.executablePath ?? "/Applications/Jobley.app/Contents/MacOS/Jobley") + " --mcp" } |
| 61 | |
| 62 | var body: some View { |
| 63 | Form { |
| 64 | Section { |
| 65 | Toggle("Let agents make changes", isOn: $allowWrites) |
| 66 | } footer: { |
| 67 | 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.") |
| 68 | } |
| 69 | Section("Connect an agent") { |
| 70 | Text(command).font(Theme.mono(11)).textSelection(.enabled) |
| 71 | Button("Copy command") { Clipboard.copy(command) } |
| 72 | Link("How to set it up", destination: URL(string: "https://jobley.ai/mcp/")!) |
| 73 | } |
| 74 | Section("What agents changed") { |
| 75 | if log.isEmpty { Text("Nothing yet.").foregroundStyle(.secondary) } |
| 76 | ForEach(log.prefix(50)) { entry in |
| 77 | VStack(alignment: .leading, spacing: 2) { |
| 78 | Text(entry.summary).font(.callout) |
| 79 | Text("\(entry.agent) · \(entry.tool) · \(entry.at.formatted(date: .abbreviated, time: .shortened))").font(.caption).foregroundStyle(.secondary) |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | .formStyle(.grouped) |
| 85 | .onAppear { log = AgentLog.entries() } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | struct AboutSettings: View { |
| 90 | @ObservedObject var updates: AppUpdates |
| 91 | |
| 92 | var body: some View { |
| 93 | Form { |
| 94 | Section("About") { |
| 95 | LabeledContent("Version", value: "\(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") (\(Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? ""))") |
| 96 | Link("Source code (public domain, Unlicense)", destination: AppLinks.source) |
| 97 | if updates.isAvailable { CheckForUpdatesButton(updates: updates) } |
| 98 | } |
| 99 | } |
| 100 | .formStyle(.grouped) |
| 101 | } |
| 102 | } |