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
feat(ios): add configurable bot shortcuts (#211)
Kai Wub8b02c557e2d
diff --git a/.github/workflows/kit.yml b/.github/workflows/kit.ymlindex f3093959..51895bdd 100644--- a/.github/workflows/kit.yml+++ b/.github/workflows/kit.yml@@ -24,4 +24,16 @@ jobs:- name: Test on an iPhone simulatorrun: |DEVICE=$(xcrun simctl list devices available | grep -m1 -oE 'iPhone [^(]+\(([0-9A-F-]{36})\)' | grep -oE '[0-9A-F-]{36}')- xcodebuild test -scheme CodyncKit-Package -destination "platform=iOS Simulator,id=$DEVICE" -quiet+ xcodebuild test -scheme CodyncKit-Package -destination "platform=iOS Simulator,id=$DEVICE" -resultBundlePath "$RUNNER_TEMP/CodyncKit.xcresult" -quiet+ - name: Report test failures+ if: failure()+ run: |+ if [ -d "$RUNNER_TEMP/CodyncKit.xcresult" ]; then+ xcrun xcresulttool get test-results summary --path "$RUNNER_TEMP/CodyncKit.xcresult"+ fi+ - uses: actions/upload-artifact@v4+ if: failure()+ with:+ name: ios-kit-test-results+ path: ${{ runner.temp }}/CodyncKit.xcresult+ retention-days: 7diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxprojindex 86c2140f..5683d4c3 100644--- a/apps/Codync.xcodeproj/project.pbxproj+++ b/apps/Codync.xcodeproj/project.pbxproj@@ -12,6 +12,7 @@0631979397E0D6822747E03A /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */; };0C920E4962F182ADF75670C5 /* CodyncBot-tablet-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 120FD9DBA315A6DD543463D8 /* CodyncBot-tablet-Ink.ttf */; };0D6E2869DC5A1BC7D6385444 /* CodyncOrb-Dot.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */; };+ 107232310A15C4D9A3BCF466 /* AppStore+Shortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C518FF3FFD22C3A114B6D1B8 /* AppStore+Shortcuts.swift */; };16C24A622E33414C24B0C148 /* AppearanceSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0814BD0C30F01A163FBDF896 /* AppearanceSettings.swift */; };17DD96A91B1EC2AE699F4A2F /* ViewingBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C0E04490F5C56FD070539E6 /* ViewingBadge.swift */; };1855DC364C2F8E5B62878BD8 /* CodyncBot-teardrop-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 203A43D8DF8D3832F95FA837 /* CodyncBot-teardrop-Ink.ttf */; };@@ -64,6 +65,7 @@BCB60463C96AF5725EC4A2C7 /* CodyncBot-hex-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D827E43025A592B41CB68EFD /* CodyncBot-hex-Tint.ttf */; };BF77DD7946621D8818EDAB9B /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A87B0091DAF0E4807D62017 /* SettingsView.swift */; };C7ED489193AC0934515D2E85 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D0DE72EEAEC947C1D3CA237F /* PrivacyInfo.xcprivacy */; };+ E0D116BF893B81AEC0D2135A /* BotShortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 300202AE0BDAB4961D1E4423 /* BotShortcuts.swift */; };E695251CFD06AC6F4E3396B7 /* OpenBotIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4EB0DBA2F08CD7C0E25E30 /* OpenBotIntent.swift */; };E78E3B5FAFEB79F31AAC104D /* CodyncBot-teardrop-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C8F46BD8301E7E2C83C35111 /* CodyncBot-teardrop-Tint.ttf */; };EBB0417A5FB2CE6D514D21BE /* ClerkKit in Frameworks */ = {isa = PBXBuildFile; productRef = D9AB2F442A5F243653EAE936 /* ClerkKit */; };@@ -120,6 +122,7 @@203A43D8DF8D3832F95FA837 /* CodyncBot-teardrop-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-teardrop-Ink.ttf"; sourceTree = "<group>"; };28B2CB561A43ED9F2F1A4391 /* ScreenHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenHelper.swift; sourceTree = "<group>"; };2C0E04490F5C56FD070539E6 /* ViewingBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewingBadge.swift; sourceTree = "<group>"; };+ 300202AE0BDAB4961D1E4423 /* BotShortcuts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotShortcuts.swift; sourceTree = "<group>"; };305DDCC18BB8AA6CD9D19CEF /* WidgetPreviews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetPreviews.swift; sourceTree = "<group>"; };31BFDAD6DCCE1CC98642ACDD /* AccountSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSession.swift; sourceTree = "<group>"; };3F4C4D3B64C608AEF2F85F91 /* Kit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Kit; path = ios/Kit; sourceTree = SOURCE_ROOT; };@@ -154,6 +157,7 @@B97102DEC6029268332DF901 /* AccessRequestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessRequestView.swift; sourceTree = "<group>"; };C3BB9F034194450254CE14EC /* CodyncBot-wedge-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-wedge-Tint.ttf"; sourceTree = "<group>"; };C484135603CEF437C27BE67B /* CodyncBot-blob-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-blob-Ink.ttf"; sourceTree = "<group>"; };+ C518FF3FFD22C3A114B6D1B8 /* AppStore+Shortcuts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppStore+Shortcuts.swift"; sourceTree = "<group>"; };C6B96EE690FC5355C9E3D1B5 /* CodyncBot-wedge-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-wedge-Ink.ttf"; sourceTree = "<group>"; };C8F46BD8301E7E2C83C35111 /* CodyncBot-teardrop-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-teardrop-Tint.ttf"; sourceTree = "<group>"; };CE63C84233B14A2D63640EAA /* Capture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = "<group>"; };@@ -389,6 +393,8 @@isa = PBXGroup;children = (31BFDAD6DCCE1CC98642ACDD /* AccountSession.swift */,+ C518FF3FFD22C3A114B6D1B8 /* AppStore+Shortcuts.swift */,+ 300202AE0BDAB4961D1E4423 /* BotShortcuts.swift */,A65FE0504B741D0B44DB2516 /* CodyncApp.swift */,E3BF4D3B82FE8274F610C703 /* Push.swift */,);@@ -669,8 +675,10 @@7E5F670CFFA0E4373F44DB41 /* AccountSession.swift in Sources */,9BBB2FAEDBD35A83EAB02981 /* AccountSwitcherView.swift in Sources */,00F78E3DAAF66E8E0933D091 /* ActivityGalleryView.swift in Sources */,+ 107232310A15C4D9A3BCF466 /* AppStore+Shortcuts.swift in Sources */,16C24A622E33414C24B0C148 /* AppearanceSettings.swift in Sources */,01A1F820EFEE49A8FCCFC3F3 /* BotListView.swift in Sources */,+ E0D116BF893B81AEC0D2135A /* BotShortcuts.swift in Sources */,7C20764DC05D499075BC5E8C /* CodyncApp.swift in Sources */,2002C16E427B4E4E7279E1C4 /* ComputerStatus.swift in Sources */,5A56EF5D36D12ACCEA100642 /* LanguageSettings.swift in Sources */,diff --git a/apps/ios/App/AppStore+Shortcuts.swift b/apps/ios/App/AppStore+Shortcuts.swiftnew file mode 100644index 00000000..82dd5a96--- /dev/null+++ b/apps/ios/App/AppStore+Shortcuts.swift@@ -0,0 +1,49 @@+import CodyncKit+import CodyncUI+import Foundation+import UIKit++extension AppStore {+ func openShortcutLive(_ bot: ShortcutBotEntity) async throws {+ let (ref, store) = try await shortcutTarget(bot)+ show(ref)+ try await store.requestVoiceCall(to: ref.botId)+ }++ func sendShortcutText(_ text: String, to bot: ShortcutBotEntity, openChat: Bool) async throws -> SendProgress {+ let (ref, store) = try await shortcutTarget(bot)+ if openChat {+ show(ref)+ } else if UIApplication.shared.applicationState == .background {+ // Only the target's pending send retains a connection while the app is backgrounded.+ accounts.setActive(false)+ }+ return try await store.sendAndWait(text, to: ref.botId)+ }++ /// Waits for Clerk to restore the account first: an intent can run before the scene's userID observer.+ private func shortcutTarget(_ bot: ShortcutBotEntity) async throws -> (BotReference, BotStore) {+ let deadline = ContinuousClock.now + .seconds(10)+ while !account.isReady {+ guard ContinuousClock.now < deadline else { throw HostError.unreachable }+ try await Task.sleep(for: .milliseconds(100))+ }+ try Task.checkCancellation()+ switchAccount(to: account.userID)+ guard let ref = bot.reference(in: storage), let store = accounts.store(for: ref.computerId) else {+ throw ShortcutError.botUnavailable+ }+ return (ref, store)+ }++ private func show(_ ref: BotReference) {+ for store in accounts.stores.values { store.screenRequest = nil }+ account.showSwitcher = false+ showComputers = false+ showUsage = false+ marketplace = nil+ tab = .bots+ accounts.selection = ref+ accounts.setActive(true)+ }+}diff --git a/apps/ios/App/BotShortcuts.swift b/apps/ios/App/BotShortcuts.swiftnew file mode 100644index 00000000..f8b5da23--- /dev/null+++ b/apps/ios/App/BotShortcuts.swift@@ -0,0 +1,67 @@+import AppIntents+import CodyncKit+import CodyncUI++struct OpenLiveModeIntent: AppIntent {+ static let title: LocalizedStringResource = "Open Live Mode"+ static let description = IntentDescription("Open a bot's conversation and start voice chat. Connect a computer in Codync first.")+ static let openAppWhenRun = true++ @Parameter(title: "Bot", requestValueDialog: "Which bot would you like to talk to?")+ var bot: ShortcutBotEntity++ static var parameterSummary: some ParameterSummary {+ Summary("Open Live Mode with \(\.$bot)")+ }++ @MainActor func perform() async throws -> some IntentResult {+ try await AppStore.shared.openShortcutLive(bot)+ return .result()+ }+}++struct SendTextToBotIntent: ForegroundContinuableIntent {+ static let title: LocalizedStringResource = "Send Text to Bot"+ static let description = IntentDescription("Send text to a bot in the background. Optionally open its conversation. Finishes when the computer or its offline mailbox accepts the message.")+ static let openAppWhenRun = false+ /// Runs in the background, also from Siri: a locked iPhone must not instruct a coding agent.+ static let authenticationPolicy: IntentAuthenticationPolicy = .requiresAuthentication++ @available(iOS 26.0, *)+ static var supportedModes: IntentModes { [.background, .foreground(.dynamic)] }++ @Parameter(title: "Bot", requestValueDialog: "Which bot should receive the text?")+ var bot: ShortcutBotEntity++ @Parameter(title: "Text", requestValueDialog: "What would you like to send?")+ var text: String++ @Parameter(title: "Open Chat", default: false)+ var openChat: Bool++ static var parameterSummary: some ParameterSummary {+ Summary("Send \(\.$text) to \(\.$bot)") { \.$openChat }+ }++ @MainActor func perform() async throws -> some IntentResult & ProvidesDialog {+ if openChat {+ if #available(iOS 26.0, *) {+ try await continueInForeground(alwaysConfirm: false)+ } else {+ try await requestToContinueInForeground()+ }+ }+ let progress = try await AppStore.shared.sendShortcutText(text, to: bot, openChat: openChat)+ if case .queued = progress { return .result(dialog: "Message queued for the offline computer.") }+ return .result(dialog: "Message sent.")+ }+}++struct BotShortcuts: AppShortcutsProvider {+ static var appShortcuts: [AppShortcut] {+ AppShortcut(intent: OpenLiveModeIntent(), phrases: ["Open Live Mode in \(.applicationName)"],+ shortTitle: "Open Live Mode", systemImageName: "waveform")+ AppShortcut(intent: SendTextToBotIntent(), phrases: ["Send text with \(.applicationName)"],+ shortTitle: "Send Text to Bot", systemImageName: "paperplane")+ }+}diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swiftindex 81d71cb5..8f563559 100644--- a/apps/ios/App/CodyncApp.swift+++ b/apps/ios/App/CodyncApp.swift@@ -128,8 +128,9 @@ final class AppStore {private init() {let session = AccountSession()- let storage = SharedStore.Context(accountID: session.userID)- SharedStore.activeAccountID = session.userID+ // Keep the selected context while Clerk restores: background intents have no scene observer yet.+ let storage = SharedStore.Context(accountID: session.isReady ? session.userID : SharedStore.activeAccountID)+ SharedStore.activeAccountID = storage.accountIDaccount = sessionAnalytics.shared.userID = { [session] in session.userID }Analytics.shared.foregroundState = {diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/ShortcutBotEntity.swift b/apps/ios/Kit/Sources/CodyncKit/Models/ShortcutBotEntity.swiftnew file mode 100644index 00000000..8efbb1d9--- /dev/null+++ b/apps/ios/Kit/Sources/CodyncKit/Models/ShortcutBotEntity.swift@@ -0,0 +1,49 @@+import AppIntents+import Foundation++/// Shortcuts keep the account scope and computer in the ID, just like widget links.+public struct ShortcutBotEntity: AppEntity {+ public static let typeDisplayRepresentation: TypeDisplayRepresentation = "Bot"+ public static let defaultQuery = ShortcutBotQuery()++ public let id: String+ public let name: String+ public let computerName: String++ public var displayRepresentation: DisplayRepresentation {+ DisplayRepresentation(title: "\(name)", subtitle: "\(computerName)")+ }++ public func reference(in storage: SharedStore.Context) -> BotReference? {+ guard let url = URL(string: id), let ref = storage.reference(from: url),+ storage.computers.contains(where: { $0.id == ref.computerId }),+ storage.bots.contains(where: { $0.computerId == ref.computerId && $0.bot.id == ref.botId && !$0.bot.hidden }) else { return nil }+ return ref+ }+}++public struct ShortcutBotQuery: EntityStringQuery {+ public init() {}++ public func entities(for identifiers: [String]) async throws -> [ShortcutBotEntity] {+ let all = Self.bots(in: SharedStore.activeContext)+ return identifiers.compactMap { id in all.first { $0.id == id } }+ }++ public func entities(matching string: String) async throws -> [ShortcutBotEntity] {+ Self.bots(in: SharedStore.activeContext).filter { $0.name.localizedStandardContains(string) }+ }++ public func suggestedEntities() async throws -> [ShortcutBotEntity] {+ Self.bots(in: SharedStore.activeContext)+ }++ static func bots(in storage: SharedStore.Context) -> [ShortcutBotEntity] {+ let computers = storage.computers+ return storage.bots.compactMap { snapshot in+ guard !snapshot.bot.hidden, let computer = computers.first(where: { $0.id == snapshot.computerId }) else { return nil }+ let ref = BotReference(accountId: storage.accountID, computerId: computer.id, botId: snapshot.bot.id)+ return ShortcutBotEntity(id: storage.botURL(ref).absoluteString, name: snapshot.bot.name, computerName: computer.name)+ }.sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }+ }+}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swiftindex a1406bb7..5015a322 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift@@ -35,7 +35,13 @@ public final class AccountStore {public private(set) var approvedAccess: [ComputerID: String] = [:]public var lastError: String?public var selection: BotReference? {- didSet { if let id = selection?.computerId, !retired { storage.lastComputerId = id } }+ didSet {+ guard !retired else { return }+ if selection != oldValue {+ for store in stores.values { store.cancelVoiceCallRequest() }+ }+ if let id = selection?.computerId { storage.lastComputerId = id }+ }}public var onBotUpdated: (@MainActor (BotReference, Bot) -> Void)?diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Connection.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Connection.swiftindex 317b6ecb..abc8c41a 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Connection.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Connection.swift@@ -7,7 +7,9 @@ extension BotStore {public func retire() {let calls = Array(voiceCalls.values)voiceCalls.removeAll()- setActive(false)+ isActive = false+ stopTransport()+ saveCache()retired = truefileDownloads.retire()for call in calls { call.end() }@@ -22,6 +24,7 @@ extension BotStore {client = nilselection = nilscreenRequest = nil+ cancelVoiceCallRequest()}public func setActive(_ active: Bool) {@@ -29,16 +32,14 @@ extension BotStore {isActive = activeif active {// Returning to the foreground must not interrupt a live call's sends.- if voiceCalls.isEmpty || streamTask == nil { restartStream() }- } else if voiceCalls.isEmpty {- // Disconnect so the host knows we're gone and sends pushes instead.- stopTransport()- saveCache()+ if !hasBackgroundWork || streamTask == nil { restartStream() }+ } else {+ stopIfIdle()}}public func restartStream() {- guard isActive || !voiceCalls.isEmpty, !retired else { return }+ guard isActive || hasBackgroundWork, !retired else { return }stopTransport()if connection != .online { setConnection(.connecting) }streamTask = Task { [weak self] in await self?.runStream() }@@ -54,7 +55,26 @@ extension BotStore {func endVoiceCall(_ id: UUID) {guard voiceCalls.removeValue(forKey: id) != nil else { return }- if !isActive && voiceCalls.isEmpty {+ stopIfIdle()+ }++ func beginShortcutSend() throws {+ try Task.checkCancellation()+ guard !retired else { throw CancellationError() }+ shortcutSends += 1+ if streamTask == nil { restartStream() }+ }++ func endShortcutSend() {+ shortcutSends -= 1+ if !retired { stopIfIdle() }+ }++ private var hasBackgroundWork: Bool { !voiceCalls.isEmpty || shortcutSends > 0 }++ private func stopIfIdle() {+ if !isActive && !hasBackgroundWork {+ // Disconnect so the host knows we're gone and sends pushes instead.stopTransport()saveCache()}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swiftindex 737668a7..951f6b8a 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift@@ -62,10 +62,11 @@ extension BotStore {send(text, to: botId, replyTo: nil, nonce: UUID().uuidString, files: files)}- private func send(_ text: String, to botId: String, replyTo: ReplyQuote?, nonce: String, files: [OutgoingFile] = [],- pasted: [String] = []) {+ @discardableResult+ func send(_ text: String, to botId: String, replyTo: ReplyQuote?, nonce: String, files: [OutgoingFile] = [],+ pasted: [String] = []) -> Task<SendProgress, Never>? {let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)- guard !trimmed.isEmpty || !files.isEmpty, !retired else { return }+ guard !trimmed.isEmpty || !files.isEmpty, !retired else { return nil }var data = EntryData(text: trimmed, status: "sending", clientNonce: nonce)// Shown at once; the computer's own quote replaces it.data.replyTo = replyTo@@ -82,13 +83,12 @@ extension BotStore {if let bot = bots[botId] { onSent?(bot, .sending) }// The relay mailbox holds text only: files wait for the computer.if canQueue, files.isEmpty, let remote = transport as? any RemoteTransport {- enqueue(remote, text: trimmed, botId: botId, replyTo: replyTo?.id, nonce: nonce)- return+ return enqueue(remote, text: trimmed, botId: botId, replyTo: replyTo?.id, nonce: nonce)}- deliver(trimmed, botId: botId, replyTo: replyTo?.id, nonce: nonce, pasted: pasted)+ return deliver(trimmed, botId: botId, replyTo: replyTo?.id, nonce: nonce, pasted: pasted)}- private func deliver(_ text: String, botId: String, replyTo: String?, nonce: String, pasted: [String] = []) {+ private func deliver(_ text: String, botId: String, replyTo: String?, nonce: String, pasted: [String] = []) -> Task<SendProgress, Never> {Task {do {// Safe to repeat: the computer skips a nonce it already has.@@ -104,54 +104,72 @@ extension BotStore {ids?.append(id)}}+ try Task.checkCancellation()return try await client.send(botId: botId, text: text, clientNonce: nonce, replyTo: replyTo, attachments: ids,pasted: pasted)}outgoingFiles[nonce] = nilupsert(e)if let bot = bots[botId] { onSent?(bot, .delivered) }+ return .delivered} catch {if outgoingFiles[nonce] != nil { lastError = "Couldn't send the files: \(error.localizedDescription)" }markLocal(nonce: nonce, botId: botId, status: "failed")+ return .failed}}}/// The computer is offline: the message waits, sealed for it, in the relay mailbox.- private func enqueue(_ remote: any RemoteTransport, text: String, botId: String, replyTo: String?, nonce: String) {+ private func enqueue(_ remote: any RemoteTransport, text: String, botId: String, replyTo: String?, nonce: String) -> Task<SendProgress, Never> {markLocal(nonce: nonce, botId: botId, status: "waiting")saveCache()- Task {+ return Task {+ defer { saveCache() }do {+ try Task.checkCancellation()try await remote.enqueue(botId: botId, text: text, clientNonce: nonce, replyTo: replyTo)if let bot = bots[botId] { onSent?(bot, .queued) }+ return .queued} catch MailboxError.hostOnline {// Presence can race the stream state. Wait for the host's events channel// before trying the normal API, instead of turning that race into a failure.markLocal(nonce: nonce, botId: botId, status: "sending")- await deliverWhenOnline(text, botId: botId, replyTo: replyTo, nonce: nonce)+ return await deliverWhenOnline(text, botId: botId, replyTo: replyTo, nonce: nonce)+ } catch is CancellationError {+ // The shortcut that sent it was cancelled: the failed message says enough.+ markLocal(nonce: nonce, botId: botId, status: "failed")+ return .failed} catch {// A dropped relay link: the message's own "Failed to send" and Resend say enough.if (error as? HostError)?.isTransient != true { lastError = error.localizedDescription }markLocal(nonce: nonce, botId: botId, status: "failed")+ return .failed}- saveCache()}}- private func deliverWhenOnline(_ text: String, botId: String, replyTo: String?, nonce: String) async {+ private func deliverWhenOnline(_ text: String, botId: String, replyTo: String?, nonce: String) async -> SendProgress {let deadline = ContinuousClock.now + .seconds(30)- while !retired, connection != .online, ContinuousClock.now < deadline {+ while !retired, !Task.isCancelled, connection != .online, ContinuousClock.now < deadline {try? await Task.sleep(for: .milliseconds(200))}- guard !retired else { return }+ guard !retired, !Task.isCancelled else {+ markLocal(nonce: nonce, botId: botId, status: "failed")+ return .failed+ }guard connection == .online else {lastError = "The computer came online, but the message couldn't be sent. Retry it when the connection is ready."markLocal(nonce: nonce, botId: botId, status: "failed")saveCache()- return+ return .failed+ }+ let delivery = deliver(text, botId: botId, replyTo: replyTo, nonce: nonce)+ return await withTaskCancellationHandler {+ await delivery.value+ } onCancel: {+ delivery.cancel()}- deliver(text, botId: botId, replyTo: replyTo, nonce: nonce)}/// Takes a waiting message back out of the mailbox, unless the computer already has it.diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Shortcuts.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Shortcuts.swiftnew file mode 100644index 00000000..6106e7c9--- /dev/null+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Shortcuts.swift@@ -0,0 +1,82 @@+import CodyncKit+import Foundation++/// Why a Shortcuts action stopped; Shortcuts shows the description.+public enum ShortcutError: LocalizedError {+ case botUnavailable, emptyText, notSent++ public var errorDescription: String? {+ switch self {+ case .botUnavailable: "This bot isn't available. Open Codync and choose a bot again in the shortcut."+ case .emptyText: "Enter some text to send to the bot."+ case .notSent: "Couldn't send the message. Check the conversation and retry the failed message."+ }+ }+}++extension BotStore {+ /// Wait for the connection before choosing normal delivery or the relay mailbox.+ private func prepareShortcut(to botId: String, allowQueue: Bool = false) async throws {+ do {+ let deadline = ContinuousClock.now + Self.actionPatience+ _ = try await ready(until: deadline)+ // Online begins with hello; the bot events can arrive in later stream chunks.+ while bots[botId] == nil && (!caughtUp || rev < catchUpRev) {+ guard mismatch == nil else { throw HostError.upgradeRequired }+ guard ContinuousClock.now < deadline else { throw HostError.unreachable }+ try await Task.sleep(for: .milliseconds(100))+ _ = try await ready(until: deadline)+ }+ } catch HostError.computerOffline where allowQueue && canQueue {+ // Acknowledged by the mailbox through the normal send path below.+ }+ try Task.checkCancellation()+ guard !retired else { throw CancellationError() }+ guard mismatch == nil else { throw HostError.upgradeRequired }+ guard let bot = bots[botId], !bot.hidden else { throw ShortcutError.botUnavailable }+ }++ public func requestVoiceCall(to botId: String) async throws {+ let request = UUID()+ preparingVoiceCall = request+ voiceCallRequest = nil+ defer { if preparingVoiceCall == request { preparingVoiceCall = nil } }+ try await prepareShortcut(to: botId)+ guard preparingVoiceCall == request else { throw CancellationError() }+ Motion.animate { voiceCallRequest = botId }+ }++ /// Leaving a conversation invalidates both its queued request and any connection wait.+ func cancelVoiceCallRequest() {+ preparingVoiceCall = nil+ voiceCallRequest = nil+ }++ /// Consumed once, including when the conversation was already on screen.+ func takeVoiceCallRequest(for botId: String) -> Bool {+ guard voiceCallRequest == botId else { return false }+ voiceCallRequest = nil+ return true+ }++ /// Shortcuts finish only after the host or mailbox has accepted the message.+ public func sendAndWait(_ text: String, to botId: String) async throws -> SendProgress {+ guard !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { throw ShortcutError.emptyText }+ try beginShortcutSend()+ defer { endShortcutSend() }+ try await prepareShortcut(to: botId, allowQueue: true)+ guard let delivery = send(text, to: botId, replyTo: nil, nonce: UUID().uuidString) else {+ throw CancellationError()+ }+ let progress = try await withTaskCancellationHandler {+ let progress = await delivery.value+ try Task.checkCancellation()+ return progress+ } onCancel: {+ delivery.cancel()+ }+ guard !retired else { throw CancellationError() }+ if case .failed = progress { throw ShortcutError.notSent }+ return progress+ }+}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swiftindex 3e5c7d25..e20bc6a5 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift@@ -80,6 +80,10 @@ public final class BotStore {/// The remote screen viewer (iPhone); `codync://screen` opens it.public var screenRequest: ScreenRequest?+ /// A Shortcuts request, consumed by the matching conversation.+ public internal(set) var voiceCallRequest: String?+ @ObservationIgnored var preparingVoiceCall: UUID?+// Platform hooks (push registration, Live Activities, widgets)./// Each time the channel becomes ready.public var onConnected: (@MainActor (BotStore) -> Void)?@@ -114,6 +118,7 @@ public final class BotStore {let end: @MainActor () -> Void}@ObservationIgnored var voiceCalls: [UUID: VoiceCall] = [:]+ @ObservationIgnored var shortcutSends = 0var saveTask: Task<Void, Never>?var rewound = false/// Events stayed undecodable after the rewind.diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swiftindex 9f498e54..e8341e09 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift@@ -67,6 +67,9 @@ public struct ThreadView: View {var conversation: some View {chrome(chat).readingConversation(botId)+ .onChange(of: model.voiceCallRequest, initial: true) { _, _ in+ if model.takeVoiceCallRequest(for: botId) { startShortcutCall() }+ }// The details sheet's Library presents its own downloads..fileExportSheet(model, botId: botId, active: details == nil).codyncSheet(isPresented: $showTrace) {@@ -90,6 +93,19 @@ public struct ThreadView: View {.deleteBotConfirmation($confirmDelete) { dismiss() }}+ /// Open Live Mode from Shortcuts: closes whatever covers the chat, then starts the call.+ private func startShortcutCall() {+ showTrace = false+ botChat = nil+ openArtifact = nil+ editingGroup = false+ details = nil+ confirmNewSession = false+ confirmDelete = nil+ if model.fileDownloads.export?.botId == botId { model.fileDownloads.dismissExport() }+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { calling = true }+ }+// MARK: rows@ViewBuilder func row(_ item: ChatItem) -> some View {diff --git a/apps/ios/Kit/Tests/CodyncKitTests/ShortcutBotTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/ShortcutBotTests.swiftnew file mode 100644index 00000000..2e193288--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncKitTests/ShortcutBotTests.swift@@ -0,0 +1,34 @@+import Foundation+import Testing+@testable import CodyncKit++@Test func shortcutBotsExcludeHiddenAndRemovedComputersAndKeepAccountScope() throws {+ let suite = "ShortcutBots.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let storage = SharedStore.Context(accountID: "alice", suite: suite)+ let other = SharedStore.Context(accountID: "bob", suite: suite)+ let computer = Vectors.shared.computer+ storage.computers = [computer]+ let bot = try JSONDecoder().decode(Bot.self, from: Data(#"{"id":"b1","name":"Ada"}"#.utf8))+ var hidden = bot+ hidden.id = "hidden"+ hidden.hidden = true+ storage.bots = [BotSnapshot(computerId: computer.id, bot: bot),+ BotSnapshot(computerId: computer.id, bot: hidden),+ BotSnapshot(computerId: "removed", bot: bot)]+ let choices = ShortcutBotQuery.bots(in: storage)+ #expect(choices.count == 1)+ let choice = try #require(choices.first)+ #expect(choice.name == "Ada")+ #expect(choice.computerName == computer.name)+ #expect(choice.reference(in: storage)?.botId == "b1")+ other.computers = storage.computers+ other.bots = storage.bots+ #expect(choice.reference(in: other) == nil)+ #expect(ShortcutBotQuery.bots(in: other).first?.id != choice.id)+ storage.bots = []+ #expect(choice.reference(in: storage) == nil)+ storage.bots = [BotSnapshot(computerId: computer.id, bot: bot)]+ storage.computers = []+ #expect(choice.reference(in: storage) == nil)+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/BotShortcutTests.swift b/apps/ios/Kit/Tests/CodyncUITests/BotShortcutTests.swiftnew file mode 100644index 00000000..543d735e--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncUITests/BotShortcutTests.swift@@ -0,0 +1,182 @@+import Foundation+import Testing+@testable import CodyncKit+@testable import CodyncUI++@MainActor+private func shortcutStore(_ storage: SharedStore.Context, remote: FakeRemote) -> BotStore {+ let computer = Computer(id: UUID().uuidString, name: "Mac", signKey: "unused", boxKey: "unused")+ return BotStore(computer: computer, storage: storage) { _ in remote }+}++@MainActor @Test func shortcutSendWaitsForAcceptanceAndPreservesComposerDraft() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.ready(.direct))+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ defer { store.retire() }+ store.setActive(true)+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":1}"#)+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ #expect(await until { store.bots["b1"] != nil })+ store.setComposerDraft("Keep my draft", for: "b1")+ let progress = try await store.sendAndWait(" Shortcut text ", to: "b1")+ if case .delivered = progress {} else { Issue.record("Expected delivered") }+ #expect(await remote.sent == ["Shortcut text"])+ #expect(store.chat("b1").contains { $0.id == "e1" })+ #expect(store.composerDraft(for: "b1") == "Keep my draft")+ await #expect(throws: (any Error).self) { try await store.sendAndWait(" \n", to: "b1") }+ await #expect(throws: (any Error).self) { try await store.sendAndWait("wrong bot", to: "missing") }+ #expect(await remote.sent.count == 1)++ await remote.fail("send", times: 1)+ let cancelled = Task { try await store.sendAndWait("cancel before retry", to: "b1") }+ #expect(await until { await remote.calls.filter { $0 == "send" }.count == 2 })+ cancelled.cancel()+ await #expect(throws: CancellationError.self) { try await cancelled.value }+ try await Task.sleep(for: .milliseconds(600))+ #expect(await remote.sent == ["Shortcut text"])+ #expect(await remote.calls.filter { $0 == "send" }.count == 2)+ #expect(store.chat("b1").contains { $0.data.text == "cancel before retry" && $0.data.status == "failed" })++ try await store.requestVoiceCall(to: "b1")+ #expect(!store.takeVoiceCallRequest(for: "another"))+ #expect(store.takeVoiceCallRequest(for: "b1"))+ #expect(!store.takeVoiceCallRequest(for: "b1"))+ try await store.requestVoiceCall(to: "b1")+ store.retire()+ #expect(store.voiceCallRequest == nil)+ await #expect(throws: (any Error).self) { try await store.requestVoiceCall(to: "b1") }+}++@MainActor @Test func liveShortcutWaitsForBotCatchUpAfterHello() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.ready(.direct))+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ defer { store.retire() }+ store.setActive(true)+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":2}"#)+ #expect(await until { store.connection == .online })+ let opening = Task { try await store.requestVoiceCall(to: "b1") }+ try await Task.sleep(for: .milliseconds(150))+ #expect(store.voiceCallRequest == nil)+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ try await opening.value+ #expect(store.voiceCallRequest == "b1")+ // Global rev can include memory writes that never appear in the bot/entry stream.+ let sent = try await store.sendAndWait("after delayed bot", to: "b1")+ if case .delivered = sent {} else { Issue.record("Expected delivered") }+ await remote.emit(#"{"type":"bot","bot":{"id":"b2","name":"Other","rev":2}}"#)+ #expect(await until { store.caughtUp })+ await #expect(throws: (any Error).self) { try await store.requestVoiceCall(to: "missing") }+}++private struct RefusingSendTransport: HostTransport {+ let remote: FakeRemote+ func call(_ method: String, body: Data, timeout: TimeInterval) async throws -> Data {+ if method == "send" { throw HostError.http(403, "Send refused") }+ return try await remote.call(method, body: body, timeout: timeout)+ }+ func stream(_ request: HostStreamRequest) -> AsyncThrowingStream<Data, Error> { remote.stream(request) }+ func states() -> AsyncStream<LinkState> { remote.states() }+}++@MainActor @Test func shortcutSendThrowsWhenHostRefusesMessage() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.ready(.direct))+ let storage = SharedStore.Context(accountID: nil, suite: suite)+ let computer = Computer(id: UUID().uuidString, name: "Mac", signKey: "unused")+ let store = BotStore(computer: computer, storage: storage) { _ in RefusingSendTransport(remote: remote) }+ defer { store.retire() }+ store.setActive(true)+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":1}"#)+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ #expect(await until { store.caughtUp })+ await #expect(throws: (any Error).self) { try await store.sendAndWait("refused", to: "b1") }+ #expect(store.chat("b1").first?.data.status == "failed")+ #expect(await remote.sent.isEmpty)+}++@MainActor @Test func shortcutSendReportsQueuedOnlyAfterMailboxAccepts() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.hostOffline(lastSeen: nil))+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ defer { store.retire() }+ store.bots["b1"] = try JSONDecoder().decode(Bot.self, from: Data(#"{"id":"b1","name":"Ada"}"#.utf8))+ store.setActive(true)+ #expect(await until { store.canQueue })+ let progress = try await store.sendAndWait("queued text", to: "b1")+ if case .queued = progress {} else { Issue.record("Expected queued") }+ #expect(await remote.enqueued.count == 1)+ #expect(await remote.sent.isEmpty)+ // A cancelled enqueue fails the message without an error dialog.+ await remote.failEnqueue(CancellationError())+ await #expect(throws: ShortcutError.notSent) { try await store.sendAndWait("cancelled", to: "b1") }+ #expect(store.lastError == nil)+ await #expect(throws: (any Error).self) { try await store.requestVoiceCall(to: "b1") }+ #expect(store.voiceCallRequest == nil)+}++@MainActor @Test func backgroundShortcutConnectsWithoutSelectingChatAndDisconnectsAfterAcceptance() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.ready(.direct))+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ defer { store.retire() }+ store.setActive(false)+ let sending = Task { try await store.sendAndWait("background text", to: "b1") }+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":1}"#)+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ let progress = try await sending.value+ if case .delivered = progress {} else { Issue.record("Expected delivered") }+ #expect(store.selection == nil)+ #expect(store.voiceCallRequest == nil)+ #expect(store.shortcutSends == 0)+ #expect(await remote.sent == ["background text"])+ #expect(await until { await remote.shutdownCount == 1 })+}++@MainActor @Test func backgroundShortcutKeepsRetryAliveUntilCancelled() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.ready(.direct))+ // Every retry fails too: on a slow runner a retry 500 ms later would otherwise send before the cancel.+ await remote.fail("send", times: 1_000)+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ defer { store.retire() }+ store.setActive(true)+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":1}"#)+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ let sending = Task { try await store.sendAndWait("cancel background retry", to: "b1") }+ #expect(await until { await remote.calls.contains("send") })+ store.setActive(false)+ #expect(await remote.shutdownCount == 0)+ sending.cancel()+ await #expect(throws: CancellationError.self) { try await sending.value }+ #expect(store.shortcutSends == 0)+ #expect(await until { await remote.shutdownCount == 1 })+ #expect(await remote.sent.isEmpty)+}++@MainActor @Test func retiringStoreClosesTransportDuringBackgroundShortcut() async throws {+ let suite = "BotShortcutTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let remote = FakeRemote(.connecting)+ let store = shortcutStore(SharedStore.Context(accountID: nil, suite: suite), remote: remote)+ store.setActive(false)+ let sending = Task { try await store.sendAndWait("retired", to: "b1") }+ #expect(await until { store.shortcutSends == 1 && store.transport != nil })+ store.retire()+ await #expect(throws: (any Error).self) { try await sending.value }+ #expect(store.shortcutSends == 0)+ #expect(await until { await remote.shutdownCount == 1 })+ #expect(await remote.sent.isEmpty)+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/LiveShortcutNavigationTests.swift b/apps/ios/Kit/Tests/CodyncUITests/LiveShortcutNavigationTests.swiftnew file mode 100644index 00000000..48c74810--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncUITests/LiveShortcutNavigationTests.swift@@ -0,0 +1,45 @@+import CryptoKit+import Foundation+import Testing+@testable import CodyncKit+@testable import CodyncUI++@MainActor @Test(arguments: [false, true])+func leavingLiveShortcutBeforeBotArrivesDoesNotStartCallOnReturn(openAnotherBot: Bool) async throws {+ let suite = "LiveShortcutNavigation.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let storage = SharedStore.Context(accountID: nil, suite: suite)+ let key = Curve25519.Signing.PrivateKey().publicKey.rawRepresentation+ storage.computers = [Computer(id: RelayCrypto.computerId(signKey: key), name: "Mac", signKey: key.base64URL)]+ let remote = FakeRemote(.ready(.direct))+ let accounts = AccountStore(storage: storage, cloud: nil) { computer in+ BotStore(computer: computer, storage: storage) { _ in remote }+ }+ defer { accounts.retire() }+ let computer = try #require(accounts.computers.first)+ let store = try #require(accounts.store(for: computer.id))+ let original = BotReference(accountId: nil, computerId: computer.id, botId: "b1")+ let other = BotReference(accountId: nil, computerId: computer.id, botId: "b2")+ accounts.selection = original+ #expect(await until { await remote.subscribed })+ await remote.emit(#"{"type":"hello","hostId":"h1","rev":2}"#)+ let opening = Task { try await store.requestVoiceCall(to: "b1") }+ #expect(await until { store.preparingVoiceCall != nil })+ accounts.selection = openAnotherBot ? other : nil+ // Returning before the connection completes must not revalidate the abandoned request.+ accounts.selection = original+ await remote.emit(#"{"type":"bot","bot":{"id":"b1","name":"Ada","rev":1}}"#)+ await #expect(throws: CancellationError.self) { try await opening.value }+ #expect(!store.takeVoiceCallRequest(for: "b1"))++ // A fresh shortcut for the same bot still starts normally.+ try await store.requestVoiceCall(to: "b1")+ #expect(store.takeVoiceCallRequest(for: "b1"))+ #expect(!store.takeVoiceCallRequest(for: "b1"))++ // A ready request awaiting the view is invalidated by the same navigation path.+ try await store.requestVoiceCall(to: "b1")+ accounts.selection = openAnotherBot ? other : nil+ accounts.selection = original+ #expect(!store.takeVoiceCallRequest(for: "b1"))+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/StoreTests.swift b/apps/ios/Kit/Tests/CodyncUITests/StoreTests.swiftindex 065efb82..99dd0319 100644--- a/apps/ios/Kit/Tests/CodyncUITests/StoreTests.swift+++ b/apps/ios/Kit/Tests/CodyncUITests/StoreTests.swift@@ -97,7 +97,14 @@ actor FakeRemote: RemoteTransport {nonisolated func computerUpdates() -> AsyncStream<Computer> { AsyncStream { _ in } }- func enqueue(botId: String, text: String, clientNonce: String, replyTo: String?) async throws { enqueued.append(clientNonce) }+ private var enqueueError: (any Error)?+ /// Every later `enqueue` throws `error`.+ func failEnqueue(_ error: any Error) { enqueueError = error }++ func enqueue(botId: String, text: String, clientNonce: String, replyTo: String?) async throws {+ if let enqueueError { throw enqueueError }+ enqueued.append(clientNonce)+ }func cancelQueued(clientNonce: String) async -> MailboxCancel { cancelResult }func listQueued() async throws -> [QueuedItem] { enqueued.map { QueuedItem(nonce: $0, exp: nil, state: "queued") } }diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex a2562e06..13e63f4d 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -18,6 +18,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 新增聯結器失敗後再試一次,會使用你改好的金鑰。- 使用 Hermes Agent 或 Gemini CLI 的 Bot,記憶頁會說明它們自己的記憶由所有用同一個 agent 的 Bot 共用,Codync 沒辦法關掉。- Bot 工作中點一下狀態膠囊,就能在對話裡展開這一輪的思考、工具與 MCP 呼叫,太長時在膠囊內捲動。+- 新增「Open Live Mode」捷徑,選擇 Bot 後直接開啟語音聊天。+- 新增「Send Text to Bot」捷徑,可選擇 Bot 並傳送文字;預設在背景傳送,也可開啟「Open Chat」顯示對話。### en-US- Bots can make artifacts: reports, trackers and dashboards you come back to show as a card in the chat. Open one full screen and message the bot below it to change it; it updates in place.@@ -29,6 +31,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- Trying again after adding a connector failed uses the key you corrected.- For bots that run Hermes Agent or Gemini CLI, Memory explains that the agent's own memory is shared by every bot that runs it and Codync can't turn it off.- While a bot works, tap its status pill to unfold this turn's thinking, tool and MCP calls right in the chat; a long turn scrolls inside the pill.+- Use Open Live Mode in Shortcuts to choose a bot and start voice chat.+- Use Send Text to Bot to choose a bot and send text in the background by default, or enable Open Chat to show the conversation.## 2.24.0diff --git a/docs/README.md b/docs/README.mdindex ca680cf4..9a79d0e6 100644--- a/docs/README.md+++ b/docs/README.md@@ -38,6 +38,7 @@ Source review, a passing build, local integration tests and production acceptanc- [Agent fallbacks](features/agent-fallback.md) (the next agent carries a turn on when the bot's own runs out of usage)- [Routines](features/routines.md)- [Voice calls](features/voice-call.md)+- [iOS Shortcuts](features/ios-shortcuts.md)- [File attachments](features/file-attachments.md)- [Artifacts and the Library](features/artifacts.md)- [Remote screen](features/remote-screen.md) and [computer use](features/computer-use.md)diff --git a/docs/architecture/file-structure.md b/docs/architecture/file-structure.mdindex 64133f07..3ff3a1cc 100644--- a/docs/architecture/file-structure.md+++ b/docs/architecture/file-structure.md@@ -102,7 +102,7 @@ Codync/| Artifacts (`publish_artifact`) and a chat's Library | `host/src/chat/artifacts.rs`, `library.rs`; desktop `apps/desktop/src/renderer/views/library/` (+ `src/main/artifacts.ts`); iPhone `apps/ios/Kit/Sources/CodyncUI/Artifacts/` (+ `Store/ArtifactCache.swift`, `BotStore+Artifacts.swift`); Android `ArtifactCardView.kt`, `ArtifactViewer.kt`, `ArtifactWebView.kt`, `LibrarySheet.kt`, `AppStoreArtifacts.kt` (+ `core/Artifact.kt`, `core/Library.kt`); terminal `host/src/tui/net/artifacts.rs`, `manage/library.rs` || Screen bridge and built-in MCP tools | `host/src/screen/`, `mcp.rs` || Swift transport and cloud API | `apps/ios/Kit/Sources/CodyncKit/Client/` |-| Account aggregation / one host mirror | `apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift` / `BotStore.swift` (+ `BotStore+Connection`, `+Sync`, `+Sending`, `+Actions`, `+Plugins`, `+Cache`) |+| Account aggregation / one host mirror | `apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift` / `BotStore.swift` (+ `BotStore+Connection`, `+Sync`, `+Sending`, `+Actions`, `+Plugins`, `+Cache`, `+Shortcuts`) || iPhone chat, replies, composer and trace | `apps/ios/Kit/Sources/CodyncUI/Thread/` || Reusable iPhone UI chrome | `apps/ios/Kit/Sources/CodyncUI/Chrome.swift`, `Controls.swift`, `Platform.swift` || iOS navigation, pairing, account settings | `apps/ios/Views/RootView.swift`, `BotListView.swift`, `PairingView.swift`, `AccountSwitcherView.swift`, `SettingsView.swift` |diff --git a/docs/features/ios-shortcuts.md b/docs/features/ios-shortcuts.mdnew file mode 100644index 00000000..54151f1b--- /dev/null+++ b/docs/features/ios-shortcuts.md@@ -0,0 +1,20 @@+# iOS Shortcuts++Codync exposes two actions in Apple's Shortcuts app:++- **Open Live Mode**: choose a **Bot**, open its conversation, and start the existing voice chat with the configured voice provider.+- **Send Text to Bot**: choose a **Bot** and supply **Text**. **Open Chat** defaults to off: the message is sent in the background without opening Codync or selecting/reading a conversation. Turn it on to open the chosen chat. The action waits for the computer to accept the message. When the computer is offline and its relay mailbox is available, it confirms that the message was queued instead.++Open Codync and connect a computer first so its bots are available in the picker. In Shortcuts, add an action, search for Codync, and select either action. The Bot parameter can be a saved selection, a compatible shortcut variable, or **Ask Each Time**. Text can be literal text, another action's output, **Shortcut Input**, or **Ask Each Time**. These are two separate actions; no manual URL construction or Bot ID is needed.++Live brings Codync to the foreground. The text action only brings it forward when **Open Chat** is on; on iOS versions before 26, the system may ask to continue in the app. Live uses the normal microphone/speech permission flow; first use may require permission and unlocking the iPhone. Siri phrases are “Open Live Mode in Codync” and “Send text with Codync” (use the installed app name, including Dev). Send Text to Bot always asks to unlock the iPhone first, also from Siri, so a locked iPhone never sends; a simulator run does not verify lock-screen use.++Only visible bots on computers the currently selected account can reach are offered. Stored selections carry the account scope and computer identity; switching accounts, removing the computer, or deleting/hiding the bot requires choosing a current bot again. Bots with the same name show their computer name. An empty list means Codync has no cached eligible bots yet: open Codync and let the computer sync.++The text action uses the existing message path, including nonce-based retry and the relay mailbox. It preserves the conversation's unsent draft. Empty input and delivery failures throw an error rather than report success. Canceling the action stops pending delivery retries; it cannot retract a message already accepted by the computer or mailbox. Live waits for the connection and bot catch-up; an offline computer produces an error rather than starting a disconnected call. Leaving the selected conversation invalidates its pending Live request, including a request still waiting for the connection. Returning to that bot later does not start an abandoned call.++## Ownership and platforms++The adapter lives in the iOS app (`BotShortcuts` and `AppStore+Shortcuts`); the account-scoped entity query lives in CodyncKit. CodyncUI reuses BotStore's sending and connection logic and delivers a one-shot voice request to ThreadView. A pending shortcut send retains its target connection across background transitions, then releases it after acceptance, failure or cancellation; active calls retain their own connection. Both actions wait for account restoration before resolving the target, since an intent can run before the scene restores the account. The host continues to own message handling and agent work; there is no new host method or compatibility-floor change.++This is an iOS system integration. Desktop already offers bot selection, text sending and voice calls in ThreadView/CallView; Android exposes the same existing functions through ChatScreen and its call bar. Neither client runs iOS App Intents. The terminal UI retains its existing bot selection and message sending and has no microphone voice UI. Their shared behavior and layouts are unchanged.diff --git a/docs/features/voice-call.md b/docs/features/voice-call.mdindex e43f8fed..3bdd9519 100644--- a/docs/features/voice-call.md+++ b/docs/features/voice-call.md@@ -4,6 +4,7 @@ A hands-free call with one bot or group from the iPhone, Android or desktop chatOn Linux the desktop app offers only the cloud engines (on-device speech is macOS only). The terminalUI has no calls (no audio stack); it shows the "Voice chat · 00:16" notice like every client.The bot is the same agent on the computer; the call only changes how you talk to it.+On iOS, [Open Live Mode in Shortcuts](ios-shortcuts.md) can select a bot and start this call directly.## On-device voicediff --git a/docs/plans/android-app.md b/docs/plans/android-app.mdindex b9a0f0e4..92cfa241 100644--- a/docs/plans/android-app.md+++ b/docs/plans/android-app.md@@ -77,6 +77,8 @@ was walked through on an emulator against a real host.`AttachmentFiles.kt`).- **Pull to refresh** on the roster and in Settings uses the chat's indicator; iOS uses the system one.- **`computers` / `plugins` links** open over the current tab; iOS switches to Bots first.+- **Shortcuts actions** (Open Live Mode, Send Text to Bot) are an Apple App Intents integration with no+ Android counterpart ([iOS Shortcuts](../features/ios-shortcuts.md)).- **On-device voice**: languages other than English need Android 13+ and Android's on-devicerecognizer; it never falls back to online recognition (iOS may use Apple's servers).- **Jump to latest** is an opaque disc: it sits in the scrolling content, so there's no blur under it.diff --git a/web/content/docs/conversations.mdx b/web/content/docs/conversations.mdxindex 0bcac1d5..61f932d7 100644--- a/web/content/docs/conversations.mdx+++ b/web/content/docs/conversations.mdx@@ -30,6 +30,8 @@ Each chat keeps its own draft on each device, and the draft comes back when youIf a message fails to send, it shows **Failed to send** with buttons to resend or delete it.+**From Shortcuts (iPhone):** Codync's **Send Text to Bot** action sends a message without typing it in the chat. Pick a **Bot** and fill in **Text**. **Open Chat** is off by default, so the message goes out in the background; turn it on to open the chat. The action finishes when the computer accepts the message, or reports it queued when the computer is offline. The iPhone has to be unlocked, also from Siri ("Send text with Codync"). Only the current account's visible bots are listed.+## FilesUse the **+** button left of the message box.diff --git a/web/content/docs/voice.mdx b/web/content/docs/voice.mdxindex eceafed2..6561060e 100644--- a/web/content/docs/voice.mdx+++ b/web/content/docs/voice.mdx@@ -22,6 +22,10 @@ When the call ends, the chat gets a notice such as "Voice chat · 00:16", in eveOn the iPhone, the first call asks for Microphone and Speech Recognition access. The call keeps going if you leave Codync for the Home Screen.+### From Shortcuts (iPhone)++In the Shortcuts app, add Codync's **Open Live Mode** action and pick a **Bot**. Running it opens that bot's chat and starts a call. Siri runs it too: say "Open Live Mode in Codync". The computer has to be online; otherwise the action stops with an error instead of starting a call.+## Choose a voice engineOpen **Voice chat** settings from the call bar's gear, or: