Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
Merge in-progress work from the main tree
leepokai810e0133d168
diff --cc apps/ios/Views/AccountSwitcherView.swiftindex 1c030eea,4e8548d5..ef7405ad--- a/apps/ios/Views/AccountSwitcherView.swift+++ b/apps/ios/Views/AccountSwitcherView.swift@@@ -60,7 -65,7 +66,7 @@@ struct AccountSwitcherView: View}}- Section {- CardSection(footer: "Computer connections are saved separately for each account on this iPhone. Pair a computer to see its bots.") {++ CardSection(footer: "Computers are kept separately for each account on this iPhone. Signed in, you also see the computers added to your account.") {NavigationLink {SettingsView()} label: {@@@ -71,20 -80,23 +81,24 @@@}if account.isSignedIn {- Section {- Button("Sign out of this account", role: .destructive) {- CardSection(footer: account.supportsMultipleAccounts ? nil : "Sign out to use a different Google account.") {++ CardSection(footer: "Signing out removes this account's computers and keys from this iPhone."++ + (account.supportsMultipleAccounts ? "" : " Sign out to use a different Google account.")) {+ Button {- Task { await account.signOut() }+ Task { await app.signOut() }+ } label: {+ Text("Sign out of this account")+ .foregroundStyle(Palette.danger)+ .frame(maxWidth: .infinity, alignment: .leading)+ .contentShape(Rectangle())}+ .buttonStyle(.plain).disabled(account.isBusy)- } footer: {- Text("Signing out removes this account's computers and keys from this iPhone."- + (account.supportsMultipleAccounts ? "" : " Sign out to use a different Google account."))}}if !account.isConfigured {- Section {+ CardSection {- Text("Account sign-in isn't configured in this build. Local pairing is available.")+ Text("Account sign-in isn't configured in this build. Pairing with a code works without it.").foregroundStyle(Palette.secondary)}}diff --cc apps/ios/Views/BotListView.swiftindex eeb44893,5495b8d6..8f548c91--- a/apps/ios/Views/BotListView.swift+++ b/apps/ios/Views/BotListView.swift@@@ -2,182 -2,77 +2,168 @@@ import CodyncKiimport CodyncUIimport SwiftUI-/// The roster: every bot is a person you can message (Grok Bot sidebar, phone-sized).+/// The roster: every bot on every computer is a person you can message (Grok Bot sidebar, phone-sized).struct BotListView: View {- @Environment(BotStore.self) private var model- @State private var editing: EditorRequest?- @State private var confirmDelete: Bot?+ @Environment(AppStore.self) private var app+ @Environment(AccountStore.self) private var accounts+ @State private var editing: EditTarget?+ @State private var pickingComputer = false+ @State private var confirmDelete: RosterItem?++ /// Computers that can take a new bot right now.+ private var onlineStores: [BotStore] {+ accounts.computers.compactMap { accounts.store(for: $0.id) }.filter { $0.connection == .online }+ }var body: some View {- let roster = model.roster+ let roster = accounts.roster- List {- // One banner per computer that isn't reachable; the others keep working.- ForEach(accounts.computers) { computer in- if let store = accounts.store(for: computer.id), store.connection != .online {- ConnectionBanner()- .environment(store)- .listRowSeparator(.hidden)- .listRowBackground(Color.clear)- .listRowInsets(EdgeInsets(top: 4, leading: 16, bottom: 4, trailing: 16))+ ScrollView {+ LazyVStack(spacing: 0) {- ConnectionBanner()- .padding(.vertical, 4)++ // One banner per computer that isn't reachable; the others keep working.++ ForEach(accounts.computers) { computer in++ if let store = accounts.store(for: computer.id), store.connection != .online {++ ConnectionBanner()++ .environment(store)++ .padding(.vertical, 4)++ }+ }- }- if roster.isEmpty {- EmptyRoster(canCreate: !onlineStores.isEmpty, hasComputer: !accounts.computers.isEmpty,- create: newBot, showComputers: { app.showComputers = true })- .listRowSeparator(.hidden)- .listRowBackground(Color.clear)- }+ if roster.isEmpty {- EmptyRoster { editing = EditorRequest(BotDraft()) }++ EmptyRoster(canCreate: !onlineStores.isEmpty, hasComputer: !accounts.computers.isEmpty,++ create: newBot, showComputers: { app.showComputers = true })+ }- ForEach(roster) { item in- if let store = accounts.store(for: item.ref.computerId) {- row(item, store: store)- ForEach(roster) { bot in- // A plain button instead of a NavigationLink: same push, no chevron.- Button { model.selection = bot.id } label: {- BotRow(bot: bot)- }- .buttonStyle(.plain)- .contextActions {- [- MenuItem(bot.pinned ? "Unpin" : "Pin", icon: bot.pinned ? "pin.slash" : "pin") { model.setPinned(bot, !bot.pinned) },- MenuItem("Edit profile", icon: "pencil") { editing = EditorRequest(BotDraft(bot)) },- MenuItem("Mark as read", icon: "checkmark.message") { model.markRead(bot.id) },- MenuItem("Hide from list", icon: "eye.slash") { model.setHidden(bot, true) },- MenuItem("Delete", icon: "trash", destructive: true, divider: true) { confirmDelete = bot },- ]++ ForEach(roster) { item in++ if let store = accounts.store(for: item.ref.computerId) {++ row(item, store: store)+ }}}+ .padding(.horizontal, 16)}- .listStyle(.plain)- .scrollContentBackground(.hidden).background(Palette.background)- .navigationTitle(model.hostName)+ .navigationTitle("Bots").navigationBarTitleDisplayMode(.inline).toolbar {ToolbarItem(placement: .topBarLeading) {AccountSwitcherButton()}- // Grok-style bare top bar: no visible title, just the two buttons.+ // Grok-style bare top bar: no visible title, just the buttons.ToolbarItem(placement: .principal) { Color.clear.frame(width: 1, height: 1) }- if model.screen != nil {- ToolbarItem(placement: .topBarTrailing) {- Button("Screen", systemImage: "display") { model.screenRequest = ScreenRequest() }- .disabled(model.connection != .online)- }+ ToolbarItem(placement: .topBarTrailing) {+ Button("Computers", systemImage: "desktopcomputer") { app.showComputers = true }}ToolbarItem(placement: .topBarTrailing) {- Button("New bot", systemImage: "plus") {- editing = EditorRequest(BotDraft())- }- .disabled(model.connection != .online)+ Button("New bot", systemImage: "plus", action: newBot)+ .disabled(onlineStores.isEmpty)}}- .refreshable { model.restartStream() }- .sheet(item: $editing) { request in- NavigationStack { BotEditorView(draft: request.draft) }+ .refreshable {+ for computer in accounts.computers { accounts.store(for: computer.id)?.restartStream() }+ await accounts.refreshCloud()}- .sheet(isPresented: Bindable(model).showPlugins) {+ .sheet(item: $editing) { target in+ if let store = accounts.store(for: target.computerId) {+ NavigationStack { BotEditorView(draft: target.draft) }+ .environment(store)+ .onChange(of: store.selection) { _, botId in+ // A new bot opens its chat, on the computer it was created on.+ guard let botId else { return }+ store.selection = nil+ accounts.selection = BotReference(accountId: accounts.accountId, computerId: target.computerId, botId: botId)+ }+ }+ }+ .sheet(isPresented: $pickingComputer) {NavigationStack {- MarketplaceView { model.showPlugins = false }+ ComputerPicker(stores: onlineStores) { store in+ pickingComputer = false+ editing = EditTarget(computerId: store.computer.id, draft: BotDraft())+ }+ }+ .presentationDetents([.medium])+ }+ .confirmationDialog("Delete \(confirmDelete?.bot.name ?? "bot")?",+ isPresented: Binding(get: { confirmDelete != nil }, set: { if !$0 { confirmDelete = nil } }),+ titleVisibility: .visible) {+ Button("Delete bot and its conversation", role: .destructive) {+ if let item = confirmDelete { accounts.store(for: item.ref.computerId)?.delete(item.bot) }+ }+ } message: {+ Text("Files it changed on your computer stay as they are.")+ }+ }++ private func row(_ item: RosterItem, store: BotStore) -> some View {+ let bot = item.bot+ // A plain button instead of a NavigationLink: same push, no chevron.+ return Button { accounts.selection = item.ref } label: {+ VStack(alignment: .leading, spacing: 0) {+ BotRow(bot: bot)+ ComputerCaption(store: store)+ .padding(.leading, 58)+ .padding(.bottom, 6)+ .offset(y: -6)+ }+ .environment(store)+ }+ .buttonStyle(.plain)- .listRowBackground(Palette.background)- .listRowSeparator(.hidden)- .listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))- .swipeActions(edge: .leading) {- Button(bot.pinned ? "Unpin" : "Pin", systemImage: bot.pinned ? "pin.slash" : "pin") {- store.setPinned(bot, !bot.pinned)- }- .tint(Palette.accentDim)- }- .swipeActions(edge: .trailing) {- Button("Delete", systemImage: "trash", role: .destructive) { confirmDelete = item }- Button("Hide", systemImage: "eye.slash") { store.setHidden(bot, true) }- }- .contextMenu {- Button(bot.pinned ? "Unpin" : "Pin", systemImage: "pin") { store.setPinned(bot, !bot.pinned) }- Button("Edit profile", systemImage: "pencil") { editing = EditTarget(computerId: item.ref.computerId, draft: BotDraft(bot)) }- Button("Mark as read", systemImage: "checkmark.message") { store.markRead(bot.id) }- Button("Hide from list", systemImage: "eye.slash") { store.setHidden(bot, true) }- Button("Delete", systemImage: "trash", role: .destructive) { confirmDelete = item }++ .contextActions {++ [++ MenuItem(bot.pinned ? "Unpin" : "Pin", icon: bot.pinned ? "pin.slash" : "pin") { store.setPinned(bot, !bot.pinned) },++ MenuItem("Edit profile", icon: "pencil") { editing = EditTarget(computerId: item.ref.computerId, draft: BotDraft(bot)) },++ MenuItem("Mark as read", icon: "checkmark.message") { store.markRead(bot.id) },++ MenuItem("Hide from list", icon: "eye.slash") { store.setHidden(bot, true) },++ MenuItem("Delete", icon: "trash", destructive: true, divider: true) { confirmDelete = item },++ ]+ }+ }++ /// A new bot lives on one computer: pick it first when there's a choice.+ private func newBot() {+ let stores = onlineStores+ if stores.count == 1, let store = stores.first {+ editing = EditTarget(computerId: store.computer.id, draft: BotDraft())+ } else if stores.count > 1 {+ pickingComputer = true+ }+ }+}++private struct EditTarget: Identifiable {+ let id = UUID()+ let computerId: ComputerID+ let draft: BotDraft+}++/// "Which computer should it run on?" — only computers that are online.+private struct ComputerPicker: View {+ let stores: [BotStore]+ let pick: (BotStore) -> Void+ @Environment(\.dismiss) private var dismiss++ var body: some View {+ List(stores, id: \.computer.id) { store in+ Button { pick(store) } label: {+ HStack(spacing: 12) {+ ComputerBadge(store.computer, size: 36)+ VStack(alignment: .leading, spacing: 2) {+ Text(store.hostName).font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ Text("\(store.roster.count) bot\(store.roster.count == 1 ? "" : "s")")+ .font(.subheadline).foregroundStyle(Palette.secondary)+ }+ Spacer()+ RouteIcon(route: store.hostRoute).foregroundStyle(Palette.tertiary)+ }}}- .sheet(isPresented: Bindable(model).showProfile) {- NavigationStack { SettingsView() }+ .navigationTitle("Run it on")+ .navigationBarTitleDisplayMode(.inline)+ .toolbar {+ ToolbarItem(placement: .cancellationAction) {+ Button("Close", systemImage: "xmark") { dismiss() }.labelStyle(.iconOnly)+ }}- .deleteBotConfirmation($confirmDelete)}}@@@ -197,17 -87,8 +183,13 @@@ private struct EmptyRoster: View.font(.subheadline).foregroundStyle(Palette.secondary).multilineTextAlignment(.center)- Button("Create your first bot", action: create)- .buttonStyle(.primary)+ if canCreate {+ Button("Create your first bot", action: create)- .buttonStyle(.borderedProminent)- .tint(Palette.accentFill)- .foregroundStyle(Palette.onAccent)++ .buttonStyle(.primary)+ } else if !hasComputer {+ Button("Computers", action: showComputers)- .buttonStyle(.borderedProminent)- .tint(Palette.accentFill)- .foregroundStyle(Palette.onAccent)++ .buttonStyle(.primary)+ }}.frame(maxWidth: .infinity).padding(.vertical, 40)diff --cc apps/ios/Views/PairingView.swiftindex 3d863eb3,76d877b5..ba536059--- a/apps/ios/Views/PairingView.swift+++ b/apps/ios/Views/PairingView.swift@@@ -53,20 -52,12 +53,18 @@@ struct PairingView: ViewButton {scanning = true} label: {- Label("Scan pairing code", systemImage: "qrcode.viewfinder")- .font(.headline)- .frame(maxWidth: .infinity, minHeight: 50)+ Group {+ if pairing {- ProgressView().tint(Palette.onAccent)++ Spinner(size: 18)+ } else {+ Label("Scan pairing code", systemImage: "qrcode.viewfinder")+ }+ }+ .font(.headline)+ .frame(maxWidth: .infinity, minHeight: 50)}- .buttonStyle(.borderedProminent)- .tint(Palette.accentFill)- .foregroundStyle(Palette.onAccent)+ .buttonStyle(.primary)- .disabled(!DataScannerViewController.isSupported)+ .disabled(!DataScannerViewController.isSupported || pairing)HStack {TextField("…or paste a codync://pair link", text: $pasted)diff --cc apps/ios/Views/SettingsView.swiftindex d6792b04,f9111123..75291932--- a/apps/ios/Views/SettingsView.swift+++ b/apps/ios/Views/SettingsView.swift@@@ -11,56 -9,40 +11,59 @@@ struct SettingsView: View@Environment(\.dismiss) private var dismiss@State private var notificationsAllowed: Bool?@State private var addingComputer = false- @State private var confirmForget: Pairing?+ @State private var confirmForget: Computer?+ @State private var confirmRevoke: CloudComputer?+ @State private var access: AccessTarget?var body: some View {- Form {- Section {+ CardForm {- CardSection("Computers on this iPhone", footer: "Each bot runs on its own computer. Tap a computer to view its bots.") {- ForEach(model.computers, id: \.token) { computer in- ComputerRow(computer: computer, active: computer.token == model.pairing?.token) { confirmForget = computer }++ CardSection("Computers", footer: app.account.isSignedIn++ ? "Computers in your account need your OK on the computer before this iPhone can use them."++ : "Each bot runs on its own computer. Sign in to see the computers in your account.") {+ ForEach(accounts.computers) { computer in+ if let store = accounts.store(for: computer.id) {- ComputerRow(store: store, inAccount: cloudComputer(computer.id))- .swipeActions {- Button("Remove", systemImage: "trash", role: .destructive) { confirmForget = computer }- }- .contextMenu { menu(for: computer, store: store) }++ ComputerRow(store: store, inAccount: cloudComputer(computer.id),++ openScreen: { openScreen(store) },++ revoke: cloudComputer(computer.id).flatMap { c in c.access == "granted" ? { confirmRevoke = c } : nil },++ remove: { confirmForget = computer })+ }+ }+ ForEach(accountOnly) { computer in+ AccountComputerRow(computer: computer, ticket: accounts.pendingAccess[computer.computerId],+ ask: { access = AccessTarget(computer: computer) },+ revoke: { confirmRevoke = computer })}Button {addingComputer = true} label: {- Label("Add a computer", systemImage: "plus")+ Label("Pair a computer", systemImage: "qrcode.viewfinder").foregroundStyle(Palette.text)+ .frame(maxWidth: .infinity, alignment: .leading)+ .contentShape(Rectangle())}- } header: {- Text("Computers")- } footer: {- Text(app.account.isSignedIn- ? "Computers in your account need your OK on the computer before this iPhone can use them."- : "Each bot runs on its own computer. Sign in to see the computers in your account.")+ .buttonStyle(.plain)}- Section {- ForEach(onlineStores, id: \.computer.id) { store in- Button {- closeSheets()- app.marketplace = store.computer.id- } label: {- CardSection {- NavigationLink {- MarketplaceView()- } label: {- LinkRow {-- VStack(alignment: .leading, spacing: 2) {- Text(onlineStores.count > 1 ? "Marketplace on \(store.hostName)" : "Marketplace").foregroundStyle(Palette.text)- Text("Marketplace")-- Text("Agents, connectors and skills for your bots").font(.subheadline).foregroundStyle(Palette.secondary)++ if !onlineStores.isEmpty {++ CardSection {++ ForEach(onlineStores, id: \.computer.id) { store in++ Button {++ closeSheets()++ app.marketplace = store.computer.id++ } label: {++ LinkRow {++ VStack(alignment: .leading, spacing: 2) {++ Text(onlineStores.count > 1 ? "Marketplace on \(store.hostName)" : "Marketplace")++ Text("Agents, connectors and skills for your bots").font(.subheadline).foregroundStyle(Palette.secondary)++ }++ }}++ .buttonStyle(.plain)}}- .buttonStyle(.plain)}- Section {+ CardSection {NavigationLink {WidgetGalleryView()} label: {@@@ -72,25 -56,27 +77,28 @@@notificationsRow}- if !model.hiddenBots.isEmpty {+ if !hiddenBots.isEmpty {- Section("Hidden bots") {+ CardSection("Hidden bots") {- ForEach(model.hiddenBots) { bot in+ ForEach(hiddenBots) { item in+ let store = item.store, bot = item.botHStack {CharacterAvatar(bot: bot, size: 28, animated: false)- Text(bot.name)+ VStack(alignment: .leading, spacing: 1) {+ Text(bot.name)+ Text(store.hostName).font(.caption).foregroundStyle(Palette.tertiary)+ }Spacer()- Button("Unhide", systemImage: "eye") { store.setHidden(bot, false) }.labelStyle(.iconOnly)- Button("Unhide", systemImage: "eye") { model.setHidden(bot, false) }++ Button("Unhide", systemImage: "eye") { store.setHidden(bot, false) }+ .labelStyle(.iconOnly)+ .buttonStyle(.plain)+ .foregroundStyle(Palette.text)}}}}- Section {- LabeledContent("App version", value: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")+ CardSection {- if let hello = model.hello {- ValueRow("Host version", value: hello.version)- }+ ValueRow("App version", value: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")Link("Source code", destination: URL(string: "https://github.com/leepokai/Codync")!).foregroundStyle(Palette.text)}@@@ -109,22 -91,13 +115,22 @@@.sheet(isPresented: $addingComputer) {PairingView(introductory: false) { addingComputer = false }}+ .sheet(item: $access) { target in+ NavigationStack { AccessRequestView(computer: target.computer, pending: accounts.pendingAccess[target.id] != nil) }+ }- .confirmationDialog("Remove \(confirmForget?.name ?? "computer")?", isPresented: Binding(get: { confirmForget != nil }, set: { if !$0 { confirmForget = nil } }), titleVisibility: .visible) {- Button("Remove", role: .destructive) {+ .codyncDialog("Remove \(confirmForget?.name ?? "computer")?",+ isPresented: Binding(get: { confirmForget != nil }, set: { if !$0 { confirmForget = nil } }),+ message: "Its bots and conversations stay on that computer. You can pair again any time.") {+ [DialogAction("Remove", destructive: true) {- if let c = confirmForget { model.forget(c) }- if model.pairing == nil { dismiss() }+ if let c = confirmForget { accounts.forget(c.id) }- }- } message: {- Text("Its bots and conversations stay on that computer. You can pair again any time.")++ }]+ }- .confirmationDialog("Revoke this iPhone's access to \(confirmRevoke?.name ?? "the computer")?", isPresented: Binding(get: { confirmRevoke != nil }, set: { if !$0 { confirmRevoke = nil } }), titleVisibility: .visible) {- Button("Revoke", role: .destructive) {++ .codyncDialog("Revoke this iPhone's access to \(confirmRevoke?.name ?? "the computer")?",++ isPresented: Binding(get: { confirmRevoke != nil }, set: { if !$0 { confirmRevoke = nil } }),++ message: "You can ask for access again; the computer will show a new code to confirm.") {++ [DialogAction("Revoke", destructive: true) {+ if let c = confirmRevoke { Task { await app.revokeAccess(c.computerId) } }- }- } message: {- Text("You can ask for access again; the computer will show a new code to confirm.")+ }]}.task {let status = await UNUserNotificationCenter.current().notificationSettings().authorizationStatus@@@ -136,77 -109,9 +142,54 @@@}}+ private struct AccessTarget: Identifiable {+ let computer: CloudComputer+ var id: ComputerID { computer.computerId }+ }++ private func cloudComputer(_ id: ComputerID) -> CloudComputer? {+ accounts.cloudComputers.first { $0.computerId == id }+ }++ /// Account computers this iPhone isn't set up for yet.+ private var accountOnly: [CloudComputer] {+ accounts.cloudComputers.filter { c in !accounts.computers.contains { $0.id == c.computerId } }+ }++ private var onlineStores: [BotStore] {+ accounts.computers.compactMap { accounts.store(for: $0.id) }.filter { $0.connection == .online }+ }++ private struct HiddenBot: Identifiable {+ let store: BotStore+ let bot: Bot+ let id: String+ }++ private var hiddenBots: [HiddenBot] {+ accounts.computers.compactMap { accounts.store(for: $0.id) }.flatMap { store in+ store.hiddenBots.map { HiddenBot(store: store, bot: $0, id: "\(store.computer.id)/\($0.id)") }+ }+ }+- @ViewBuilder private func menu(for computer: Computer, store: BotStore) -> some View {- Menu("Color", systemImage: "paintpalette") {- ForEach(AvatarPalette.colors) { swatch in- Button { accounts.setColor(computer.id, swatch.id) } label: {- // Menus drop SwiftUI tints; an original-mode UIImage keeps the swatch colored.- Label {- Text(swatch.label)- } icon: {- Image(uiImage: UIImage(systemName: computer.color == swatch.id ? "checkmark.circle.fill" : "circle.fill")!- .withTintColor(UIColor(swatch.color), renderingMode: .alwaysOriginal))- }- }- }- }- if store.screen != nil, store.connection == .online {- Button("Screen", systemImage: "display") { openScreen(store) }- }- if let cloud = cloudComputer(computer.id), cloud.access == "granted" {- Button("Revoke this iPhone's access", systemImage: "lock.slash", role: .destructive) { confirmRevoke = cloud }- }- Button("Remove", systemImage: "trash", role: .destructive) { confirmForget = computer }- }-+ /// This screen is a sheet of its own or inside Accounts; the marketplace and screen open over the app.+ private func closeSheets() {+ app.showComputers = false+ app.account.showSwitcher = false+ }++ private func openScreen(_ store: BotStore) {+ closeSheets()+ Task {+ // Let the sheet finish closing before covering the screen.+ try? await Task.sleep(for: .milliseconds(450))+ store.screenRequest = ScreenRequest()+ }+ }+@ViewBuilder private var notificationsRow: some View {if notificationsAllowed == true {- LabeledContent("Notifications", value: "On")+ ValueRow("Notifications", value: "On")} else {Button {if notificationsAllowed == false {@@@ -222,79 -128,76 +206,121 @@@}}+/// A computer this iPhone can use: its connection, how it's reached, and whether it's in the account.private struct ComputerRow: View {- let computer: Pairing- let active: Bool- let onRemove: () -> Void- @Environment(BotStore.self) private var model+ let store: BotStore+ let inAccount: CloudComputer?++ let openScreen: () -> Void++ /// Set when this iPhone's access to the computer can be revoked.++ let revoke: (() -> Void)?++ let remove: () -> Void++ @Environment(AccountStore.self) private var accounts+ @State private var coloring = falsevar body: some View {HStack(spacing: 12) {- ComputerBadge(computer, size: 40)+ ComputerBadge(store.computer, size: 40)VStack(alignment: .leading, spacing: 2) {- Text(computer.name).font(.body.weight(.semibold)).foregroundStyle(Palette.text)- Text(status).font(.subheadline).foregroundStyle(Palette.secondary).lineLimit(1)+ Text(store.hostName).font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ HStack(spacing: 4) {+ Text(detail).lineLimit(1)+ if store.connection == .online { RouteIcon(route: store.hostRoute) }+ }+ .font(.subheadline)+ .foregroundStyle(store.isOffline ? Palette.warning : Palette.secondary)}Spacer()- if !active || model.screen != nil {- Button("Screen", systemImage: "display") { openScreen() }++ if store.screen != nil, store.connection == .online {++ Button("Screen", systemImage: "display", action: openScreen)+ .labelStyle(.iconOnly)+ .buttonStyle(.plain)+ .foregroundStyle(Palette.text)+ }- if active {- Image(systemName: "checkmark").font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ if inAccount != nil {+ Image(systemName: "person.crop.circle.badge.checkmark")+ .foregroundStyle(Palette.tertiary)+ .accessibilityLabel("In your account")}}.padding(.vertical, 2)+ .contentShape(Rectangle())- .onTapGesture { if !active { model.pair(computer) } }+ .contextActions {- [++ var items = [+ MenuItem("Color", icon: "paintpalette") {+ // ponytail: waits for the menu popover to close before opening the swatches; one popover at a time.+ Task {+ try? await Task.sleep(for: .milliseconds(350))+ coloring = true+ }+ },- MenuItem("Remove", icon: "trash", destructive: true, divider: true, action: onRemove),+ ]++ if store.screen != nil, store.connection == .online {++ items.append(MenuItem("Screen", icon: "display", action: openScreen))++ }++ if let revoke {++ items.append(MenuItem("Revoke this iPhone's access", icon: "lock.slash", destructive: true, divider: true, action: revoke))++ }++ items.append(MenuItem("Remove", icon: "trash", destructive: true, divider: revoke == nil, action: remove))++ return items+ }+ .background {+ Color.clear.popover(isPresented: $coloring, arrowEdge: .bottom) {- SwatchPanel(selected: computer.color) { id in++ SwatchPanel(selected: store.computer.color) { id in+ coloring = false- model.setColor(computer, id)++ accounts.setColor(store.computer.id, id)+ }+ .presentationCompactAdaptation(.popover)+ .presentationBackground(Palette.bubbleAgent)+ }+ }}- /// Only the active computer is connected: switch to this one first, then open its screen.- private func openScreen() {- if !active { model.pair(computer) }- model.showProfile = false- Task {- // Let the sheet finish closing before covering the screen.- try? await Task.sleep(for: .milliseconds(450))- model.screenRequest = ScreenRequest()+ private var detail: String {+ guard store.connection == .online else { return store.statusText }+ let count = store.roster.count+ let route = switch store.hostRoute {+ case .direct: " · Direct"+ case .relay: " · Relay"+ default: ""}+ return "\(count) bot\(count == 1 ? "" : "s")\(route)"+ }+}++/// A computer in the account that this iPhone can't use yet.+private struct AccountComputerRow: View {+ let computer: CloudComputer+ let ticket: AccessTicket?+ let ask: () -> Void+ let revoke: () -> Void++ var body: some View {+ HStack(spacing: 12) {+ ComputerBadge(Computer(id: computer.computerId, name: computer.name, signKey: computer.signKey, device: computer.device), size: 40)+ .opacity(0.5)+ VStack(alignment: .leading, spacing: 2) {+ Text(computer.name).font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ Text(detail).font(.subheadline).foregroundStyle(Palette.secondary).lineLimit(2)+ }+ Spacer()+ if ticket != nil {- Button("Code", action: ask).buttonStyle(.bordered)++ Button("Code", action: ask).buttonStyle(.secondary)+ } else if computer.access == "granted" {- Button("Revoke", role: .destructive, action: revoke).buttonStyle(.bordered)++ Button("Revoke", role: .destructive, action: revoke).buttonStyle(.secondary)+ } else {- Button("Ask for access", action: ask).buttonStyle(.bordered)++ Button("Ask for access", action: ask).buttonStyle(.secondary)+ }+ }+ .padding(.vertical, 2)}- private var status: String {- guard active else { return "\(computer.urls.count) address\(computer.urls.count == 1 ? "" : "es")" }- return switch model.connection {- case .online: "Connected · \(model.bots.count) bot\(model.bots.count == 1 ? "" : "s")"- case .connecting: "Connecting…"- case .offline: "Offline"- case .unpaired: "Not paired"+ private var detail: String {+ let online = computer.isOnline ? "Online" : "Offline"+ if let ticket { return "Waiting for your OK on the computer · \(ticket.code)" }+ return switch computer.access {+ case "granted": "Approved for an earlier install of Codync. Revoke it, then ask again."+ case "pending": "\(online) · A request is waiting"+ default: "\(online) · In your account"}}}diff --cc apps/macos/App/CodyncMacApp.swiftindex 9baa0bcb,836f81fb..e5b783fb--- a/apps/macos/App/CodyncMacApp.swift+++ b/apps/macos/App/CodyncMacApp.swift@@@ -457,38 -416,23 +449,38 @@@ struct PairingPanel: View.frame(width: 200, height: 200).padding(10).background(.white, in: RoundedRectangle(cornerRadius: 12))+ .accessibilityLabel("Pairing code for \(store.hostName)")}- Text("Scan with the Codync app or the iPhone Camera.")+ Text("Scan with the Codync app or the iPhone Camera. No Tailscale or open ports needed: your iPhone connects directly on the same Wi-Fi, and through the encrypted relay anywhere else.").font(.caption).foregroundStyle(Palette.secondary)- if info.urls.isEmpty {- Text("No network address found. Connect this Mac to Wi-Fi or Tailscale.")+ .multilineTextAlignment(.center)+ .fixedSize(horizontal: false, vertical: true)+ if store.cloud?.enabled != true {+ Text(info.urls.isEmpty+ ? "No network address found and “Reach from anywhere” is off. Connect to Wi-Fi or turn it on."+ : "“Reach from anywhere” is off, so the iPhone only reaches \(store.hostName) on the same network.").font(.caption).foregroundStyle(Palette.warning)- } else if !info.urls.contains(where: Tailscale.isAddress) {- TailscaleTip()+ .multilineTextAlignment(.center)+ .fixedSize(horizontal: false, vertical: true)}- IconButton("Copy pairing link", systemImage: "doc.on.doc") {- NSPasteboard.general.clearContents()- NSPasteboard.general.setString(info.pairingUrl, forType: .string)+ HStack(spacing: 4) {+ if let expires = info.expiresAt {+ Text("Works once, until \(Date(milliseconds: expires).formatted(date: .omitted, time: .shortened))")+ .font(.caption2).foregroundStyle(Palette.tertiary)+ }+ IconButton("New code", systemImage: "arrow.clockwise") { Task { await load() } }+ IconButton("Copy pairing link", systemImage: "doc.on.doc") {+ NSPasteboard.general.clearContents()+ NSPasteboard.general.setString(info.pairingUrl, forType: .string)+ }}+ } else if let error {+ Text(error).font(.caption).foregroundStyle(Palette.danger).multilineTextAlignment(.center)+ IconButton("Try again", systemImage: "arrow.clockwise") { Task { await load() } }} else {- ProgressView()+ Spinner(size: 20)}}.frame(maxWidth: .infinity)@@@ -521,22 -451,24 +513,22 @@@}}-/// Without Tailscale the iPhone only reaches this Mac on the same Wi-Fi.-private struct TailscaleTip: View {- private static let app = URL(fileURLWithPath: "/Applications/Tailscale.app")- private let installed = FileManager.default.fileExists(atPath: app.path)+/// A pending access request in the menu; the decision happens in the approval sheet.+private struct ApprovalLine: View {+ let approval: Approval+ let review: () -> Voidvar body: some View {- VStack(spacing: 6) {- Text(installed- ? "Tailscale isn't connected. Open it and sign in to reach your bots away from home."- : "Install Tailscale on this Mac and your iPhone to reach your bots away from home.")- .font(.caption)- .foregroundStyle(Palette.tertiary)- .multilineTextAlignment(.center)- if installed {- Button("Open Tailscale") { NSWorkspace.shared.open(Self.app) }.buttonStyle(.secondary)- } else {- Link("Get Tailscale", destination: Tailscale.downloadURL).font(.caption)+ HStack(spacing: 10) {+ Image(systemName: "person.badge.key")+ .foregroundStyle(Palette.warning)+ .accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 1) {+ Text("\(approval.request.deviceName) asks for access").font(.callout.weight(.medium)).foregroundStyle(Palette.text)+ Text(approval.store.hostName).font(.caption).foregroundStyle(Palette.secondary)}+ Spacer()- Button("Review", action: review).controlSize(.small)++ Button("Review", action: review).buttonStyle(.secondary)}}}diff --cc apps/macos/Views/ChatWindow.swiftindex 906d8037,eee13f6d..68056ba6--- a/apps/macos/Views/ChatWindow.swift+++ b/apps/macos/Views/ChatWindow.swift@@@ -341,51 -302,28 +341,48 @@@ private struct ChatSplitView: ViewsidebarWidth = min(sidebarWidth, max(260, $0.width - 420))}.hiddenWindowTitle()- .confirmationDialog("Start a new session?", isPresented: Binding(+ .codyncDialog("Start a new session?", isPresented: Binding(get: { newSessionBot != nil },set: { if !$0 { newSessionBot = nil } }- ), titleVisibility: .visible) {- if let target = newSessionBot {- Button("New session") { target.store.newSession(target.bot.id); newSessionBot = nil }- }- } message: {- Text("The conversation stays here, but the agent starts with a fresh context.")+ ), message: "The conversation stays here, but the agent starts with a fresh context.") {- guard let bot = newSessionBot else { return [] }- return [DialogAction("New session") { model.newSession(bot.id); newSessionBot = nil }]++ guard let target = newSessionBot else { return [] }++ return [DialogAction("New session") { target.store.newSession(target.bot.id); newSessionBot = nil }]+ }+ .confirmationDialog("Delete \(confirmDelete?.bot.name ?? "bot")?", isPresented: Binding(+ get: { confirmDelete != nil },+ set: { if !$0 { confirmDelete = nil } }+ ), titleVisibility: .visible) {+ if let target = confirmDelete {+ Button("Delete bot and its conversation", role: .destructive) { target.store.delete(target.bot) }+ }+ } message: {+ Text("Files it changed on your computer stay as they are.")+ }+ .alert("Something went wrong", isPresented: Binding(get: { errorMessage != nil }, set: { if !$0 { clearErrors() } })) {+ Button("OK", role: .cancel) {}+ } message: {+ Text(errorMessage ?? "")}- .deleteBotConfirmation($confirmDelete)- .storeErrorAlert(model)- .animation(Motion.reduced(Motion.fade, reduceMotion), value: model.selection)+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: accounts.selection).animation(Motion.reduced(Motion.fade, reduceMotion), value: composing)- .onChange(of: model.selection) { _, id in if id != nil { composing = false } }+ .onChange(of: accounts.selection) { _, ref in if ref != nil { composing = false } }+ .onChange(of: storeSelection) { _, ref in+ guard let ref else { return }+ accounts.store(for: ref.computerId)?.selection = nil+ accounts.selection = ref+ }#if DEBUG.onAppear {- // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | plugins | <bot name>+ // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | plugins | computers | <bot name>let target = ProcessInfo.processInfo.environment["CODYNC_DEBUG_OPEN"]if target == "compose" {- composing = true+ compose()} else if target == "plugins" {- showPlugins = true- } else if let target, let bot = model.roster.first(where: { $0.name == target }) {- model.selection = bot.id+ marketplace = host.store?.computer.id+ } else if target == "computers" {+ showComputers = true+ } else if let target, let item = accounts.roster.first(where: { $0.bot.name == target }) {+ accounts.selection = item.ref}}#endifdiff --cc apps/macos/Views/ComputersView.swiftindex f53b6c6f,00000000..cfdae331mode 100644,000000..100644--- a/apps/macos/Views/ComputersView.swift+++ b/apps/macos/Views/ComputersView.swift@@@ -1,608 -1,0 +1,608 @@@+import AppKit+import CodyncKit+import CodyncUI+import SwiftUI+import UniformTypeIdentifiers++/// A computer's name over its bots in the sidebar, with how it's reached.+struct ComputerHeader: View {+ let store: BotStore+ let ssh: Bool++ var body: some View {+ HStack(spacing: 6) {+ ComputerBadge(store.computer, size: 16)+ Text(store.hostName).font(.system(size: 11, weight: .semibold)).lineLimit(1)+ RouteLabel(store: store, ssh: ssh)+ Spacer()+ if store.connection != .online {+ Text(store.statusText).font(.system(size: 11)).foregroundStyle(store.isOffline ? Palette.warning : Palette.tertiary)+ }+ }+ .foregroundStyle(Palette.secondary)+ .padding(.horizontal, 8)+ .padding(.top, 10)+ .padding(.bottom, 2)+ .accessibilityElement(children: .combine)+ .accessibilityAddTraits(.isHeader)+ }+}++/// How this Mac reaches a computer: itself, an SSH tunnel, direct LAN or the encrypted relay.+struct RouteLabel: View {+ let store: BotStore+ let ssh: Bool++ var body: some View {+ if ssh {+ Image(systemName: "terminal").help("Over SSH").accessibilityLabel("Over SSH")+ } else if store.connection == .online {+ RouteIcon(route: store.hostRoute).help(store.hostRoute == .relay ? "Through the encrypted relay" : "Direct connection")+ }+ }+}++// MARK: - Approval++/// A device asks for access through the account (spec §4.2 B). The code is the only thing+/// that tells a real request from a cloud swapping keys, so it's big and Approve is never the default.+struct ApprovalSheet: View {+ let approval: Approval+ @Environment(HostController.self) private var host+ @State private var busy = false+ @State private var error: String?++ private var request: AccessRequest { approval.request }++ var body: some View {+ VStack(spacing: 16) {+ HStack {+ Spacer()+ IconButton("Decide later", systemImage: "xmark") { host.deferApproval(approval) }+ }+ Image(systemName: request.platform == "macos" ? "laptopcomputer" : "iphone")+ .font(.system(size: 40, weight: .light))+ .foregroundStyle(Palette.secondary)+ .accessibilityHidden(true)+ VStack(spacing: 4) {+ Text("\(request.deviceName) wants to use \(approval.store.hostName)")+ .font(.title3.weight(.semibold))+ .multilineTextAlignment(.center)+ if let email = request.email {+ Text("Signed in as \(email)").font(.callout).foregroundStyle(Palette.secondary)+ }+ }+ if let code = request.code {+ Text(Self.spaced(code))+ .font(.system(size: 48, weight: .semibold, design: .monospaced))+ .foregroundStyle(Palette.text)+ .textSelection(.enabled)+ .accessibilityLabel("Code \(code.map(String.init).joined(separator: " "))")+ Text("Approve only if \(request.deviceName) shows exactly this code. If it doesn't, deny: someone may be trying to get in.")+ .font(.callout)+ .foregroundStyle(Palette.secondary)+ .multilineTextAlignment(.center)+ .fixedSize(horizontal: false, vertical: true)+ } else {+ ProgressView().controlSize(.small)+ Text("Waiting for \(request.deviceName) to show its code…")+ .font(.callout)+ .foregroundStyle(Palette.secondary)+ }+ if let error {+ Text(error).font(.caption).foregroundStyle(Palette.danger).multilineTextAlignment(.center)+ }+ HStack(spacing: 12) {+ Button("Deny", role: .destructive) { decide(false) }+ .disabled(busy)+ Button("Approve") { decide(true) }+ .buttonStyle(.borderedProminent)+ .tint(Palette.accentFill)+ .disabled(busy || request.code == nil)+ }+ .controlSize(.large)+ }+ .padding(24)+ .frame(width: 420)+ }++ private func decide(_ approve: Bool) {+ busy = true+ Task {+ defer { busy = false }+ do {+ try await host.decide(approval, approve: approve)+ // The host's accessRequests event removes it; don't wait for that to close.+ host.deferApproval(approval)+ } catch {+ self.error = error.localizedDescription+ }+ }+ }++ private static func spaced(_ code: String) -> String {+ code.count == 6 ? "\(code.prefix(3)) \(code.suffix(3))" : code+ }+}++// MARK: - Computers & devices++/// Computers this Mac manages (itself and SSH), with their account, relay and authorized devices;+/// SSH profiles; and the account's other computers.+struct ComputersView: View {+ let close: () -> Void+ @Environment(HostController.self) private var host+ @Environment(AccountSession.self) private var account+ @State private var editingSSH: SSHProfile?++ var body: some View {+ VStack(spacing: 0) {+ HStack {+ Text("Computers & devices").font(.title2.bold())+ Spacer()+ Button("Done", action: close).keyboardShortcut(.cancelAction)+ }+ .padding(20)+ ScrollView {+ VStack(alignment: .leading, spacing: 22) {+ ForEach(host.managedStores, id: \.computer.id) { store in+ ManagedComputerCard(store: store, ssh: host.isSSH(store.computer.id))+ }+ sshSection+ accountSection+ }+ .padding(.horizontal, 20)+ .padding(.bottom, 20)+ }+ }+ .background(Palette.background)+ .sheet(item: $editingSSH) { profile in+ SSHProfileEditor(profile: profile, isNew: !host.ssh.profiles.contains { $0.id == profile.id }) { editingSSH = nil }+ }+ }++ private var sshSection: some View {+ VStack(alignment: .leading, spacing: 8) {+ HStack {+ SectionTitle("Over SSH")+ Spacer()+ IconButton("Add SSH computer", systemImage: "plus") {+ editingSSH = SSHProfile(host: "", name: "")+ }+ }+ if host.ssh.profiles.isEmpty {+ Text("Run bots on another computer you reach with SSH. It needs codync-host installed; your SSH keys stay on this Mac.")+ .font(.callout)+ .foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ }+ ForEach(host.ssh.profiles) { profile in+ SSHRow(profile: profile) { editingSSH = profile }+ }+ }+ }++ @ViewBuilder private var accountSection: some View {+ let managed = Set(host.managedStores.map(\.computer.id))+ let reached = host.accounts.computers.filter { !managed.contains($0.id) }+ let others = host.accounts.cloudComputers.filter { c in !managed.contains(c.id) && !reached.contains { $0.id == c.id } }+ VStack(alignment: .leading, spacing: 8) {+ HStack {+ SectionTitle("In your account")+ Spacer()+ if account.isSignedIn {+ IconButton("Refresh", systemImage: "arrow.clockwise") { Task { await host.accounts.refreshCloud() } }+ }+ }+ if !account.isSignedIn {+ Text("Sign in to reach the other computers in your account from this Mac.")+ .font(.callout).foregroundStyle(Palette.secondary)+ } else if reached.isEmpty && others.isEmpty {+ Text("No other computers in your account yet.").font(.callout).foregroundStyle(Palette.secondary)+ }+ ForEach(reached) { computer in+ if let store = host.accounts.store(for: computer.id) {+ HStack(spacing: 10) {+ ComputerBadge(store.computer, size: 22)+ VStack(alignment: .leading, spacing: 1) {+ Text(store.hostName).font(.callout.weight(.medium))+ Text(store.statusText).font(.caption).foregroundStyle(Palette.secondary)+ }+ RouteLabel(store: store, ssh: false).foregroundStyle(Palette.tertiary)+ Spacer()+ IconButton("Remove from this Mac", systemImage: "minus.circle") { host.accounts.forget(computer.id) }+ }+ .card()+ }+ }+ ForEach(others) { computer in+ AccountComputerRow(computer: computer)+ }+ }+ }+}++private struct SectionTitle: View {+ let title: String+ init(_ title: String) { self.title = title }+ var body: some View {+ Text(title).font(.headline).foregroundStyle(Palette.text).accessibilityAddTraits(.isHeader)+ }+}++/// An account computer this Mac isn't authorized on: ask, then compare the code shown there.+private struct AccountComputerRow: View {+ let computer: CloudComputer+ @Environment(HostController.self) private var host+ @State private var busy = false++ var body: some View {+ let ticket = host.accounts.pendingAccess[computer.id]+ VStack(alignment: .leading, spacing: 8) {+ HStack(spacing: 10) {+ ComputerBadge(Computer(id: computer.id, name: computer.name, signKey: computer.signKey, device: computer.device), size: 22)+ VStack(alignment: .leading, spacing: 1) {+ Text(computer.name).font(.callout.weight(.medium))+ Text(computer.isOnline ? "Online" : "Offline").font(.caption).foregroundStyle(Palette.secondary)+ }+ Spacer()+ if ticket == nil {+ Button(busy ? "Asking…" : "Ask for access") {+ busy = true+ Task {+ defer { busy = false }+ do { _ = try await host.accounts.requestAccess(computer.id) } catch {+ host.accounts.lastError = error.localizedDescription+ }+ }+ }+ .disabled(busy)+ }+ }+ if let ticket {+ HStack(spacing: 12) {+ Text(ticket.code.count == 6 ? "\(ticket.code.prefix(3)) \(ticket.code.suffix(3))" : ticket.code)+ .font(.system(size: 26, weight: .semibold, design: .monospaced))+ .accessibilityLabel("Code \(ticket.code.map(String.init).joined(separator: " "))")+ Text("Approve on \(computer.name) only if it shows this code.")+ .font(.callout).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ Spacer()+ Button("Cancel request", systemImage: "xmark.circle") {+ Task { await host.accounts.cancelAccess(computer.id) }+ }+ .labelStyle(.iconOnly)+ .buttonStyle(.borderless)+ .help("Cancel request")+ }+ }+ }+ .card()+ }+}++/// This Mac or an SSH computer: relay, account membership, pairing and authorized devices.+private struct ManagedComputerCard: View {+ let store: BotStore+ let ssh: Bool+ @Environment(HostController.self) private var host+ @Environment(AccountSession.self) private var account+ @State private var devices: [AuthorizedDevice]?+ @State private var busy = false+ @State private var showPairing = false+ @State private var confirmRevoke: AuthorizedDevice?+ @State private var confirmUnclaim = false++ private var cloud: CloudStatus? { store.cloud }++ var body: some View {+ VStack(alignment: .leading, spacing: 12) {+ HStack(spacing: 10) {+ ComputerBadge(store.computer, size: 26)+ VStack(alignment: .leading, spacing: 1) {+ Text(store.hostName).font(.headline)+ Text(ssh ? "Over SSH · \(store.statusText)" : "This Mac · \(store.statusText)")+ .font(.caption).foregroundStyle(Palette.secondary)+ }+ Spacer()+ IconButton("Pair iPhone", systemImage: "qrcode", selected: showPairing) { showPairing.toggle() }+ .disabled(store.connection != .online)+ .popover(isPresented: $showPairing, arrowEdge: .bottom) {+ PairingPanel(store: store).frame(width: 300)+ }+ }++ Toggle(isOn: Binding(get: { cloud?.enabled ?? false }, set: { on in run { await host.setCloud(store, enabled: on) } })) {+ VStack(alignment: .leading, spacing: 1) {+ Text("Reach from anywhere")+ Text(cloudLine).font(.caption).foregroundStyle(cloud?.lastError == nil ? Palette.secondary : Palette.warning)+ }+ }- .toggleStyle(.switch)++ .toggleStyle(.codync)+ .disabled(busy || store.connection != .online)++ accountLine++ VStack(alignment: .leading, spacing: 6) {+ Text("Devices that can use \(store.hostName)").font(.subheadline.weight(.semibold))+ if let devices {+ if devices.isEmpty {+ Text("None yet. Pair an iPhone, or approve one from your account.").font(.caption).foregroundStyle(Palette.secondary)+ }+ ForEach(devices) { device in deviceRow(device) }+ } else {+ ProgressView().controlSize(.small)+ }+ }+ }+ .card()+ .task(id: "\(store.computer.id)/\(store.connection == .online)/\(store.accessRequests.count)") { await loadDevices() }+ .confirmationDialog("Revoke \(confirmRevoke?.name ?? "device")?", isPresented: Binding(+ get: { confirmRevoke != nil }, set: { if !$0 { confirmRevoke = nil } }+ ), titleVisibility: .visible) {+ if let device = confirmRevoke {+ Button("Revoke access", role: .destructive) {+ run {+ do { try await store.client?.revokeDevice(device.key) } catch { host.accounts.lastError = error.localizedDescription }+ await loadDevices()+ }+ }+ }+ } message: {+ Text("It disconnects right away and has to pair or ask again.")+ }+ .confirmationDialog("Remove \(store.hostName) from the account?", isPresented: $confirmUnclaim, titleVisibility: .visible) {+ Button("Remove from account", role: .destructive) { run { await host.unclaim(store) } }+ } message: {+ Text("Devices that were approved through the account lose access. Devices paired with a QR code keep it.")+ }+ }++ private var cloudLine: String {+ guard let cloud, cloud.enabled else { return "Off: only devices on the same network reach it." }+ if let error = cloud.lastError { return error }+ return cloud.connected == true ? "Connected to the encrypted relay." : "Connecting to the relay…"+ }++ @ViewBuilder private var accountLine: some View {+ HStack(spacing: 8) {+ if let owner = cloud?.owner {+ Image(systemName: "person.crop.circle.badge.checkmark").foregroundStyle(Palette.secondary).accessibilityHidden(true)+ Text(owner.userId == account.userID ? "In your account" : "In \(owner.email ?? "another") account")+ .font(.callout)+ Spacer()+ Button("Remove from account") { confirmUnclaim = true }+ .disabled(busy || store.connection != .online)+ } else {+ Image(systemName: "person.crop.circle.badge.plus").foregroundStyle(Palette.secondary).accessibilityHidden(true)+ Text(account.isSignedIn ? "Not in your account" : "Sign in to add it to your account").font(.callout)+ Spacer()+ if account.isSignedIn {+ Button(busy ? "Adding…" : "Add to account") { run { await host.claim(store) } }+ .disabled(busy || store.connection != .online)+ }+ }+ }+ }++ private func deviceRow(_ device: AuthorizedDevice) -> some View {+ HStack(spacing: 8) {+ Image(systemName: device.platform == "macos" ? "laptopcomputer" : "iphone")+ .frame(width: 18)+ .foregroundStyle(Palette.secondary)+ .accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 1) {+ Text(device.name).font(.callout)+ Text(detail(device)).font(.caption).foregroundStyle(Palette.tertiary)+ }+ Spacer()+ IconButton("Revoke access", systemImage: "xmark.circle") { confirmRevoke = device }+ }+ .accessibilityElement(children: .combine)+ }++ private func detail(_ device: AuthorizedDevice) -> String {+ var parts = [device.source == "account" ? "Approved through the account" : "Paired with a QR code"]+ if device.connected == true {+ parts.append("connected")+ } else if let seen = device.lastSeenAt {+ parts.append("seen \(RelativeTime.day(Date(milliseconds: seen)))")+ }+ return parts.joined(separator: " · ")+ }++ private func loadDevices() async {+ guard let client = store.client, store.connection == .online else { return }+ devices = (try? await client.devices()) ?? devices+ }++ private func run(_ work: @escaping @MainActor () async -> Void) {+ busy = true+ Task {+ await work()+ busy = false+ }+ }+}++// MARK: - SSH++private struct SSHRow: View {+ let profile: SSHProfile+ let edit: () -> Void+ @Environment(HostController.self) private var host++ var body: some View {+ let status = host.ssh.status(of: profile.id)+ VStack(alignment: .leading, spacing: 8) {+ HStack(spacing: 10) {+ Image(systemName: "terminal").frame(width: 22).foregroundStyle(Palette.secondary).accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 1) {+ Text(profile.name.isEmpty ? profile.host : profile.name).font(.callout.weight(.medium))+ Text(line(status)).font(.caption).foregroundStyle(isProblem(status) ? Palette.warning : Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ }+ Spacer()+ switch status {+ case .connected, .connecting, .retrying:+ IconButton("Disconnect", systemImage: "stop.circle") { host.ssh.disconnect(profile.id) }+ default:+ IconButton("Connect", systemImage: "arrow.clockwise") { host.ssh.connect(profile.id) }+ }+ IconButton("Edit", systemImage: "pencil", action: edit)+ IconButton("Remove", systemImage: "trash") { host.ssh.remove(profile.id) }+ }+ if case let .confirmHostKey(name, fingerprints, _) = status {+ VStack(alignment: .leading, spacing: 6) {+ Text("First connection to \(name). Check that its host key fingerprint matches what the computer's owner sees (`ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub`).")+ .font(.caption).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ ForEach(fingerprints, id: \.self) { Text($0).font(.caption.monospaced()).textSelection(.enabled) }+ HStack {+ Button("Trust and connect") { host.ssh.trustHostKey(profile.id) }+ Button("Cancel") { host.ssh.disconnect(profile.id) }+ }+ .controlSize(.small)+ }+ }+ if status == .notInstalled {+ HStack(spacing: 6) {+ Text(SSH.installCommand)+ .font(.caption.monospaced())+ .textSelection(.enabled)+ .padding(6)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(Palette.codeBackground, in: RoundedRectangle(cornerRadius: 6))+ IconButton("Copy install command", systemImage: "doc.on.doc") {+ NSPasteboard.general.clearContents()+ NSPasteboard.general.setString(SSH.installCommand, forType: .string)+ }+ }+ }+ }+ .card()+ }++ private func line(_ status: SSHComputers.Status) -> String {+ let target = [profile.user.map { "\($0)@" } ?? "", profile.host, profile.port.map { ":\($0)" } ?? ""].joined()+ switch status {+ case .idle: return "\(target) · Not connected"+ case let .connecting(step): return step+ case .confirmHostKey: return "\(target) · Confirm the host key"+ case .connected: return "\(target) · Connected"+ case let .retrying(message): return "\(message) Retrying…"+ case let .failed(message): return message+ case .notInstalled: return "codync-host isn't installed on \(profile.host). Install it there:"+ }+ }++ private func isProblem(_ status: SSHComputers.Status) -> Bool {+ switch status {+ case .retrying, .failed, .notInstalled: true+ default: false+ }+ }+}++/// Add or change an SSH computer. Only fields ssh takes as separate arguments; nothing goes through a shell.+private struct SSHProfileEditor: View {+ @State var profile: SSHProfile+ let isNew: Bool+ let close: () -> Void+ @Environment(HostController.self) private var host+ @State private var port = ""+ @State private var remotePort = ""+ @State private var user = ""+ @State private var chooseKey = false+ @State private var problem: String?++ init(profile: SSHProfile, isNew: Bool, close: @escaping () -> Void) {+ _profile = State(initialValue: profile)+ self.isNew = isNew+ self.close = close+ _port = State(initialValue: profile.port.map(String.init) ?? "")+ _remotePort = State(initialValue: String(profile.remotePort))+ _user = State(initialValue: profile.user ?? "")+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 16) {+ Text(isNew ? "Add SSH computer" : "Edit SSH computer").font(.title3.bold())+ Form {+ TextField("Name", text: $profile.name, prompt: Text("Optional"))+ TextField("Host", text: $profile.host, prompt: Text("SSH alias or hostname"))+ TextField("User", text: $user, prompt: Text("From SSH config"))+ TextField("SSH port", text: $port, prompt: Text("From SSH config"))+ HStack {+ Text("Key")+ Spacer()+ Text(profile.identityFile.map { URL(filePath: $0).lastPathComponent } ?? "ssh-agent / SSH config")+ .foregroundStyle(Palette.secondary)+ IconButton("Choose key file", systemImage: "key") { chooseKey = true }+ if profile.identityFile != nil {+ IconButton("Use ssh-agent", systemImage: "xmark.circle") { profile.identityFile = nil }+ }+ }+ TextField("Codync port", text: $remotePort)+ }+ .formStyle(.grouped)+ Text("Codync opens an SSH tunnel to codync-host on that computer's loopback. It uses your SSH config and ssh-agent; agent forwarding stays off.")+ .font(.caption).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ if let problem {+ Text(problem).font(.caption).foregroundStyle(Palette.danger)+ }+ HStack {+ Spacer()+ Button("Cancel", action: close).keyboardShortcut(.cancelAction)+ Button(isNew ? "Add" : "Save", action: save).keyboardShortcut(.defaultAction)+ }+ }+ .padding(20)+ .frame(width: 460)+ .fileImporter(isPresented: $chooseKey, allowedContentTypes: [.item]) { result in+ if case let .success(url) = result { profile.identityFile = url.path }+ }+ }++ private func save() {+ var p = profile+ p.host = p.host.trimmingCharacters(in: .whitespaces)+ p.name = p.name.trimmingCharacters(in: .whitespaces)+ let u = user.trimmingCharacters(in: .whitespaces)+ p.user = u.isEmpty ? nil : u+ let portText = port.trimmingCharacters(in: .whitespaces)+ if portText.isEmpty {+ p.port = nil+ } else if let n = Int(portText) {+ p.port = n+ } else {+ problem = "The SSH port must be a number."+ return+ }+ guard let remote = Int(remotePort.trimmingCharacters(in: .whitespaces)) else {+ problem = "The Codync port must be a number."+ return+ }+ p.remotePort = remote+ if !isNew, let old = host.ssh.profiles.first(where: { $0.id == p.id }), old.host != p.host || old.port != p.port {+ // A different address may be a different computer: learn its identity again.+ p.computerId = nil+ }+ if let problem = SSH.validate(p) {+ self.problem = problem+ return+ }+ if isNew { host.ssh.add(p) } else { host.ssh.update(p) }+ close()+ }+}++private extension View {+ func card() -> some View {+ padding(12)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 12, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).strokeBorder(Palette.border, lineWidth: 0.5))+ }+}diff --cc host/src/api.rsindex 01e66332,5001e420..91cd5dea--- a/host/src/api.rs+++ b/host/src/api.rs@@@ -164,10 -105,28 +164,30 @@@ fn str_arg<'a>(b: &'a Value, k: &str) -b[k].as_str().ok_or_else(|| anyhow!("`{k}` is required"))}-pub async fn dispatch(hub: &Arc<Hub>, method: &str, b: Value) -> Result<Value> {+/// Runs one API method for `caller` (permissions per spec §6.6).+pub async fn dispatch(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value) -> Result<Value> {+ crate::devices::permit(caller, method)?;Ok(match method {+ "composioCall" => {+ json!({"result": crate::composio::call(&hub.store, str_arg(&b, "botId")?, str_arg(&b, "name")?, &b["arguments"]).await?})+ }+ "composioStatus" => crate::composio::status(&hub.store),+ "setComposioKey" => crate::composio::set_key(&hub.store, b["key"].as_str().unwrap_or_default()).await?,+ "composioToolkits" => {+ crate::composio::toolkits(+ &hub.store,+ b["search"].as_str().unwrap_or_default(),+ b["cursor"].as_str().unwrap_or_default(),+ )+ .await?+ }+ "composioConnect" => crate::composio::connect(&hub.store, str_arg(&b, "toolkit")?).await?,+ "composioConnectFields" => {+ let fields = b["fields"].as_object().ok_or_else(|| anyhow!("`fields` is required"))?;+ crate::composio::connect_with_fields(&hub.store, str_arg(&b, "toolkit")?, str_arg(&b, "mode")?, fields)+ .await?+ }+ "composioConnection" => crate::composio::connection(&hub.store, str_arg(&b, "id")?).await?,"teamCall" => crate::team::call(hub, str_arg(&b, "botId")?, str_arg(&b, "name")?, &b["arguments"]).await?,"hello" => {let port = hub.port;diff --cc host/src/main.rsindex 3d8e4898,7fac3784..205b4429--- a/host/src/main.rs+++ b/host/src/main.rs@@@ -5,13 -5,9 +5,14 @@@ mod apimod auth;mod backends;mod bot;+mod channel;+mod cloud;+ mod composio;mod context;+mod crypto;+mod devices;mod hub;+mod identity;mod market;mod mcp;mod memory;