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
fix(ios): take CallKit out of voice calls, keep the Live Activity
leepokai4f8fe44a5863
diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/CallAudio.swift b/apps/ios/Kit/Sources/CodyncUI/Call/CallAudio.swiftindex 443e035c..c3993559 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/CallAudio.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/CallAudio.swift@@ -1,7 +1,6 @@import AVFoundationimport Foundationimport os-@preconcurrency import WebRTCprivate let log = Logger(subsystem: "com.pokai.Codync", category: "Call")@@ -30,63 +29,27 @@ enum AudioInterruption {case ended(shouldResume: Bool)}-/// The call's audio session, set up the same way for every engine. Under CallKit the system activates it (and-/// deactivates it as its call ends or is held), and WebRTC's audio runs only while it's active; otherwise the engines-/// activate and release it.+/// The call's audio session, set up the same way for every engine; each activates it as its audio starts and+/// releases it as it stops (OpenAI's WebRTC manages its own, with the same options).@MainActorenum CallAudioSession {/// The category options of every engine's audio, WebRTC's too.static let options: AVAudioSession.CategoryOptions = [.defaultToSpeaker, .allowBluetoothHFP]- /// A CallKit call carries the audio (`CallKitCalls`). WebRTC then waits for the system's activation- /// (`useManualAudio`) instead of activating the session itself, and deactivating it as a connection closes.- static var systemRuns = false {- didSet {- let webRTC = RTCAudioSession.sharedInstance()- webRTC.isAudioEnabled = false- webRTC.useManualAudio = systemRuns- }- }-- /// Sets the call's category; CallKit activates the session it finds configured.- static func configure() throws {- try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .voiceChat, options: options)- }-- /// Before an engine's audio starts or resumes: the session set up, and active unless the system activates it.+ /// Before an engine's audio starts or resumes.static func activate() throws {- try configure()- guard !systemRuns else { return }- try AVAudioSession.sharedInstance().setActive(true)+ let session = AVAudioSession.sharedInstance()+ try session.setCategory(.playAndRecord, mode: .voiceChat, options: options)+ try session.setActive(true)}- /// After an engine stops: deactivates the session unless the system runs the call.+ /// After an engine stops.static func release() {- guard !systemRuns else { return }try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)}-- /// CallKit activated the session (the call started, or came off hold): WebRTC's audio may run.- static func systemActivated(_ session: AVAudioSession) {- let webRTC = RTCAudioSession.sharedInstance()- webRTC.audioSessionDidActivate(session)- webRTC.isAudioEnabled = true- }-- /// CallKit deactivated the session (held, or ended).- static func systemDeactivated(_ session: AVAudioSession) {- let webRTC = RTCAudioSession.sharedInstance()- webRTC.audioSessionDidDeactivate(session)- webRTC.isAudioEnabled = false- }}-extension Notification.Name {- /// CallKit put the call on hold (`held` true: a phone call took over) or gave it its audio back after one.- static let callHeld = Notification.Name("CodyncCallHeld")-}--/// The audio session's events a call follows: interruptions (also CallKit holding the call), and `engine`+/// The audio session's events a call follows: interruptions, and `engine`/// reconfiguring (a route change such as AirPods, voice processing settling), which stops it.@MainActorfinal class AudioSessionEvents {@@ -106,10 +69,6 @@ final class AudioSessionEvents {}}})- observers.append(center.addObserver(forName: .callHeld, object: nil, queue: .main) { note in- let held = note.userInfo?["held"] as? Bool == true- MainActor.assumeIsolated { interrupted(held ? .began : .ended(shouldResume: true)) }- })if let engine {observers.append(center.addObserver(forName: .AVAudioEngineConfigurationChange, object: engine, queue: .main) { _ inMainActor.assumeIsolated { reconfigured() }diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swiftindex 12002dc9..f751eac5 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift@@ -28,12 +28,8 @@ struct CallView: View {@State private var reported = false/// Each engine's `voice_call_quality`.@State private var quality = CallQuality()- /// The call as the system shows it (CallKit); nil where CallKit isn't offered (mainland China) or it refused.- @State private var system: CallKitCall?/// The bot's Live Activity showing the call.@State private var activity: CallActivity?- /// The call view went away (before its engine may have started).- @State private var closed = falseprivate var bot: Bot? { model.bots[botId] }private var call: String { callID.uuidString }@@ -63,21 +59,9 @@ struct CallView: View {let ref = BotReference(accountId: model.storage.accountID, computerId: model.computer.id, botId: botId)activity = CallActivity(bot: bot, computerId: model.computer.id, link: model.storage.botURL(ref))}- Task {- // The system runs the call where it may: the engine starts once its audio session is up.- if await SystemCallPolicy.allowed(), !closed {- let system = CallKitCalls.shared.start(id: callID, name: bot?.name ?? "Codync")- system.onEnd = close- system.onMute = { muted in session?.muted = muted }- self.system = system- await system.audioReady()- }- guard !closed else { return }- begin(cloud: VoiceSettings.provider)- }+ begin(cloud: VoiceSettings.provider)}.onDisappear {- closed = truesession?.end()countCloudMinutes()isSpeaking = false@@ -85,8 +69,6 @@ struct CallView: View {model.endVoiceCall(callID)link?.end(seconds: Int(Date.now.timeIntervalSince(startedAt)))quality.report()- // After the engine let go of the audio: CallKit deactivates the session as its call ends.- system?.end()activity?.end()}.onChange(of: session?.phase) { _, phase in@@ -101,7 +83,6 @@ struct CallView: View {reported = trueAnalytics.shared.capture(.voiceCallStarted(session.analyticsName))model.callStarted(botId, call: call)- system?.connected()}// A cloud engine that can't start or drops mid-call hands over to on-device voice.if case .failed(let message, _) = phase, let provider = session?.provider {@@ -215,7 +196,6 @@ struct CallView: View {let muted = session?.muted == trueround(muted ? "Unmute" : "Mute", muted ? "mic.slash" : "mic", on: muted) {session?.muted.toggle()- system?.setMuted(session?.muted == true)}Button(action: close) {Image(systemName: "xmark")diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/OpenAIRealtimeEngine.swift b/apps/ios/Kit/Sources/CodyncUI/Call/OpenAIRealtimeEngine.swiftindex 05790cf6..56109cab 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/OpenAIRealtimeEngine.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/OpenAIRealtimeEngine.swift@@ -78,7 +78,6 @@ final class OpenAIRealtimeEngine: VoiceEngine {}private func connect(secret: String) async throws {- // Under CallKit, WebRTC's audio waits for the system's activation (`CallAudioSession`).let audio = RTCAudioSessionConfiguration.webRTC()audio.categoryOptions = CallAudioSession.optionsRTCAudioSessionConfiguration.setWebRTC(audio)diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/SystemCall.swift b/apps/ios/Kit/Sources/CodyncUI/Call/SystemCall.swiftdeleted file mode 100644index 4f76e97a..00000000--- a/apps/ios/Kit/Sources/CodyncUI/Call/SystemCall.swift+++ /dev/null@@ -1,231 +0,0 @@-import AVFoundation-import CallKit-import Foundation-import StoreKit-import os--private let log = Logger(subsystem: "com.pokai.Codync", category: "Call")--/// Where CallKit may carry calls: not in apps offered in mainland China's App Store, which doesn't allow CallKit.-enum SystemCallPolicy {- static func allowed(storefront: String?, region: String?) -> Bool {- if let storefront { return storefront != "CHN" }- return region != "CN"- }-- static func allowed() async -> Bool {- allowed(storefront: await Storefront.current?.countryCode, region: Locale.current.region?.identifier)- }-}--/// The app's one CallKit provider; a call starts as an outgoing call to its bot.-@MainActor-final class CallKitCalls: NSObject {- static let shared = CallKitCalls()-- private let provider: CXProvider- private let controller = CXCallController()- private var current: CallKitCall?-- private override init() {- let config = CXProviderConfiguration()- config.supportsVideo = false- config.maximumCallGroups = 1- config.maximumCallsPerCallGroup = 1- config.supportedHandleTypes = [.generic]- config.includesCallsInRecents = false- provider = CXProvider(configuration: config)- super.init()- provider.setDelegate(self, queue: nil)- }-- func start(id: UUID, name: String) -> CallKitCall {- current?.systemEnded()- let call = CallKitCall(id: id, calls: self)- current = call- CallAudioSession.systemRuns = true- let start = CXStartCallAction(call: id, handle: CXHandle(type: .generic, value: name))- controller.request(CXTransaction(action: start)) { error in- guard let error else { return }- Task { @MainActor in- log.info("CallKit didn't take the call: \(error.localizedDescription, privacy: .public)")- self.drop(call)- }- }- return call- }-- fileprivate func connected(_ call: CallKitCall) {- provider.reportOutgoingCall(with: call.id, connectedAt: nil)- }-- fileprivate func request(_ action: CXCallAction) {- controller.request(CXTransaction(action: action)) { error in- if let error { log.info("CallKit action failed: \(error.localizedDescription, privacy: .public)") }- }- }-- /// CallKit refused the call or lost it (the Simulator, CallKit unavailable, its daemon restarted): the call goes- /// on without the system's.- private func drop(_ call: CallKitCall) {- call.declined()- finished(call)- }-- /// The call is over for CallKit (ended, or never taken): the engines manage the audio session again.- private func finished(_ call: CallKitCall) {- call.systemEnded()- guard current === call else { return }- current = nil- CallAudioSession.systemRuns = false- }-}--extension CallKitCalls: @preconcurrency CXProviderDelegate {- func providerDidReset(_ provider: CXProvider) {- if let current { drop(current) }- }-- func provider(_ provider: CXProvider, perform action: CXStartCallAction) {- do { try CallAudioSession.configure() } catch {- log.error("call audio category: \(error.localizedDescription, privacy: .public)")- }- provider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: nil)- action.fulfill()- }-- func provider(_ provider: CXProvider, perform action: CXEndCallAction) {- if let current, current.id == action.callUUID { finished(current) }- action.fulfill()- }-- func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {- if let current, current.id == action.callUUID { current.onMute?(action.isMuted) }- action.fulfill()- }-- func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) {- if let current, current.id == action.callUUID { current.held(action.isOnHold) }- action.fulfill()- }-- // Every activation has its deactivation, also after the call is over: WebRTC counts them.- func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {- CallAudioSession.systemActivated(audioSession)- current?.audioActivated()- }-- func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {- CallAudioSession.systemDeactivated(audioSession)- current?.audioDeactivated()- }-}--/// The call as the system shows it (CallKit): on the Lock Screen and in the Dynamic Island, ended or muted from there-/// or from AirPods, held by a phone call, with the audio session the system activates for it.-@MainActor-final class CallKitCall {- /// The system ended the call (Lock Screen, Dynamic Island, AirPods, another call answered instead).- var onEnd: (() -> Void)?- /// The system muted or unmuted the call.- var onMute: ((Bool) -> Void)?- let id: UUID- private weak var calls: CallKitCalls?- private var over = false- /// The call got its audio session or connected: from here an end from the system is the user's.- private var live = false- private var audio = Audio.awaited- /// Taken off hold while the system still had its audio: the engine picks up once it's back.- private var resumesOnAudio = false- private var waiting: [CheckedContinuation<Void, Never>] = []-- /// How long `audioReady` waits for the system's activation (it never comes on the Simulator).- static var audioTimeout: Duration = .seconds(1.5)-- /// The call's audio session as the system hands it over.- private enum Audio { case awaited, active, takenAway }-- /// `calls` is nil only in tests.- init(id: UUID, calls: CallKitCalls? = nil) {- self.id = id- self.calls = calls- }-- /// The call reached its voice.- func connected() {- guard !over else { return }- live = true- calls?.connected(self)- }-- /// The app muted or unmuted the call.- func setMuted(_ muted: Bool) {- guard !over else { return }- calls?.request(CXSetMutedCallAction(call: id, muted: muted))- }-- /// The app hung up.- func end() {- guard !over else { return }- over = true- calls?.request(CXEndCallAction(call: id))- resumeWaiting()- }-- /// Returns once the system activated the call's audio session, or after `audioTimeout` if it doesn't.- func audioReady() async {- guard audio == .awaited, !over else { return }- Task { [weak self] in- try? await Task.sleep(for: Self.audioTimeout)- self?.resumeWaiting()- }- await withCheckedContinuation { waiting.append($0) }- }-- func audioActivated() {- audio = .active- live = true- resumeWaiting()- if resumesOnAudio {- resumesOnAudio = false- Self.post(held: false)- }- }-- func audioDeactivated() {- audio = .takenAway- }-- /// CallKit held the call (a phone call took over) or took it off hold: the engine pauses at once, and picks up- /// again once the system has given the audio back, so it doesn't start on a session that isn't active.- func held(_ onHold: Bool) {- resumesOnAudio = !onHold && audio == .takenAway- if !resumesOnAudio { Self.post(held: onHold) }- }-- /// CallKit refused the call: it goes on without the system's.- func declined() {- over = true- resumeWaiting()- }-- /// CallKit ended the call. Before the call ever got its audio or connected, that's CallKit dropping it (the- /// Simulator ends calls right after starting them) and the call goes on without the system's; after, the app- /// hangs up too unless it started the ending.- func systemEnded() {- resumeWaiting()- guard !over else { return }- over = true- if live { onEnd?() } else { log.info("CallKit ended the call before it connected; going on without it") }- }-- private func resumeWaiting() {- let continuations = waiting- waiting = []- for continuation in continuations { continuation.resume() }- }-- private static func post(held: Bool) {- NotificationCenter.default.post(name: .callHeld, object: nil, userInfo: ["held": held])- }-}diff --git a/apps/ios/Kit/Tests/CodyncUITests/CallActivityTests.swift b/apps/ios/Kit/Tests/CodyncUITests/CallActivityTests.swiftnew file mode 100644index 00000000..ae1ac7f1--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncUITests/CallActivityTests.swift@@ -0,0 +1,36 @@+import Foundation+import Testing+@testable import CodyncKit+@testable import CodyncUI++@MainActor @Test func theLiveActivityFollowsTheCallsPhase() {+ #expect(CallActivity.state(.starting) == .connecting)+ #expect(CallActivity.state(.reconnecting) == .connecting)+ #expect(CallActivity.state(.listening) == .listening)+ #expect(CallActivity.state(.speaking) == .speaking)+ #expect(CallActivity.state(.interrupted) == .paused)+ #expect(CallActivity.state(.failed("x", .connection)) == nil)+}++@MainActor @Test func anActivityShowsTheCallOnlyWhileThisPhoneIsOnIt() throws {+ var bot = try #require(Bot.widgetPreview.first)+ bot.id = "call-activity-test"+ // The computer's push carries no call; one left on the activity by a call that's over goes.+ let pushed = BotActivityAttributes.ContentState(status: "working", activity: "", startedAt: nil)+ let leftover = CallActivity.merge(pushed, call: .listening, since: .now)+ #expect(CallActivity.withCall(leftover, botId: bot.id) == pushed)++ let older = CallActivity(bot: bot, computerId: "computer", link: nil)+ older.phase(.speaking)+ let shown = CallActivity.withCall(pushed, botId: bot.id)+ #expect(shown.call == .speaking && shown.callStartedAt != nil && shown.status == "working")+ // A newer call with the bot outlives the older one ending.+ let newer = CallActivity(bot: bot, computerId: "computer", link: nil)+ newer.phase(.listening)+ older.end()+ #expect(CallActivity.isLive(botId: bot.id))+ #expect(CallActivity.withCall(pushed, botId: bot.id).call == .listening)+ newer.end()+ #expect(!CallActivity.isLive(botId: bot.id))+ #expect(CallActivity.withCall(leftover, botId: bot.id) == pushed)+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/SystemCallTests.swift b/apps/ios/Kit/Tests/CodyncUITests/SystemCallTests.swiftdeleted file mode 100644index b62a92b2..00000000--- a/apps/ios/Kit/Tests/CodyncUITests/SystemCallTests.swift+++ /dev/null@@ -1,119 +0,0 @@-import Foundation-import Testing-@testable import CodyncKit-@testable import CodyncUI--@Test func callKitStaysOffWhereTheAppStoreIsMainlandChinas() {- #expect(!SystemCallPolicy.allowed(storefront: "CHN", region: "US"))- #expect(SystemCallPolicy.allowed(storefront: "TWN", region: "CN"))- // Without a storefront (no App Store account), the region decides.- #expect(!SystemCallPolicy.allowed(storefront: nil, region: "CN"))- #expect(SystemCallPolicy.allowed(storefront: nil, region: "HK"))- #expect(SystemCallPolicy.allowed(storefront: nil, region: nil))-}--@MainActor @Test func theLiveActivityFollowsTheCallsPhase() {- #expect(CallActivity.state(.starting) == .connecting)- #expect(CallActivity.state(.reconnecting) == .connecting)- #expect(CallActivity.state(.listening) == .listening)- #expect(CallActivity.state(.speaking) == .speaking)- #expect(CallActivity.state(.interrupted) == .paused)- #expect(CallActivity.state(.failed("x", .connection)) == nil)-}--@MainActor @Test func anActivityShowsTheCallOnlyWhileThisPhoneIsOnIt() throws {- var bot = try #require(Bot.widgetPreview.first)- bot.id = "call-activity-test"- // The computer's push carries no call; one left on the activity by a call that's over goes.- let pushed = BotActivityAttributes.ContentState(status: "working", activity: "", startedAt: nil)- let leftover = CallActivity.merge(pushed, call: .listening, since: .now)- #expect(CallActivity.withCall(leftover, botId: bot.id) == pushed)-- let older = CallActivity(bot: bot, computerId: "computer", link: nil)- older.phase(.speaking)- let shown = CallActivity.withCall(pushed, botId: bot.id)- #expect(shown.call == .speaking && shown.callStartedAt != nil && shown.status == "working")- // A newer call with the bot outlives the older one ending.- let newer = CallActivity(bot: bot, computerId: "computer", link: nil)- newer.phase(.listening)- older.end()- #expect(CallActivity.isLive(botId: bot.id))- #expect(CallActivity.withCall(pushed, botId: bot.id).call == .listening)- newer.end()- #expect(!CallActivity.isLive(botId: bot.id))- #expect(CallActivity.withCall(leftover, botId: bot.id) == pushed)-}--@MainActor @Test func callKitEndingTheCallHangsUpOnlyOnceTheCallWasLive() {- var hungUp = 0- func systemEnds(after setUp: (CallKitCall) -> Void) {- let call = CallKitCall(id: UUID())- call.onEnd = { hungUp += 1 }- setUp(call)- call.systemEnded()- }- // Ended before it got its audio or connected: CallKit dropped it (the Simulator), and the call goes on.- systemEnds { _ in }- #expect(hungUp == 0)- systemEnds { $0.connected() }- #expect(hungUp == 1)- systemEnds { $0.audioActivated() }- #expect(hungUp == 2)- // The app hung up, or CallKit refused the call: nothing more to end.- systemEnds { $0.connected(); $0.end() }- systemEnds { $0.connected(); $0.declined() }- #expect(hungUp == 2)-}--@MainActor @Test func theCallWaitsForCallKitsAudioAtMostAMoment() async throws {- let timeout = CallKitCall.audioTimeout- defer { CallKitCall.audioTimeout = timeout }- let clock = ContinuousClock()-- CallKitCall.audioTimeout = .seconds(5)- let call = CallKitCall(id: UUID())- var start = clock.now- let ready = Task { await call.audioReady() }- try await Task.sleep(for: .milliseconds(50))- call.audioActivated()- await ready.value- #expect(clock.now - start < .seconds(2))- // Active already: no wait.- start = clock.now- await call.audioReady()- #expect(clock.now - start < .seconds(1))- // It never comes: the call goes on after the timeout.- CallKitCall.audioTimeout = .milliseconds(50)- start = clock.now- await CallKitCall(id: UUID()).audioReady()- #expect(clock.now - start < .seconds(2))-}--@MainActor @Test func callKitsHoldPausesTheCallAndItResumesOnceTheAudioIsBack() async {- var heard: [String] = []- let events = AudioSessionEvents(engine: nil, interrupted: { change in- switch change {- case .began: heard.append("paused")- case .ended(let shouldResume): heard.append(shouldResume ? "resumed" : "ended")- }- })- defer { events.stop() }- func settle() async { try? await Task.sleep(for: .milliseconds(20)) }-- let call = CallKitCall(id: UUID())- call.audioActivated()- call.held(true)- call.audioDeactivated()- // Off hold before the system gave the audio back: the engine waits for it.- call.held(false)- await settle()- #expect(heard == ["paused"])- call.audioActivated()- await settle()- #expect(heard == ["paused", "resumed"])- // Held without losing the audio: off hold resumes at once.- call.held(true)- call.held(false)- await settle()- #expect(heard == ["paused", "resumed", "paused", "resumed"])-}diff --git a/apps/ios/Resources/Info.plist b/apps/ios/Resources/Info.plistindex 98e9974c..f80677a8 100644--- a/apps/ios/Resources/Info.plist+++ b/apps/ios/Resources/Info.plist@@ -33,7 +33,6 @@<key>UIBackgroundModes</key><array><string>audio</string>- <string>voip</string></array><key>NSAppTransportSecurity</key><dict>diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex 2cfc83f2..3f4fdb45 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -12,14 +12,14 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- Bot 工作時,Gemini 與 OpenAI 的語音會主動告訴你它在做什麼、有沒有等你核准或遇到問題,做完就念出結果。- 通話中短暫斷線再連上時,錯過的回覆會補念給你聽。- Gemini 或 OpenAI 通話斷線時會自動重新連上並接著聊,不必重打;來電、Siri 或其他 App 佔用聲音時通話會暫停,結束後自動繼續,也可以點一下通話列下方繼續。-- 語音通話像一般電話一樣出現在鎖定畫面和動態島,可以從那裡或 AirPods 靜音、掛斷;來電時通話先保留,掛斷後接著聊。Bot 的即時動態也會顯示通話狀態和它正在做的事。+- 通話中,Bot 的即時動態會在鎖定畫面和動態島顯示通話狀態和它正在做的事。- Gemini 與 OpenAI 的語音用你正在說的語言回答,你換語言它就跟著換。### en-US- While the bot works, the Gemini and OpenAI voice keeps you posted on what it's doing, tells you when an approval waits or something fails, and reads the result when it's done.- A reply that arrives while a call briefly loses its connection is read once it's back.- A Gemini or OpenAI call that loses its connection reconnects and carries on without hanging up; a phone call, Siri or another app's audio pauses the call, which picks up again when it ends, or with a tap under the call bar.-- Calls show like phone calls on the Lock Screen and in the Dynamic Island: mute or end them there or with AirPods, and a phone call holds them until you're back. The bot's Live Activity shows the call and what the bot is doing.+- During a call, the bot's Live Activity on the Lock Screen and in the Dynamic Island shows the call and what the bot is doing.- The Gemini and OpenAI voice answers in the language you speak and follows when you switch.## 2.25.0diff --git a/docs/architecture/file-structure.md b/docs/architecture/file-structure.mdindex 4cc988a2..f76befea 100644--- a/docs/architecture/file-structure.md+++ b/docs/architecture/file-structure.md@@ -91,7 +91,7 @@ Codync/| Agent process, ACP, queue and session lifecycle | `host/src/agent/bot/` (`launch.rs`, `queue.rs`, `session.rs`, `turn.rs`, `updates.rs`), `acp.rs` || Compaction timing and rollover | `host/src/agent/bot/compaction.rs`, the handoff card in `host/src/chat/handoff.rs`; the rules in `codync-mem`'s `compaction.rs` || Group room turns / bot-to-bot requests | `host/src/chat/group.rs` / `team.rs` |-| Voice calls (the call, the voice's instructions and tools, transcripts, call lines) | `host/src/chat/calls/` (`mod.rs`, `context.rs`, `project.rs` the git state, `tools.rs`, `announce.rs` what the voice hears while the call lasts, `speech.rs` text as a voice says it); the user's messages it relays go through `host/src/chat/messages.rs` like typed ones; clients' `CallLink` (iPhone `CodyncUI/Call/CallLink.swift`, desktop `views/call/call-link.ts`, Android `core/Calls.kt` + `HostCallLink.kt`) and call rows (`CallRows`); the system's call on the iPhone (`CodyncUI/Call/SystemCall.swift` CallKit, `CallActivity.swift` the Live Activity) and Android's call notification (`VoiceService.kt`) |+| Voice calls (the call, the voice's instructions and tools, transcripts, call lines) | `host/src/chat/calls/` (`mod.rs`, `context.rs`, `project.rs` the git state, `tools.rs`, `announce.rs` what the voice hears while the call lasts, `speech.rs` text as a voice says it); the user's messages it relays go through `host/src/chat/messages.rs` like typed ones; clients' `CallLink` (iPhone `CodyncUI/Call/CallLink.swift`, desktop `views/call/call-link.ts`, Android `core/Calls.kt` + `HostCallLink.kt`) and call rows (`CallRows`); the call on the iPhone's Lock Screen (`CodyncUI/Call/CallActivity.swift`, the Live Activity) and Android's call notification (`VoiceService.kt`) || Team management (bots creating and changing bots) | `host/src/chat/manage.rs`, its approval card (`Cmd::Approve`) in `agent/bot/updates.rs` || Prompt snapshots and memory | `host/src/chat/context.rs`, `memory/` (`api.rs` the apps' read-only view, `tools.rs` and `file_tools.rs` the MCP tools, `files.rs` the folders and scan, `turns.rs` which bot's turn a found change is credited to, `file_api.rs`, `dream.rs`, `import.rs`); the rules in `host/crates/memory` (`codync-mem`: files and facts in `files/`, dreaming in `dream/`, tombstones in `store.rs`, the old entries in `legacy.rs`); harnesses' own memory turned off in `host/src/agent/own_memory.rs` || Identity, encryption and direct channel | `host/src/remote/identity.rs`, `crypto.rs`, `channel.rs` |diff --git a/docs/design/push-and-live-activity.md b/docs/design/push-and-live-activity.mdindex 717ad81e..714a5aa6 100644--- a/docs/design/push-and-live-activity.md+++ b/docs/design/push-and-live-activity.md@@ -40,7 +40,7 @@ flowchart LR- The extension then turns the alert into a communication notification (`INSendMessageIntent`) so the banner shows the bot's avatar instead of the app icon. A group alert carries the speaking member (`from`, sealed with the text) and shows as a group conversation: the group's avatar and name, with the member as sender. The sealed alert carries `faces` (name, shape and color of the chat, its first two members and the speaker), so a bot created while the app was closed still gets its avatar; alerts from an older host fall back to the widget snapshot in the App Group, and a bot in neither keeps the plain banner. Needs the app's Communication Notifications entitlement and `NSUserActivityTypes: INSendMessageIntent`. [Apple communication notifications](https://developer.apple.com/documentation/usernotifications/implementing-communication-notifications)- ActivityKit renders both Lock Screen and Dynamic Island. A separate Dynamic Island Worker or event API is unnecessary. APNs updates use a dedicated activity token, not the normal notification token. [Apple ActivityKit push updates](https://developer.apple.com/documentation/ActivityKit/starting-and-updating-live-activities-with-activitykit-push-notifications)-Remote activity content contains only `status`, empty `activity`, and `startedAt`. During a voice call the app also sets `call` and `callStartedAt` locally ([the call on the system](../features/voice-call.md#the-call-on-the-system)); the computer never sends them, so a remote update drops them and the app puts them back, and the app doesn't end the activity while the call lasts. Foreground app updates may show the current step from the encrypted connection; a remote update clears that free text. The notification service extension is not an ActivityKit decryption stage. The UI therefore does not promise private task summaries in background Live Activities. Bot identity and its deep link are set locally when starting the activity.+Remote activity content contains only `status`, empty `activity`, and `startedAt`. During a voice call the app also sets `call` and `callStartedAt` locally ([the call outside the app](../features/voice-call.md#the-call-outside-the-app)); the computer never sends them, so a remote update drops them and the app puts them back, and the app doesn't end the activity while the call lasts. Foreground app updates may show the current step from the encrypted connection; a remote update clears that free text. The notification service extension is not an ActivityKit decryption stage. The UI therefore does not promise private task summaries in background Live Activities. Bot identity and its deep link are set locally when starting the activity.## Registration and lifecyclediff --git a/docs/features/voice-call.md b/docs/features/voice-call.mdindex 6c0fe479..ad1bb134 100644--- a/docs/features/voice-call.md+++ b/docs/features/voice-call.md@@ -368,19 +368,12 @@ carries audio and talks to these methods:`CallRecoveryTests`, desktop `call-recovery.test.ts`, Android `VoiceEnginesTest` (Gemini over MockWebServer, OpenAIover a fake peer).-### The call on the system--- iPhone: a call is a CallKit outgoing call to the bot (`SystemCall.swift`, one `CXProvider`, audio only, not in- Recents): it shows on the Lock Screen and in the Dynamic Island, ends or mutes from there and from AirPods, and a- phone call holds it (`CXSetHeldCallAction` pauses the engine the way an interruption does; off hold, it resumes once- CallKit has activated the audio session again). CallKit activates and deactivates the audio session- (`CallAudioSession`): the engine starts once it has (at most 1.5 s later where it never does, as on the Simulator),- the engines set the session up but neither activate nor deactivate it, and OpenAI's WebRTC audio runs only while- CallKit has it active (`useManualAudio`, `audioSessionDidActivate`/`DidDeactivate`), so a reconnect or an engine- switch doesn't cut the call's audio. The call reports connected once the engine reaches ready. CallKit ending the- call before that (the Simulator does at once), refusing it or resetting leaves the call going on without it.-- CallKit isn't allowed in apps offered in mainland China's App Store: with the storefront `CHN` (or, without a- storefront, the region `CN`) the call keeps the app's own audio session, as before (`SystemCallPolicy`).+### The call outside the app++- iPhone: the app owns the call's audio session (`CallAudioSession`): each engine activates it as its audio starts+ and releases it as it stops (OpenAI's WebRTC manages its own with the same options); interruptions and route+ changes come from `AVAudioSession` notifications (above). CallKit carried the call in a build that never shipped and+ was taken out: [CallKit (archived)](../plans/callkit.md).- iPhone Live Activity: while a call is on, the bot's activity shows it (`ContentState.call`: connecting, listening,speaking, paused; `callStartedAt` for its length) and the bot's latest progress line from the computer until itsreply (`CallActivity`). It uses the bot's activity if one is up and starts one for the call otherwise; a task sent@@ -391,7 +384,7 @@ carries audio and talks to these methods:minute later) and one with a task under way stays without the call.- Android: the call's foreground notification shows its state and the bot's latest progress line (cleared by itsreply), updated in place, with Mute and End call.-- The desktop and the terminal have no system call UI to join.+- The desktop and the terminal have no Live Activity or call notification.### Failure and costdiff --git a/docs/plans/callkit.md b/docs/plans/callkit.mdnew file mode 100644index 00000000..f055c084--- /dev/null+++ b/docs/plans/callkit.md@@ -0,0 +1,55 @@+# CallKit for voice calls (archived)++Status: built for 2.26.0 as part of stage 4 of [voice calls owned by the host](voice-architecture.md), then taken out+before release by the owner's decision (2026-10-25). The iPhone app keeps its own audio session, as before; the+Live Activity call state and Android's call notification from the same stage stayed. Current behavior:+[the call outside the app](../features/voice-call.md#the-call-outside-the-app).++## What it did++- **The call as a phone call**: one `CXProvider` (audio only, one call group, `includesCallsInRecents = false`,+ generic handle) reported each Codync voice call as an outgoing call to the bot (the handle was the bot's name),+ connecting at once and connected when the engine reached ready (`reportOutgoingCall(connectedAt:)`). It showed on the+ Lock Screen and in the Dynamic Island.+- **System actions**: ending it from the Lock Screen, the Dynamic Island, AirPods or by answering another call+ (`CXEndCallAction`) hung up the Codync call; `CXSetMutedCallAction` synced both ways with the call bar's mute; a phone+ call holding it (`CXSetHeldCallAction`) paused the engine the way an audio interruption does (a `callHeld`+ notification into `AudioSessionEvents`), and off hold it resumed once CallKit had activated the audio session again.+- **CallKit owned the audio session**: the call view waited for `provider(_:didActivate:)` before starting the engine,+ at most 1.5 s (`CallKitCall.audioTimeout`; the activation never comes on the Simulator). The engines set the+ category but neither activated nor deactivated the session while CallKit ran the call (`CallAudioSession.systemRuns`).+- **OpenAI's WebRTC audio** followed CallKit's activation: `RTCAudioSession.useManualAudio = true` while CallKit ran the+ call, `audioSessionDidActivate`/`DidDeactivate` and `isAudioEnabled` from the provider's activate/deactivate, so a+ reconnect or an engine switch didn't deactivate the session under the call.+- **Fallback**: CallKit refusing the call, resetting, or ending it before it got audio or connected (the Simulator does+ this to every call) left the call going on without it, on the app's own audio session.+- **Mainland China**: CallKit isn't allowed in apps offered on mainland China's App Store, so it stayed off when the+ storefront was `CHN` (`Storefront.current`; without one, the region `CN`): `SystemCallPolicy`.+- **Background mode**: `voip` in `UIBackgroundModes` (`apps/ios/Resources/Info.plist`); without it CallKit refused+ calls as unentitled. App Review may ask about it.++Code: `apps/ios/Kit/Sources/CodyncUI/Call/SystemCall.swift` (`SystemCallPolicy`, `CallKitCalls`, `CallKitCall`), the+CallKit wiring in `CallView.swift` (start, `audioReady`, `connected`, `setMuted`, `end`), `CallAudioSession`'s+CallKit half in `CallAudio.swift`, tests in `CodyncUITests/SystemCallTests.swift`.++## What review found and fixed in it++- OpenAI's WebRTC activated and deactivated the session CallKit owned, so a reconnect could leave the call's audio+ dead after a hold: fixed with WebRTC's manual audio (above).+- Taken off hold before CallKit gave the audio back, the engine resumed on an inactive session: it waited for the+ activation.+- The first build closed the whole call when the Simulator's CallKit ended it at once (a `00:00` line): CallKit ending+ a call that never connected became "go on without it".++## Not verified++On a physical iPhone: the system call UI, ending and muting from it and from AirPods, holds from a real phone call,+and OpenAI under CallKit. The Simulator ends every CallKit call right after it starts.++## Bringing it back++- Added in `9b6b9ede` (feat(apps): calls show on the Lock Screen, in the Dynamic Island and in the notification) and+ `1ecd8353` (fix(apps): calls keep their audio and Live Activity under CallKit).+- Taken out in "fix(ios): take CallKit out of voice calls, keep the Live Activity" (the commit that added this page).+ Reverting it restores the code, the `voip` background mode, the tests and the docs.+- Before shipping it: walk the list under "Not verified" on a phone, and expect App Review to ask about `voip`.diff --git a/docs/plans/voice-architecture.md b/docs/plans/voice-architecture.mdindex c5ca3f71..25e8fa8b 100644--- a/docs/plans/voice-architecture.md+++ b/docs/plans/voice-architecture.md@@ -1,6 +1,6 @@# Voice calls owned by the host-Status: all four stages shipped (stage 1 in 2.25.0, stages 2–4 in 2.26.0). Supersedes [voice call transcripts](voice-call-transcripts.md),+Status: all four stages shipped (stage 1 in 2.25.0, stages 2–4 in 2.26.0; stage 4 without CallKit). Supersedes [voice call transcripts](voice-call-transcripts.md),which became stage 1 of this plan. Current behavior: [voice call](../features/voice-call.md#the-call-on-the-host).A realtime voice model (Gemini Live, OpenAI Realtime) stays in front of the bot: coding agents are text-only and@@ -78,11 +78,11 @@ replayed end to end in the iPhone and desktop tests (its events are).### 4. Platform-Shipped in 2.26.0 ([the call on the system](../features/voice-call.md#the-call-on-the-system)). CallKit stays off where-the App Store storefront is mainland China's.+Shipped in 2.26.0 ([the call outside the app](../features/voice-call.md#the-call-outside-the-app)), without CallKit:+it was built, then taken out before release by the owner's decision (2026-10-25); the design and how to bring it back+are in [CallKit (archived)](callkit.md).-- iPhone: CallKit for the call (lock screen, Dynamic Island, AirPods controls, interruptions handled by the system),- and the bot's progress in the call's Live Activity.+- iPhone: the bot's progress and the call's state in the bot's Live Activity; the app keeps its own audio session.- Android: the call's foreground notification shows the same progress.## Compatibilitydiff --git a/web/content/docs/voice.mdx b/web/content/docs/voice.mdxindex 1e50b6ed..153d4e1e 100644--- a/web/content/docs/voice.mdx+++ b/web/content/docs/voice.mdx@@ -24,7 +24,7 @@ What you say on a call, and the bot's replies during it, don't fill up the chat.The bot remembers what matters from the call like from any conversation: its memory picks up what you said, not the voice's wording.-On the iPhone, the first call asks for Microphone and Speech Recognition access. The call keeps going if you leave Codync for the Home Screen. It shows like a phone call: on the Lock Screen and in the Dynamic Island, where you can mute or end it (AirPods controls work too), and a real phone call puts it on hold until you're back. Calls with bots don't appear in the Phone app's Recents. Where the App Store is mainland China's, calls stay inside Codync (Apple doesn't allow this there). The bot's Live Activity shows the call and what the bot is doing while you talk.+On the iPhone, the first call asks for Microphone and Speech Recognition access. The call keeps going if you leave Codync for the Home Screen, and the bot's Live Activity on the Lock Screen and in the Dynamic Island shows the call and what the bot is doing while you talk.On Android, the call's notification shows the same: the call's state and what the bot is working on, with Mute and End call.