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(apps): switch the call's voice mid-call and show a connecting line
leepokaic88db4f07938
diff --git a/apps/android/WhatsNew.md b/apps/android/WhatsNew.mdindex 63e86194..40d0ac5f 100644--- a/apps/android/WhatsNew.md+++ b/apps/android/WhatsNew.md@@ -18,13 +18,15 @@ else a generic "Bug fixes and improvements" line. Delete old sections.- 新增聯結器失敗後再試一次,會使用你改好的金鑰。- 在設定開啟「顯示思考細節」後,點一下工作中 Bot 的狀態膠囊,就能展開這一輪的思考與步驟。- 點對話上方的 Bot 會打開它的詳情、資料庫與設定;「新會話」改到 Bot 列表的長按選單。+- 通話中在設定換了語音,關掉設定後通話就改用新的語音繼續。+- 語音通話連線中,通話列會顯示一條跑動的進度線。### en-US-- Bots make artifacts, shown as cards in the chat; message the bot below one to edit it.-- Each bot's Library holds its artifacts and the chat's files.+- Bots make artifacts, shown as chat cards; message the bot below one to edit it.+- Each bot's Library holds its artifacts and chat files.- Create bots that run Hermes Agent.- Bots hand work to each other without waiting.-- Computers & settings now matches the page it opens.- Retrying a failed connector uses the corrected key.- Settings › Show thinking details unfolds a bot's steps.- Tap a chat's title for the bot's details; New session moved to the list's touch & hold menu.+- Change the voice mid-call; it takes over when settings close.diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreVoice.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreVoice.ktindex 0c225336..f74e8d39 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreVoice.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreVoice.kt@@ -18,6 +18,8 @@ internal class VoiceBinding(val id: String, val botId: String, val generation: Ivar engine: VoiceEngine? = null/** When the current cloud engine started, for this month's minutes. */var cloudSince: Long? = null+ /** The call settings the current engine was built from. */+ var choice = ""/** The microphone's audio session, so Android silencing it pauses the call. */var recording: () -> Int? = { null }/** What the voice service sees: the current engine, never the failure it fell back from. */@@ -62,6 +64,9 @@ private fun AppStore.begin(call: VoiceBinding, provider: VoiceProvider?) {// Picks up the computer's newest models for the next call; this one starts right away.if (provider != null) contextScope.launch { try { choices.remember(voiceStatus()) } catch (_: Exception) { } }val settings = VoicePreferences.load(getApplication())+ call.choice = choices.engineChoice(provider, callLanguage())+ // A muted call stays muted on the engine that takes over (what the call last showed).+ val muted = call.state.value.mutedval operator = CallOperator(call.botId, object : CallTarget {override val bots get() = state.value.botsoverride val entries get() = state.value.entries@@ -101,6 +106,7 @@ private fun AppStore.begin(call: VoiceBinding, provider: VoiceProvider?) {}}call.engine = engine+ if (muted) engine.mute(true)call.cloudSince = if (provider != null) SystemClock.elapsedRealtime() else nullcontextScope.launch {val last = engine.state.first { status ->@@ -116,12 +122,33 @@ private fun AppStore.begin(call: VoiceBinding, provider: VoiceProvider?) {}!current || fallingBack || status.phase == VoicePhase.Ended}- if (provider == null || last.phase != VoicePhase.Failed || voiceBinding !== call) return@launch- countCloudMinutes(call)- val notice = "${provider.title} isn't available (${last.error ?: "no answer"}). Using on-device voice."- mutableState.update { it.copy(voice = it.voice?.takeIf { voice -> voice.id == call.id }?.copy(notice = notice) ?: it.voice) }- engine.end(); engine.awaitEnd()- if (voiceBinding === call) begin(call, null)+ if (provider == null || last.phase != VoicePhase.Failed || voiceBinding !== call || call.engine !== engine) return@launch+ handOver(call, "${provider.title} isn't available (${last.error ?: "no answer"}). Using on-device voice.") { null }+ }+}++/** After the call settings close: a different engine picked there takes over the call, which goes on. */+fun AppStore.switchVoiceEngine() {+ val call = voiceBinding ?: return+ val choices = voiceChoices()+ // No engine: a hand-over is under way; a switch begins what is picked by the time it's done.+ if (call.engine == null || choices.engineChoice(choices.provider, callLanguage()) == call.choice) return+ handOver(call, null) { voiceChoices().provider }+}++/**+ * Ends the call's engine and, once it has closed, begins `next()` in the same call, unless the call+ * ended or got an engine meanwhile. The old engine is detached first: its end mustn't reach the+ * call's state, which would end the call.+ */+private fun AppStore.handOver(call: VoiceBinding, notice: String?, next: () -> VoiceProvider?) {+ val old = call.engine+ countCloudMinutes(call)+ call.engine = null+ mutableState.update { it.copy(voice = it.voice?.takeIf { voice -> voice.id == call.id }?.copy(notice = notice) ?: it.voice) }+ contextScope.launch {+ old?.end(); old?.awaitEnd()+ if (voiceBinding === call && call.engine == null) begin(call, next())}}diff --git a/apps/android/app/src/main/kotlin/com/codync/android/VoiceChatSettings.kt b/apps/android/app/src/main/kotlin/com/codync/android/VoiceChatSettings.ktindex f5eb888c..33508e39 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/VoiceChatSettings.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/VoiceChatSettings.kt@@ -28,6 +28,8 @@ import kotlinx.coroutines.launchvar engine by remember { mutableStateOf(choices.provider) }var settings by remember { mutableStateOf(VoicePreferences.load(context)) }fun change(next: VoiceSettings) { settings = next; store.voiceSettings(next) }+ // Closing hands a running call to a different engine picked here.+ DisposableEffect(Unit) { onDispose { store.switchVoiceEngine() } }Column(Modifier.fillMaxSize().background(Palette.background)) {ModalHeader({Symbol("waveform", size = 24.dp, tint = Palette.text)@@ -37,8 +39,8 @@ import kotlinx.coroutines.launchCardForm {val provider = enginevar speech by remember(provider) { mutableStateOf(provider?.let(choices::speechMode) == true) }- CardSection("Voice", footer = provider?.let { "Your own ${it.title} key, billed by ${it.title}. Applies from the next call." }- ?: "Android speech, on this device. Applies from the next call.", Modifier.animateContentSize(Motion.layoutSize)) {+ CardSection("Voice", footer = provider?.let { "Your own ${it.title} key, billed by ${it.title}. During a call, applies when you close settings." }+ ?: "Android speech, on this device. During a call, applies when you close settings.", Modifier.animateContentSize(Motion.layoutSize)) {row {ValueRow("Engine") {ChoicePicker(provider, listOf<Pair<VoiceProvider?, String>>(null to "On device") + VoiceProvider.entries.map { it to it.title },diff --git a/apps/android/app/src/main/kotlin/com/codync/android/VoiceControls.kt b/apps/android/app/src/main/kotlin/com/codync/android/VoiceControls.ktindex 48997d87..21a02938 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/VoiceControls.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/VoiceControls.kt@@ -9,8 +9,10 @@ import androidx.activity.compose.rememberLauncherForActivityResultimport androidx.activity.result.contract.ActivityResultContractsimport androidx.compose.animation.core.RepeatModeimport androidx.compose.animation.core.animateFloat+import androidx.compose.animation.core.animateFloatAsStateimport androidx.compose.animation.core.infiniteRepeatableimport androidx.compose.animation.core.rememberInfiniteTransition+import androidx.compose.animation.core.snapimport androidx.compose.animation.core.tweenimport androidx.compose.foundation.Canvasimport androidx.compose.foundation.background@@ -24,6 +26,8 @@ import androidx.compose.ui.geometry.CornerRadiusimport androidx.compose.ui.geometry.Offsetimport androidx.compose.ui.geometry.Sizeimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.drawscope.clipRectimport androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.semantics.contentDescription@@ -78,7 +82,7 @@ internal fun openAppSettings(context: android.content.Context) =.semantics { contentDescription = if (speaking) "Interrupt" else bot?.name.orEmpty() }) {if (bot != null) BotAvatar(bot, state.bots, 34.dp)}- CallLevelDots(voice.level, speaking, bot?.status == "working", color,+ CallLevelDots(voice.level, speaking, bot?.status == "working", voice.phase == VoicePhase.Starting, color,Modifier.weight(1f).height(20.dp).semantics { contentDescription = statusText(voice, bot?.status == "working") })// Audio leaves the phone: say where.voice.provider?.let { provider ->@@ -123,19 +127,26 @@ private fun statusText(voice: VoiceState, working: Boolean) = when (voice.phase)VoicePhase.Listening -> if (voice.muted) "Muted" else if (working) "Working, listening" else "Listening"}+/** Seconds for the connecting segment to cross the track. */+private const val CONNECTING_PERIOD = 1.4f+/*** The dotted line in the call bar: it follows your voice while listening, ripples while the bot- * talks, breathes while it works, and rests as faint dots otherwise.+ * talks, breathes while it works, and rests as faint dots otherwise. While the call connects it shows+ * an indeterminate progress line instead (a short segment sliding along a faint track, resting at the+ * left with reduced motion), and fades back to the dots.*/-@Composable private fun CallLevelDots(level: Float, speaking: Boolean, working: Boolean, color: Color, modifier: Modifier) {+@Composable private fun CallLevelDots(level: Float, speaking: Boolean, working: Boolean, connecting: Boolean, color: Color, modifier: Modifier) {val still = reduceMotion()var time by remember { mutableFloatStateOf(0f) }if (!still) LaunchedEffect(Unit) { while (true) withFrameNanos { time = it / 1e9f } }val accent = Palette.accent+ val mix by animateFloatAsState(if (connecting) 1f else 0f, if (still) snap() else Motion.fade(), label = "Connecting")Canvas(modifier) {+ if (mix > 0.01f) connectingLine(accent, mix, time, still)val spacing = 8.dp.toPx()val width = 2.5.dp.toPx()- val count = maxOf(1, (size.width / spacing).toInt())+ val count = if (mix < 0.99f) maxOf(1, (size.width / spacing).toInt()) else 0for (i in 0 until count) {val wave = (sin(i * 0.55f - time * 6f) + 1) / 2val amount = when {@@ -145,8 +156,21 @@ private fun statusText(voice: VoiceState, working: Boolean) = when (voice.phase)else -> 0.08f}val height = 4.dp.toPx() + amount * (size.height - 4.dp.toPx())- drawRoundRect((if (speaking) accent else color).copy(alpha = 0.5f + 0.5f * amount),+ drawRoundRect((if (speaking) accent else color).copy(alpha = (0.5f + 0.5f * amount) * (1 - mix)),Offset(i * spacing + spacing / 2 - width / 2, (size.height - height) / 2), Size(width, height), CornerRadius(width / 2))}}}++/** The connecting line at `alpha`: a faint track and a segment a third its length sliding across it, at the left when `still`. */+private fun DrawScope.connectingLine(accent: Color, alpha: Float, time: Float, still: Boolean) {+ val mid = size.height / 2+ drawRoundRect(accent.copy(alpha = 0.15f * alpha), Offset(0f, mid - 0.75.dp.toPx()), Size(size.width, 1.5.dp.toPx()),+ CornerRadius(0.75.dp.toPx()))+ val segment = size.width / 3+ val x = if (still) 0f else -segment + (time % CONNECTING_PERIOD) / CONNECTING_PERIOD * (size.width + segment)+ clipRect {+ drawRoundRect(accent.copy(alpha = alpha), Offset(x, mid - 1.75.dp.toPx()), Size(segment, 3.5.dp.toPx()),+ CornerRadius(1.75.dp.toPx()))+ }+}diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/VoiceProvider.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/VoiceProvider.ktindex b94f91e0..1e2916d6 100644--- a/apps/android/core/src/main/kotlin/com/codync/android/core/VoiceProvider.kt+++ b/apps/android/core/src/main/kotlin/com/codync/android/core/VoiceProvider.kt@@ -70,6 +70,13 @@ class VoiceChoices(private val read: (String) -> String?, private val write: (Stfun voice(provider: VoiceProvider): String = read("callVoice.${provider.id}")?.takeIf { it in provider.voices } ?: provider.voices[0]fun voice(provider: VoiceProvider, voice: String) = write("callVoice.${provider.id}", voice)+ /** What a call's engine is built from (`language`: on device): a different one picked mid-call takes over the call. */+ fun engineChoice(provider: VoiceProvider?, language: String): String = when {+ provider == null -> "device $language"+ speechMode(provider) -> "${provider.id} speech ${model(provider, Model.Transcribe)} ${model(provider, Model.Speech)} ${voice(provider)}"+ else -> "${provider.id} ${model(provider, Model.Realtime)} ${voice(provider)}"+ }+/** The provider's model list as last fetched with the user's key. */fun cachedModels(provider: VoiceProvider): VoiceModels? = read("callModels.${provider.id}")?.let { runCatching { WireJson.decodeFromString(VoiceModels.serializer(), it) }.getOrNull() }diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/VoiceEnginesTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/VoiceEnginesTest.ktindex eb6ef7cc..fcb05f93 100644--- a/apps/android/core/src/test/kotlin/com/codync/android/core/VoiceEnginesTest.kt+++ b/apps/android/core/src/test/kotlin/com/codync/android/core/VoiceEnginesTest.kt@@ -44,6 +44,26 @@ class VoiceEnginesTest {assertEquals("61", prefs.values["callUsage.openai.2026-10"])}+ @Test fun aCallTakesAnotherEngineOnlyWhenWhatItsEngineIsBuiltFromChanges() {+ val choices = Prefs().choices; val gemini = VoiceProvider.Gemini+ assertEquals(choices.engineChoice(null, ""), choices.engineChoice(null, ""))+ assertNotEquals(choices.engineChoice(null, ""), choices.engineChoice(null, "ja-JP"))+ assertNotEquals(choices.engineChoice(gemini, ""), choices.engineChoice(VoiceProvider.OpenAI, ""))+ val seen = mutableListOf(choices.engineChoice(gemini, ""))+ for (change in listOf<() -> Unit>(+ { choices.choose(gemini, VoiceChoices.Model.Realtime, "live-9") },+ { choices.voice(gemini, "Puck") },+ { choices.speechMode(gemini, true) },+ { choices.choose(gemini, VoiceChoices.Model.Transcribe, "flash-9") },+ { choices.choose(gemini, VoiceChoices.Model.Speech, "tts-9") })) {+ change()+ val choice = choices.engineChoice(gemini, "")+ assertEquals(choice, choices.engineChoice(gemini, ""))+ assertFalse(choice, choice in seen)+ seen += choice+ }+ }+@Test fun utterancesStartAtSpeechEndAtThePauseAndDropCoughs() {val detector = UtteranceDetector(); val frame = ByteArray(3_200)assertNull(detector.feed(frame, 0f, 0, 1_000))diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex fcb1bedd..953fc021 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -16,7 +16,7 @@"build": "electron-vite build","build:demo": "vite build --config vite.demo.config.ts && mv ../../web/public/demo/desktop/index.html ../../web/public/demo/desktop.html","typecheck": "tsc --noEmit -p tsconfig.json",- "test": "node --test --experimental-strip-types src/shared/*.test.ts src/renderer/lib/*.test.ts src/renderer/views/thread/*.test.ts src/renderer/views/routines/*.test.ts",+ "test": "node --test --experimental-strip-types src/shared/*.test.ts src/renderer/lib/*.test.ts src/renderer/views/thread/*.test.ts src/renderer/views/routines/*.test.ts src/renderer/views/call/*.test.ts","icons": "swift tools/export-symbols.swift","dist:mac:dev": "node tools/account-config.mjs dev && node tools/native-host.mjs dev && node tools/native-screen.mjs dev && electron-vite build && CSC_NAME=\"Pokai Lee (6KFK5J2LB4)\" electron-builder --mac --config tools/dev-builder.cjs","dist:mac:main": "node tools/account-config.mjs main && node tools/native-host.mjs main && node tools/native-screen.mjs main && electron-vite build && electron-builder --mac",diff --git a/apps/desktop/src/renderer/components/LevelDots.tsx b/apps/desktop/src/renderer/components/LevelDots.tsxindex 0f69f410..c94b52b7 100644--- a/apps/desktop/src/renderer/components/LevelDots.tsx+++ b/apps/desktop/src/renderer/components/LevelDots.tsx@@ -1,19 +1,24 @@import { useEffect, useRef } from 'react'import { useDark, usePixelRatio, useReduceMotion, withAlpha } from '../lib/theme'-/** What the dots show this frame: your voice's level (0…1), the other side talking, or work going on. */+/** What the dots show this frame: your voice's level (0…1), the other side talking, work going on, or a call connecting. */export interface LevelSample {level: numberspeaking?: booleanworking?: boolean+ connecting?: boolean}/** The gap between dots, in points. */const SPACING = 8+/** Seconds for the connecting segment to cross the track. */+const PERIOD = 1.4/*** A dotted line that follows your voice while listening, ripples while the other side talks,- * breathes while work goes on, and rests as faint dots otherwise. `sample` is read every frame.+ * breathes while work goes on, and rests as faint dots otherwise. While a call connects it shows an+ * indeterminate progress line instead (a short segment sliding along a faint track, resting at the left+ * with reduced motion), and fades back to the dots. `sample` is read every frame.* `color` null is the text color.*/export function LevelDots({ sample, color, width, height = 16, label, className }: {@@ -38,15 +43,24 @@ export function LevelDots({ sample, color, width, height = 16, label, classNameel.width = width * scaleel.height = height * scalelet frame = 0+ /** 1 while connecting, 0 for the dots; eased between them for the fade. */+ let mix = 0+ let last = 0const draw = (now: number) => {const { sample, color, dark, reduceMotion } = live.current- const { level, speaking = false, working = false } = sample()+ const { level, speaking = false, working = false, connecting = false } = sample()const t = reduceMotion ? 0 : now / 1000const accent = dark ? '#ffffff' : '#000000'const tint = speaking ? accent : (color ?? accent)+ const target = connecting ? 1 : 0+ mix = reduceMotion || !last ? target : mix + (target - mix) * Math.min(1, ((now - last) / 1000) * 8)+ last = nowctx.setTransform(scale, 0, 0, scale, 0, 0)ctx.clearRect(0, 0, width, height)- const count = Math.max(1, Math.floor(width / SPACING))+ ctx.globalAlpha = mix+ if (mix > 0.01) drawConnecting(ctx, width, height, t, accent, reduceMotion)+ ctx.globalAlpha = 1 - mix+ const count = mix < 0.99 ? Math.max(1, Math.floor(width / SPACING)) : 0for (let i = 0; i < count; i++) {const x = i * SPACING + SPACING / 2const wave = (Math.sin(i * 0.55 - t * 6) + 1) / 2@@ -57,6 +71,7 @@ export function LevelDots({ sample, color, width, height = 16, label, classNamectx.roundRect(x - 1.25, (height - bar) / 2, 2.5, bar, 1.25)ctx.fill()}+ ctx.globalAlpha = 1frame = requestAnimationFrame(draw)}frame = requestAnimationFrame(draw)@@ -65,3 +80,22 @@ export function LevelDots({ sample, color, width, height = 16, label, classNamereturn <canvas ref={canvas} role="img" aria-label={label} className={className} style={{ width, height }} />}++/** The connecting line: a faint track and a segment a third its length sliding across it (`t` in seconds), resting at the left with reduced motion. */+function drawConnecting(ctx: CanvasRenderingContext2D, width: number, height: number, t: number, accent: string, reduceMotion: boolean) {+ ctx.fillStyle = withAlpha(accent, 0.15)+ ctx.beginPath()+ ctx.roundRect(0, height / 2 - 0.75, width, 1.5, 0.75)+ ctx.fill()+ const segment = width / 3+ const x = reduceMotion ? 0 : -segment + ((t % PERIOD) / PERIOD) * (width + segment)+ ctx.save()+ ctx.beginPath()+ ctx.rect(0, 0, width, height)+ ctx.clip()+ ctx.fillStyle = accent+ ctx.beginPath()+ ctx.roundRect(x, height / 2 - 1.75, segment, 3.5, 1.75)+ ctx.fill()+ ctx.restore()+}diff --git a/apps/desktop/src/renderer/views/call/CallView.tsx b/apps/desktop/src/renderer/views/call/CallView.tsxindex 2106bb23..911484b3 100644--- a/apps/desktop/src/renderer/views/call/CallView.tsx+++ b/apps/desktop/src/renderer/views/call/CallView.tsx@@ -14,20 +14,20 @@ import { VoiceChatSettingsView } from '../settings/VoiceChatSettingsView'import { voiceStatus } from '../settings/voice-settings'import { stopDictation } from '../thread/dictation'import { CallOperator } from './call-operator'--/**- * Opens the window's own Settings at Voice chat; without it (no Settings screen around) the- * call bar shows the voice settings in their own sheet.- */-export const OpenVoiceSettings = createContext<(() => void) | null>(null)import { CloudSpeechEngine } from './CloudSpeechEngine'import { GeminiLiveEngine } from './GeminiLiveEngine'import { OnDeviceEngine } from './OnDeviceEngine'import { OpenAIRealtimeEngine } from './OpenAIRealtimeEngine'-import { countVoiceUsage, fromBase64, onDeviceAvailable, onDeviceUnavailableReason, providerName, transcribeOnHost, VoiceEngine, VoiceSettings, type VoiceProvider } from './voice'+import { countVoiceUsage, fromBase64, onDeviceAvailable, onDeviceUnavailableReason, providerName, transcribeOnHost, VoiceEngine, VoiceSettings, voiceSettingsClosed, type VoiceProvider } from './voice'import { watchVoiceCall } from './voice-call'import './call.css'+/**+ * Opens the window's own Settings at Voice chat; without it (no Settings screen around) the+ * call bar shows the voice settings in their own sheet.+ */+export const OpenVoiceSettings = createContext<(() => void) | null>(null)+/*** A voice call with a bot, as Grok Bot does it: a floating bar over the chat, which stays* readable underneath. What you say goes out as ordinary messages, its final replies are read@@ -51,6 +51,8 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {const engine = useRef<VoiceEngine | null>(null)/** When the current cloud engine started, for this month's minutes. */const cloudStartedAt = useRef<number | null>(null)+ /** The call settings the current engine was built from. */+ const engineChoice = useRef('')const closed = useRef(false)/** What carries the current engine's audio, and whether the call has been counted (once its first engine runs). */const engineName = useRef<VoiceCallEngine>('on_device')@@ -75,6 +77,7 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {if (closed.current) return// Every engine takes the microphone (and the speech helper) from any dictation in progress.stopDictation()+ engineChoice.current = VoiceSettings.engineChoice(provider)if (!provider && !onDeviceAvailable()) return void fallbackFromDevice()const op = new CallOperator(store, botId)const send = (text: string) => store.send(text, botId)@@ -118,11 +121,24 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {stopWatching = null}}+ // A muted call stays muted on the engine that takes over.+ next.muted = engine.current?.muted === trueengine.current = nextsetSession(next)void next.start()}+ /** After the call settings close: a different engine picked there takes over the call, which goes on. */+ const switchEngine = () => {+ const provider = VoiceSettings.provider()+ if (closed.current || VoiceSettings.engineChoice(provider) === engineChoice.current) return+ countCloudMinutes()+ engine.current?.end()+ setNotice(null)+ setBlocked(null)+ begin(provider)+ }+const rememberStatus = async () => {try {return await voiceStatus(await store.ready())@@ -131,15 +147,23 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {}}- /** No on-device speech here (Linux, or a build without the helper): use a provider with a key, if any. */+ /**+ * No on-device speech here (Linux, or a build without the helper): use a provider with a key, if+ * any. On device stays the pick, so closing the settings unchanged keeps that provider.+ */const fallbackFromDevice = async () => {+ const picked = engineChoice.currentconst configured = (await rememberStatus())?.providers.find((p) => p.configured)?.provider- if (closed.current) return+ // Ended, or another engine was picked meanwhile.+ if (closed.current || engineChoice.current !== picked) returnif (configured) {setNotice(`${onDeviceUnavailableReason()} Using ${providerName(configured)}.`)begin(configured)+ engineChoice.current = picked} else {setBlocked(`${onDeviceUnavailableReason()} Add an OpenAI or Gemini key in call settings.`)+ // Nothing runs: the next settings close tries again, with a key added there.+ engineChoice.current = ''}}@@ -157,6 +181,7 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {store.logCall(botId, Math.floor((Date.now() - startedAt) / 1000))}}, [])+ useEffect(() => voiceSettingsClosed.subscribe(switchEngine), [])const phase = session?.phase ?? nulluseEffect(() => {@@ -178,18 +203,18 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {const speaking = phase === 'speaking'const muted = session?.muted === trueconst working = bot ? isWorking(bot) : false- const statusText =- phase === null || phase === 'starting'- ? 'Connecting'- : phase === 'speaking'- ? 'Speaking'- : phase === 'failed'- ? "Can't listen"- : muted- ? 'Muted'- : working- ? 'Working, listening'- : 'Listening'+ const connecting = phase === null || phase === 'starting'+ const statusText = connecting+ ? 'Connecting'+ : phase === 'speaking'+ ? 'Speaking'+ : phase === 'failed'+ ? "Can't listen"+ : muted+ ? 'Muted'+ : working+ ? 'Working, listening'+ : 'Listening'const failure = blocked ?? (phase === 'failed' ? session?.failure : null)return (@@ -205,7 +230,7 @@ export function CallView({ botId, onSpeaking, interrupt, onEnd }: {{bot ? <BotAvatar bot={bot} size={34} /> : <span className="call-avatar-empty" />}</button><LevelDots- sample={() => ({ level: session?.level ?? 0, speaking: session?.phase === 'speaking', working })}+ sample={() => ({ level: session?.level ?? 0, speaking: session?.phase === 'speaking', working, connecting: connecting && !blocked })}color={color}width={120}label={statusText}diff --git a/apps/desktop/src/renderer/views/call/voice.test.ts b/apps/desktop/src/renderer/views/call/voice.test.tsnew file mode 100644index 00000000..f0d5dcb8--- /dev/null+++ b/apps/desktop/src/renderer/views/call/voice.test.ts@@ -0,0 +1,46 @@+import assert from 'node:assert/strict'+import { existsSync } from 'node:fs'+import { registerHooks } from 'node:module'+import { test } from 'node:test'++// The renderer imports without extensions, as the bundler resolves them.+registerHooks({+ resolve(specifier, context, nextResolve) {+ if (specifier.startsWith('.') && context.parentURL && !/\.[a-z]+$/.test(specifier)) {+ const url = new URL(`${specifier}.ts`, context.parentURL)+ if (existsSync(url)) return nextResolve(url.href, context)+ }+ return nextResolve(specifier, context)+ },+})++test('a call takes another engine only when what its engine is built from changes', async () => {+ const disk = new Map<string, string>()+ Object.assign(globalThis, {+ localStorage: { getItem: (key: string) => disk.get(key) ?? null, setItem: (key: string, value: string) => disk.set(key, value) },+ window: { addEventListener() {} },+ })+ const { VoiceSettings } = await import('./voice.ts')+ const settings = await import('../settings/voice-settings.ts')++ const device = VoiceSettings.engineChoice(null)+ assert.equal(VoiceSettings.engineChoice(null), device)+ settings.language.set('ja-JP')+ assert.notEqual(VoiceSettings.engineChoice(null), device)+ assert.notEqual(VoiceSettings.engineChoice('gemini'), VoiceSettings.engineChoice('openai'))++ const seen = [VoiceSettings.engineChoice('gemini')]+ for (const change of [+ () => settings.saveModel('gemini', 'realtime', 'live-9'),+ () => settings.saveVoice('gemini', 'Puck'),+ () => settings.mode('gemini').set('speech'),+ () => settings.saveModel('gemini', 'transcribe', 'flash-9'),+ () => settings.saveModel('gemini', 'speech', 'tts-9'),+ ]) {+ change()+ const choice = VoiceSettings.engineChoice('gemini')+ assert.equal(VoiceSettings.engineChoice('gemini'), choice)+ assert.ok(!seen.includes(choice), choice)+ seen.push(choice)+ }+})diff --git a/apps/desktop/src/renderer/views/call/voice.ts b/apps/desktop/src/renderer/views/call/voice.tsindex be3014c1..f2cae576 100644--- a/apps/desktop/src/renderer/views/call/voice.ts+++ b/apps/desktop/src/renderer/views/call/voice.ts@@ -53,8 +53,23 @@ export const VoiceSettings = {rate: () => rate.get(),/** The on-device recognizer's language; '' is the computer's. */language: () => language.get(),+ /** What a call's engine is built from (`CallView`'s `begin`): a different one picked mid-call takes over the call. */+ engineChoice: (p: VoiceProvider | null): string =>+ !p+ ? `device ${VoiceSettings.language()}`+ : VoiceSettings.isSpeechMode(p)+ ? `${p} speech ${VoiceSettings.transcribeModel(p)} ${VoiceSettings.speechModel(p)} ${VoiceSettings.voice(p)}`+ : `${p} ${VoiceSettings.model(p)} ${VoiceSettings.voice(p)}`,}+/** Rings when voice chat settings close, so a running call takes up a different engine picked there. */+class SettingsClosed extends Observable {+ ring() {+ this.changed()+ }+}+export const voiceSettingsClosed = new SettingsClosed()+/** This month's realtime minutes, counted on this device. */export const countVoiceUsage = (seconds: number, p: VoiceProvider) => addVoiceUsage(Math.floor(seconds), p)diff --git a/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx b/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsxindex 2b891a4a..9c1180fe 100644--- a/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx+++ b/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx@@ -1,4 +1,4 @@-import { onDeviceUnavailableReason } from '../call/voice'+import { onDeviceUnavailableReason, voiceSettingsClosed } from '../call/voice'import { useEffect, useMemo, useRef, useState } from 'react'import type { HostClient } from '../../client/host-client'import { Button, CardForm, CardSection, ChoicePicker, IconButton, Reveal, Spinner, ValueRow } from '../../components/Controls'@@ -32,10 +32,12 @@ export function VoiceChatSettingsView({ showsHeader = true }: { showsHeader?: bo/** Dictation on another provider than calls still needs that provider's key and speech-to-text model. */const dictationProvider = voice.isVoiceProvider(dictationEngine) && dictationEngine !== provider ? dictationEngine : nullconst [mode, setMode] = usePref(voice.mode(provider ?? 'openai'))+ // Closing hands a running call to a different engine picked here.+ useEffect(() => () => voiceSettingsClosed.ring(), [])const footer = provider- ? `Your own ${voice.voiceInfo[provider].name} key, billed by ${voice.voiceInfo[provider].name}. Applies from the next call.`+ ? `Your own ${voice.voiceInfo[provider].name} key, billed by ${voice.voiceInfo[provider].name}. During a call, applies when you close settings.`: window.codync.speech.available- ? 'On-device speech, on this computer. Applies from the next call.'+ ? 'On-device speech, on this computer. During a call, applies when you close settings.': onDeviceUnavailableReason()return (<SheetPage className={showsHeader ? 'settings-voice-sheet' : undefined}>diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.jsonindex b08afc8c..72adacf0 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json@@ -1053,10 +1053,10 @@"Version": "Version","this Mac": "dieser Mac","this computer": "dieser Computer",- "On-device speech, on this computer. Applies from the next call.": "Lokale Sprachverarbeitung auf diesem Computer. Gilt ab dem nächsten Anruf.",- "Apple speech, on this device. Applies from the next call.": "Apple-Sprachverarbeitung auf diesem Gerät. Gilt ab dem nächsten Anruf.",- "Android speech, on this device. Applies from the next call.": "Android-Sprachverarbeitung auf diesem Gerät. Gilt ab dem nächsten Anruf.",- "Your own {name} key, billed by {name}. Applies from the next call.": "Dein eigener {name}-Schlüssel, abgerechnet von {name}. Gilt ab dem nächsten Anruf.",+ "On-device speech, on this computer. During a call, applies when you close settings.": "Lokale Sprachverarbeitung auf diesem Computer. Während eines Anrufs gilt die Änderung, sobald du die Einstellungen schließt.",+ "Apple speech, on this device. During a call, applies when you close settings.": "Apple-Sprachverarbeitung auf diesem Gerät. Während eines Anrufs gilt die Änderung, sobald du die Einstellungen schließt.",+ "Android speech, on this device. During a call, applies when you close settings.": "Android-Sprachverarbeitung auf diesem Gerät. Während eines Anrufs gilt die Änderung, sobald du die Einstellungen schließt.",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "Dein eigener {name}-Schlüssel, abgerechnet von {name}. Während eines Anrufs gilt die Änderung, sobald du die Einstellungen schließt.","Reachable from anywhere through Cloudflare (encrypted).": "Von überall über Cloudflare erreichbar (verschlüsselt).","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "Aus: nur über WLAN und Tailscale erreichbar, nichts läuft über Cloudflare.","Connecting to Cloudflare…": "Verbindung mit Cloudflare wird hergestellt…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.jsonindex 811e8c3f..b414c54e 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json@@ -1053,10 +1053,10 @@"Version": "Versión","this Mac": "este Mac","this computer": "esta computadora",- "On-device speech, on this computer. Applies from the next call.": "Procesamiento de voz local en esta computadora. Se aplica a partir de la próxima llamada.",- "Apple speech, on this device. Applies from the next call.": "Reconocimiento de voz de Apple en este dispositivo. Se aplica a partir de la próxima llamada.",- "Android speech, on this device. Applies from the next call.": "Reconocimiento de voz de Android en este dispositivo. Se aplica a partir de la próxima llamada.",- "Your own {name} key, billed by {name}. Applies from the next call.": "Tu propia clave de {name}, facturada por {name}. Se aplica a partir de la próxima llamada.",+ "On-device speech, on this computer. During a call, applies when you close settings.": "Procesamiento de voz local en esta computadora. Durante una llamada, se aplica al cerrar los ajustes.",+ "Apple speech, on this device. During a call, applies when you close settings.": "Reconocimiento de voz de Apple en este dispositivo. Durante una llamada, se aplica al cerrar los ajustes.",+ "Android speech, on this device. During a call, applies when you close settings.": "Reconocimiento de voz de Android en este dispositivo. Durante una llamada, se aplica al cerrar los ajustes.",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "Tu propia clave de {name}, facturada por {name}. Durante una llamada, se aplica al cerrar los ajustes.","Reachable from anywhere through Cloudflare (encrypted).": "Accesible desde cualquier lugar mediante Cloudflare (cifrado).","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "Desactivado: solo se accede por Wi-Fi y Tailscale; nada pasa por Cloudflare.","Connecting to Cloudflare…": "Conectando con Cloudflare…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.jsonindex 136f0c33..9bfd549b 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json@@ -1053,10 +1053,10 @@"Version": "Version","this Mac": "ce Mac","this computer": "cet ordinateur",- "On-device speech, on this computer. Applies from the next call.": "Traitement vocal local sur cet ordinateur. S’applique au prochain appel.",- "Apple speech, on this device. Applies from the next call.": "Reconnaissance vocale Apple sur cet appareil. S’applique au prochain appel.",- "Android speech, on this device. Applies from the next call.": "Reconnaissance vocale Android sur cet appareil. S’applique au prochain appel.",- "Your own {name} key, billed by {name}. Applies from the next call.": "Votre propre clé {name}, facturée par {name}. S’applique au prochain appel.",+ "On-device speech, on this computer. During a call, applies when you close settings.": "Traitement vocal local sur cet ordinateur. Pendant un appel, s’applique à la fermeture des réglages.",+ "Apple speech, on this device. During a call, applies when you close settings.": "Reconnaissance vocale Apple sur cet appareil. Pendant un appel, s’applique à la fermeture des réglages.",+ "Android speech, on this device. During a call, applies when you close settings.": "Reconnaissance vocale Android sur cet appareil. Pendant un appel, s’applique à la fermeture des réglages.",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "Votre propre clé {name}, facturée par {name}. Pendant un appel, s’applique à la fermeture des réglages.","Reachable from anywhere through Cloudflare (encrypted).": "Accessible de partout via Cloudflare (chiffré).","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "Désactivé : accessible uniquement par Wi-Fi et Tailscale, rien ne passe par Cloudflare.","Connecting to Cloudflare…": "Connexion à Cloudflare…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.jsonindex 6a139178..aff8603d 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json@@ -1053,10 +1053,10 @@"Version": "バージョン","this Mac": "このMac","this computer": "このコンピュータ",- "On-device speech, on this computer. Applies from the next call.": "このコンピューター上のデバイス上の音声。次回通話から適用されます。",- "Apple speech, on this device. Applies from the next call.": "Apple のスピーチ、このデバイス上で。次回通話から適用されます。",- "Android speech, on this device. Applies from the next call.": "このデバイス上の Android 音声。次回通話から適用されます。",- "Your own {name} key, billed by {name}. Applies from the next call.": "{name} によって請求される、独自の {name} キー。次回通話から適用されます。",+ "On-device speech, on this computer. During a call, applies when you close settings.": "このコンピューター上のデバイス上の音声。通話中は、設定を閉じると適用されます。",+ "Apple speech, on this device. During a call, applies when you close settings.": "Apple のスピーチ、このデバイス上で。通話中は、設定を閉じると適用されます。",+ "Android speech, on this device. During a call, applies when you close settings.": "このデバイス上の Android 音声。通話中は、設定を閉じると適用されます。",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "{name} によって請求される、独自の {name} キー。通話中は、設定を閉じると適用されます。","Reachable from anywhere through Cloudflare (encrypted).": "Cloudflare (暗号化) を介してどこからでもアクセス可能。","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "オフ: Wi-Fi と Tailscale のみが到達し、Cloudflare は何も通過しません。","Connecting to Cloudflare…": "Cloudflareに接続中…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.jsonindex 83e149df..5c7133b7 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json@@ -1053,10 +1053,10 @@"Version": "버전","this Mac": "이 Mac","this computer": "이 컴퓨터",- "On-device speech, on this computer. Applies from the next call.": "이 컴퓨터의 기기 내 음성 처리입니다. 다음 통화부터 적용됩니다.",- "Apple speech, on this device. Applies from the next call.": "이 기기의 Apple 음성 처리입니다. 다음 통화부터 적용됩니다.",- "Android speech, on this device. Applies from the next call.": "이 기기의 Android 음성 처리입니다. 다음 통화부터 적용됩니다.",- "Your own {name} key, billed by {name}. Applies from the next call.": "나의 {name} 키이며 {name}에서 과금합니다. 다음 통화부터 적용됩니다.",+ "On-device speech, on this computer. During a call, applies when you close settings.": "이 컴퓨터의 기기 내 음성 처리입니다. 통화 중에는 설정을 닫으면 적용됩니다.",+ "Apple speech, on this device. During a call, applies when you close settings.": "이 기기의 Apple 음성 처리입니다. 통화 중에는 설정을 닫으면 적용됩니다.",+ "Android speech, on this device. During a call, applies when you close settings.": "이 기기의 Android 음성 처리입니다. 통화 중에는 설정을 닫으면 적용됩니다.",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "나의 {name} 키이며 {name}에서 과금합니다. 통화 중에는 설정을 닫으면 적용됩니다.","Reachable from anywhere through Cloudflare (encrypted).": "Cloudflare를 통해 어디서나 접근할 수 있습니다(암호화됨).","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "끄면 Wi-Fi와 Tailscale로만 접근하며 Cloudflare를 거치지 않습니다.","Connecting to Cloudflare…": "Cloudflare 연결 중…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.jsonindex ccfd6969..94245b8b 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json@@ -1053,10 +1053,10 @@"Version": "版本","this Mac": "这台 Mac","this computer": "这台电脑",- "On-device speech, on this computer. Applies from the next call.": "使用这台电脑上的本机语音。下次通话起生效。",- "Apple speech, on this device. Applies from the next call.": "使用这台设备上的 Apple 语音。下次通话起生效。",- "Android speech, on this device. Applies from the next call.": "使用这台设备上的 Android 语音。下次通话起生效。",- "Your own {name} key, billed by {name}. Applies from the next call.": "使用你自己的 {name} 密钥,由 {name} 计费。下次通话起生效。",+ "On-device speech, on this computer. During a call, applies when you close settings.": "使用这台电脑上的本机语音。通话中更改,关闭设置后生效。",+ "Apple speech, on this device. During a call, applies when you close settings.": "使用这台设备上的 Apple 语音。通话中更改,关闭设置后生效。",+ "Android speech, on this device. During a call, applies when you close settings.": "使用这台设备上的 Android 语音。通话中更改,关闭设置后生效。",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "使用你自己的 {name} 密钥,由 {name} 计费。通话中更改,关闭设置后生效。","Reachable from anywhere through Cloudflare (encrypted).": "通过 Cloudflare 随时随地连接(已加密)。","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "关闭:只有 Wi-Fi 和 Tailscale 能连上,不会经过 Cloudflare。","Connecting to Cloudflare…": "正在连接 Cloudflare…",diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.jsonindex edd7bbf6..95423d85 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json@@ -1053,10 +1053,10 @@"Version": "版本","this Mac": "這臺 Mac","this computer": "這臺電腦",- "On-device speech, on this computer. Applies from the next call.": "使用這臺電腦上的本機語音。下次通話起生效。",- "Apple speech, on this device. Applies from the next call.": "使用這臺裝置上的 Apple 語音。下次通話起生效。",- "Android speech, on this device. Applies from the next call.": "使用這臺裝置上的 Android 語音。下次通話起生效。",- "Your own {name} key, billed by {name}. Applies from the next call.": "使用你自己的 {name} 金鑰,由 {name} 計費。下次通話起生效。",+ "On-device speech, on this computer. During a call, applies when you close settings.": "使用這臺電腦上的本機語音。通話中更改,關閉設定後生效。",+ "Apple speech, on this device. During a call, applies when you close settings.": "使用這臺裝置上的 Apple 語音。通話中更改,關閉設定後生效。",+ "Android speech, on this device. During a call, applies when you close settings.": "使用這臺裝置上的 Android 語音。通話中更改,關閉設定後生效。",+ "Your own {name} key, billed by {name}. During a call, applies when you close settings.": "使用你自己的 {name} 金鑰,由 {name} 計費。通話中更改,關閉設定後生效。","Reachable from anywhere through Cloudflare (encrypted).": "透過 Cloudflare 隨時隨地連線(已加密)。","Off: only Wi-Fi and Tailscale reach it, nothing goes through Cloudflare.": "關閉:只有 Wi-Fi 和 Tailscale 能連上,不會經過 Cloudflare。","Connecting to Cloudflare…": "正在連線 Cloudflare…",diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swiftindex 2d370d88..45aa836d 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift@@ -17,6 +17,8 @@ struct CallView: View {@State private var startedAt = Date.now/// When the current cloud engine started, for this month's minutes.@State private var cloudStartedAt: Date?+ /// The call settings the current engine was built from.+ @State private var engineChoice = ""/// One line under the bar, e.g. why the call fell back to on-device voice.@State private var notice: String?@State private var settings = false@@ -65,6 +67,7 @@ struct CallView: View {begin(cloud: nil)}}+ .onChange(of: settings) { _, open in if !open { switchEngine() } }.codyncSheet(isPresented: $settings) { VoiceChatSettingsView() }}@@ -74,6 +77,7 @@ struct CallView: View {if provider != nil, let client = model.client {Task { if let status = try? await client.voiceStatus() { VoiceSettings.remember(status) } }}+ engineChoice = VoiceSettings.engineChoice(provider)let op = CallOperator(model: model, botId: botId)let engine: any VoiceEngineif let provider, VoiceSettings.isSpeechMode(provider) {@@ -115,10 +119,22 @@ struct CallView: View {model.endVoiceCall(callID)}}+ // A muted call stays muted on the engine that takes over.+ engine.muted = session?.muted == truesession = engineTask { await engine.start() }}+ /// After the call settings close: a different engine picked there takes over the call, which goes on.+ private func switchEngine() {+ let provider = VoiceSettings.provider+ guard VoiceSettings.engineChoice(provider) != engineChoice else { return }+ countCloudMinutes()+ session?.end()+ notice = nil+ begin(cloud: provider)+ }+private func countCloudMinutes() {guard let provider = session?.provider, let since = cloudStartedAt else { return }VoiceUsage.add(seconds: Int(Date.now.timeIntervalSince(since)), for: provider)@@ -140,7 +156,8 @@ struct CallView: View {HStack(spacing: 10) {avatarLevelDots(level: session?.level ?? 0, speaking: session?.phase == .speaking,- working: bot?.isWorking == true, color: color, reduceMotion: reduceMotion)+ working: bot?.isWorking == true, connecting: (session?.phase ?? .starting) == .starting,+ color: color, reduceMotion: reduceMotion).frame(minWidth: Self.dotsWidth, maxWidth: Self.dotsMaxWidth, minHeight: Self.dotsHeight, maxHeight: Self.dotsHeight).accessibilityLabel(statusText)// Audio leaves the phone: say where.diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swiftindex 885a1808..0cc1637e 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift@@ -49,7 +49,7 @@ final class OnDeviceEngine: VoiceEngine {static let pauseKey = "callPause"static let rateKey = "callRate"/// On-device recognition language (a locale identifier); empty follows the system.- static let languageKey = "callLanguage"+ nonisolated static let languageKey = "callLanguage"/// Settings options: the system's language, then every language the recognizer supports, by name.static var languageOptions: [(String, String)] {diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swiftindex 343c3168..61d47f11 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift@@ -62,9 +62,9 @@ public struct VoiceChatSettingsView: View {private var engineFooter: String {guard let provider = VoiceProvider(rawValue: engine) else {- return "Apple speech, on this device. Applies from the next call."+ return "Apple speech, on this device. During a call, applies when you close settings."}- return "Your own \(provider.name) key, billed by \(provider.name). Applies from the next call."+ return "Your own \(provider.name) key, billed by \(provider.name). During a call, applies when you close settings."}}diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceEngine.swift b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceEngine.swiftindex f0457470..11d3096c 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceEngine.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceEngine.swift@@ -130,6 +130,14 @@ enum VoiceSettings {return text.applyingTransform(StringTransform("Hans-Hant"), reverse: false) ?? text}+ /// What a call's engine is built from (`CallView.begin`): a different one picked mid-call takes over the call.+ static func engineChoice(_ provider: VoiceProvider?) -> String {+ guard let provider else { return "device \(UserDefaults.standard.string(forKey: OnDeviceEngine.languageKey) ?? "")" }+ return isSpeechMode(provider)+ ? "\(provider.rawValue) speech \(transcribeModel(provider)) \(speechModel(provider)) \(voice(provider))"+ : "\(provider.rawValue) \(model(provider)) \(voice(provider))"+ }+static func voiceKey(_ provider: VoiceProvider) -> String { "callVoice.\(provider.rawValue)" }static func voice(_ provider: VoiceProvider) -> String {diff --git a/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift b/apps/ios/Kit/Sources/CodyncUI/LevelDots.swiftindex 5e665d11..7bc063e6 100644--- a/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift+++ b/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift@@ -3,14 +3,24 @@ import SwiftUI/// A dotted line (the call bar, the composer's recording pill): it follows your voice while/// listening, ripples while the bot talks, breathes while it works, and rests as faint dots otherwise.+/// While a call connects it shows an indeterminate progress line instead, and fades back to the dots.struct LevelDots: View {let level: Floatlet speaking: Boollet working: Bool+ var connecting = falselet color: Colorlet reduceMotion: Boolvar body: some View {+ ZStack {+ dots.opacity(connecting ? 0 : 1)+ if connecting { ConnectingLine(reduceMotion: reduceMotion).transition(.opacity) }+ }+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: connecting)+ }++ private var dots: some View {TimelineView(.animation(paused: reduceMotion)) { context inCanvas { canvas, size inlet t = context.date.timeIntervalSinceReferenceDate@@ -37,3 +47,28 @@ struct LevelDots: View {}}}++/// Indeterminate progress: a short capsule slides left to right along a faint track, on a loop;+/// with reduced motion it rests at the left.+private struct ConnectingLine: View {+ let reduceMotion: Bool+ /// Seconds for the segment to cross the track.+ private static let period = 1.4++ var body: some View {+ TimelineView(.animation(paused: reduceMotion)) { context in+ Canvas { canvas, size in+ let mid = size.height / 2+ let track = CGRect(x: 0, y: mid - 0.75, width: size.width, height: 1.5)+ canvas.fill(Path(roundedRect: track, cornerRadius: 0.75), with: .color(Palette.accent.opacity(0.15)))+ let width = size.width / 3+ let progress = reduceMotion ? 0+ : context.date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: Self.period) / Self.period+ let segment = CGRect(x: reduceMotion ? 0 : -width + progress * (size.width + width), y: mid - 1.75,+ width: width, height: 3.5)+ canvas.clip(to: Path(CGRect(origin: .zero, size: size)))+ canvas.fill(Path(roundedRect: segment, cornerRadius: 1.75), with: .color(Palette.accent))+ }+ }+ }+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/VoiceSettingsTests.swift b/apps/ios/Kit/Tests/CodyncUITests/VoiceSettingsTests.swiftindex 0e912a62..67277148 100644--- a/apps/ios/Kit/Tests/CodyncUITests/VoiceSettingsTests.swift+++ b/apps/ios/Kit/Tests/CodyncUITests/VoiceSettingsTests.swift@@ -32,3 +32,29 @@ import TestingVoiceSettings.remember(old)#expect(VoiceSettings.defaults(p).transcribe == "gemini-10-flash")}++/// A call takes another engine only when what its engine is built from changes: the engine, the mode,+/// a model or the voice it uses, or the on-device language.+@Test func engineChoiceChangesWithWhatTheCallIsBuiltFrom() {+ let p = VoiceProvider.openAI+ let keys = [OnDeviceEngine.languageKey, VoiceSettings.modelKey(p), VoiceSettings.voiceKey(p), VoiceSettings.modeKey(p),+ VoiceSettings.transcribeKey(p), VoiceSettings.speechKey(p)]+ defer { keys.forEach(UserDefaults.standard.removeObject(forKey:)) }+ keys.forEach(UserDefaults.standard.removeObject(forKey:))++ let device = VoiceSettings.engineChoice(nil)+ #expect(VoiceSettings.engineChoice(nil) == device)+ UserDefaults.standard.set("ja-JP", forKey: OnDeviceEngine.languageKey)+ #expect(VoiceSettings.engineChoice(nil) != device)+ #expect(VoiceSettings.engineChoice(p) != VoiceSettings.engineChoice(.gemini))++ var seen = [VoiceSettings.engineChoice(p)]+ for (key, value) in [(VoiceSettings.modelKey(p), "realtime-9"), (VoiceSettings.voiceKey(p), "cedar"), (VoiceSettings.modeKey(p), "speech"),+ (VoiceSettings.transcribeKey(p), "transcribe-9"), (VoiceSettings.speechKey(p), "tts-9")] {+ UserDefaults.standard.set(value, forKey: key)+ let choice = VoiceSettings.engineChoice(p)+ #expect(VoiceSettings.engineChoice(p) == choice)+ #expect(!seen.contains(choice), "\(key)")+ seen.append(choice)+ }+}diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex bf987d6e..66b2abb2 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -22,6 +22,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 新增「Send Text to Bot」捷徑,可選擇 Bot 並傳送文字;預設在背景傳送,也可開啟「Open Chat」顯示對話。- 點對話上方的 Bot 會打開它的詳情、資料庫、記憶與設定;「新會話」改到 Bot 列表的長按選單。- 用 Gemini 即時語音通話時,Gemini 聽得到你說話並會回答,也會念出 Bot 的回覆;先前通話可能一直沒有聲音、也沒有回應。+- 通話中在設定換了語音(例如從本機換成 Gemini),關掉設定後通話就改用新的語音繼續,不必掛斷重打。+- 語音通話連線中,通話列會顯示一條跑動的進度線,連上後才換回音量點點。### 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.@@ -37,6 +39,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 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.- Tapping the bot at the top of its chat opens its Details, Library, Memory and Settings; New session moved to the bot's touch-and-hold menu in the list.- Gemini realtime voice calls hear you, answer and read the bot's replies aloud; before, a call could stay silent with no reply.+- Pick another voice in the call settings mid-call (on-device to Gemini, say) and the call carries on with it once you close them.+- While a voice call connects, the call bar shows a moving progress line instead of flat dots.## 2.24.0diff --git a/docs/features/voice-call.md b/docs/features/voice-call.mdindex 32c55c1e..c4b7f6fd 100644--- a/docs/features/voice-call.md+++ b/docs/features/voice-call.md@@ -13,7 +13,9 @@ On iOS, [Open Live Mode in Shortcuts](ios-shortcuts.md) can select a bot and sta- UI follows Grok Bot: a floating capsule over the top of the chat (`ThreadView` overlay), and thechat stays readable and usable underneath. Left to right: the bot's avatar (pulses whilespeaking; tap it to interrupt), a dotted level line (your voice while listening, a ripple while- the bot speaks, a slow breath while it works), gear (call settings), mic (mute), red ✕ (end).+ the bot speaks, a slow breath while it works; while the engine connects, an indeterminate progress+ line instead: a short segment sliding along a faint track, still at the left under Reduce Motion,+ fading back to the dots once it listens), gear (call settings), mic (mute), red ✕ (end).- Desktop: the capsule sits 16 CSS pixels below the window top and explicitly excludes itselffrom Electron's window-drag region so the gear, mute and end buttons receive mouse clicks.The iPhone places its capsule below native navigation; the terminal has no call controls.@@ -155,7 +157,14 @@ bring their own provider key; Codync never pays for or resells minutes.### Engines-The gear's first section is **Voice engine** (applies from the next call):+The gear's first section is **Voice engine**. Each client remembers what the running engine was built from+(engine, mode, models, voice; On device: its language; `engineChoice`). When the voice settings close and that+differs, the call ends that engine and starts the new one without hanging up: same call, one "Voice chat" line+at the end, cloud minutes counted up to the switch, mute kept, a fallback notice cleared. A call that fell back+to On device tries the picked cloud engine again the same way. Desktop and Android check whenever a voice+settings view closes (the gear, Settings, a computer's row); on the iPhone only the gear is open during a call.+Where on-device speech is missing (desktop on Linux or Windows), the provider standing in for On device keeps+running while On device stays picked.| Engine | Needs | Transport | Code || --- | --- | --- | --- |diff --git a/web/content/docs/voice.mdx b/web/content/docs/voice.mdxindex 6561060e..beac2ca7 100644--- a/web/content/docs/voice.mdx+++ b/web/content/docs/voice.mdx@@ -14,7 +14,7 @@ When the message box is empty and the bot isn't working, the send button becomesThe call bar floats at the top of the chat, and the chat stays readable and usable underneath. From left to right:- the bot's avatar: it pulses while the bot speaks, and tapping it then interrupts the reply-- a line of dots that follows your voice while you speak, ripples while the bot speaks, and breathes slowly while it works+- a line of dots that follows your voice while you speak, ripples while the bot speaks, and breathes slowly while it works; while the call connects, a moving progress line takes its place- the provider's name, whenever audio leaves your device (see "What goes where" below)- **Call settings** (the gear), **Mute**, and **End call** (the red ✕)@@ -33,7 +33,7 @@ Open **Voice chat** settings from the call bar's gear, or:- **iPhone:** **Computers & settings → Voice chat → Voice and API keys**.- **Desktop app:** **Settings → Voice chat**.-Under **Engine**, pick one. The choice is kept on this device and applies from your next call.+Under **Engine**, pick one. The choice is kept on this device. Changed during a call, it takes over that call once you close the settings; the call goes on, still muted if it was.| Engine | Needs | How it works || --- | --- | --- |