Skip to content

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.

feat(ios): show a recording pill while dictating

leepokaid6b4aec93a1d
diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift
index 38402943..2d370d88 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Call/CallView.swift
@@ -139,7 +139,7 @@ struct CallView: View {
private var bar: some View {
HStack(spacing: 10) {
avatar
- CallLevelDots(level: session?.level ?? 0, speaking: session?.phase == .speaking,
+ LevelDots(level: session?.level ?? 0, speaking: session?.phase == .speaking,
working: bot?.isWorking == true, color: color, reduceMotion: reduceMotion)
.frame(minWidth: Self.dotsWidth, maxWidth: Self.dotsMaxWidth, minHeight: Self.dotsHeight, maxHeight: Self.dotsHeight)
.accessibilityLabel(statusText)
@@ -218,40 +218,3 @@ struct CallView: View {
}
}
}
-
-/// 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.
-private struct CallLevelDots: View {
- let level: Float
- let speaking: Bool
- let working: Bool
- let color: Color
- let reduceMotion: Bool
-
- var body: some View {
- TimelineView(.animation(paused: reduceMotion)) { context in
- Canvas { canvas, size in
- let t = context.date.timeIntervalSinceReferenceDate
- let spacing: CGFloat = 8
- let count = max(1, Int(size.width / spacing))
- for i in 0..<count {
- let x = CGFloat(i) * spacing + spacing / 2
- let wave = (sin(Double(i) * 0.55 - t * 6) + 1) / 2
- let amount: Double = if speaking {
- 0.5 + 0.5 * wave
- } else if level > 0.05 {
- max(0.2, Double(level)) * (0.45 + 0.55 * wave)
- } else if working {
- 0.25 * ((sin(t * 2.4) + 1) / 2)
- } else {
- 0.08
- }
- let height = 4 + CGFloat(amount) * (size.height - 4)
- let rect = CGRect(x: x - 1.25, y: (size.height - height) / 2, width: 2.5, height: height)
- let tint = speaking ? Palette.accent : color
- canvas.fill(Path(roundedRect: rect, cornerRadius: 1.25), with: .color(tint.opacity(0.5 + 0.5 * amount)))
- }
- }
- }
- }
-}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift
index e3b5cc07..885a1808 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift
@@ -195,7 +195,8 @@ final class OnDeviceEngine: VoiceEngine {
// MARK: audio-thread closures (built outside the main actor)
- private nonisolated static func tap(_ request: SFSpeechAudioBufferRecognitionRequest,
+ /// Feeds the recognizer and reports the microphone's level, 0…1 (dictation uses it too).
+ nonisolated static func tap(_ request: SFSpeechAudioBufferRecognitionRequest,
meter: @escaping @Sendable (Float) -> Void) -> AVAudioNodeTapBlock {
{ buffer, _ in
request.append(buffer)
diff --git a/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift b/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift
new file mode 100644
index 00000000..5e665d11
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/LevelDots.swift
@@ -0,0 +1,39 @@
+import CodyncKit
+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.
+struct LevelDots: View {
+ let level: Float
+ let speaking: Bool
+ let working: Bool
+ let color: Color
+ let reduceMotion: Bool
+
+ var body: some View {
+ TimelineView(.animation(paused: reduceMotion)) { context in
+ Canvas { canvas, size in
+ let t = context.date.timeIntervalSinceReferenceDate
+ let spacing: CGFloat = 8
+ let count = max(1, Int(size.width / spacing))
+ for i in 0..<count {
+ let x = CGFloat(i) * spacing + spacing / 2
+ let wave = (sin(Double(i) * 0.55 - t * 6) + 1) / 2
+ let amount: Double = if speaking {
+ 0.5 + 0.5 * wave
+ } else if level > 0.05 {
+ max(0.2, Double(level)) * (0.45 + 0.55 * wave)
+ } else if working {
+ 0.25 * ((sin(t * 2.4) + 1) / 2)
+ } else {
+ 0.08
+ }
+ let height = 4 + CGFloat(amount) * (size.height - 4)
+ let rect = CGRect(x: x - 1.25, y: (size.height - height) / 2, width: 2.5, height: height)
+ let tint = speaking ? Palette.accent : color
+ canvas.fill(Path(roundedRect: rect, cornerRadius: 1.25), with: .color(tint.opacity(0.5 + 0.5 * amount)))
+ }
+ }
+ }
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
index dc41a053..36ad80f4 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
@@ -207,29 +207,31 @@ struct Composer: View {
.animation(Motion.reduced(Motion.morph, reduceMotion), value: canSend)
}
- /// Dictation, beside send / call (Grok Bot's): a light circle; red while it listens.
+ /// Dictation, beside send / call (Grok Bot's): a light circle; while it listens, the recording pill.
private var micButton: some View {
- let on = dictation.listening
- return Button {
- if on {
- dictation.stop()
+ Group {
+ if dictation.listening {
+ RecordingPill(dictation: dictation, height: buttonSize)
+ .transition(.opacity.combined(with: .scale(scale: 0.9, anchor: .trailing)))
} else {
- dictatedAfter = draft
- Task { await dictation.start { said in draft = Dictation.join(dictatedAfter, said) } }
+ Button {
+ dictatedAfter = draft
+ Task { await dictation.start { said in draft = Dictation.join(dictatedAfter, said) } }
+ } label: {
+ Image(systemName: "mic")
+ .font(.system(size: 15, weight: .medium))
+ .foregroundStyle(Palette.secondary)
+ .frame(width: buttonSize, height: buttonSize)
+ .background(Palette.bubbleAgent, in: Circle())
+ .contentShape(Circle())
+ }
+ .buttonStyle(PressScale())
+ .accessibilityLabel("Dictate")
+ .help("Dictate")
+ .transition(.opacity)
}
- } label: {
- Image(systemName: on ? "mic.fill" : "mic")
- .font(.system(size: 15, weight: .medium))
- .contentTransition(.symbolEffect(.replace))
- .foregroundStyle(on ? .white : Palette.secondary)
- .frame(width: buttonSize, height: buttonSize)
- .background(on ? Palette.danger : Palette.bubbleAgent, in: Circle())
- .contentShape(Circle())
}
- .buttonStyle(PressScale())
- .accessibilityLabel(on ? "Stop dictating" : "Dictate")
- .help(on ? "Stop dictating" : "Dictate")
- .animation(Motion.reduced(Motion.morph, reduceMotion), value: on)
+ .animation(Motion.reduced(Motion.morph, reduceMotion), value: dictation.listening)
}
private var box: some View {
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Dictation.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Dictation.swift
index 24326d82..aa4e64a3 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Dictation.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Dictation.swift
@@ -3,11 +3,15 @@ import Speech
import SwiftUI
/// Dictation into the message box with on-device speech: the words appear as they're recognized,
-/// after what was already typed; the mic again, or the recognizer finishing on a pause, stops it.
-/// It uses the call's language setting.
+/// after what was already typed; the recording pill's stop, or the recognizer finishing on a pause,
+/// stops it. It uses the call's language setting.
@MainActor @Observable
final class Dictation {
private(set) var listening = false
+ /// When it started listening, for the recording pill's time.
+ private(set) var startedAt = Date.now
+ /// The microphone's level while listening, 0…1.
+ private(set) var level: Float = 0
@ObservationIgnored private let engine = AVAudioEngine()
@ObservationIgnored private var request: SFSpeechAudioBufferRecognitionRequest?
@ObservationIgnored private var task: SFSpeechRecognitionTask?
@@ -48,13 +52,16 @@ final class Dictation {
self.request = request
let input = engine.inputNode
input.removeTap(onBus: 0)
- input.installTap(onBus: 0, bufferSize: 1024, format: format, block: Self.tap(request))
+ input.installTap(onBus: 0, bufferSize: 1024, format: format, block: OnDeviceEngine.tap(request) { [weak self] level in
+ Task { @MainActor in if self?.listening == true { self?.level = level } }
+ })
engine.prepare()
do {
try engine.start()
} catch {
return stop()
}
+ startedAt = .now
listening = true
task = recognizer.recognitionTask(with: request, resultHandler: Self.results(self, generation: generation))
}
@@ -70,6 +77,7 @@ final class Dictation {
heard = nil
if listening { try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation) }
listening = false
+ level = 0
}
private func recognized(_ text: String, final: Bool, generation: Int) {
@@ -78,10 +86,6 @@ final class Dictation {
if final { stop() }
}
- private nonisolated static func tap(_ request: SFSpeechAudioBufferRecognitionRequest) -> AVAudioNodeTapBlock {
- { buffer, _ in request.append(buffer) }
- }
-
private nonisolated static func results(_ dictation: Dictation, generation: Int) -> @Sendable (SFSpeechRecognitionResult?, (any Error)?) -> Void {
{ result, error in
let text = result?.bestTranscription.formattedString
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/RecordingPill.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/RecordingPill.swift
new file mode 100644
index 00000000..5e20df82
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/RecordingPill.swift
@@ -0,0 +1,35 @@
+import CodyncKit
+import SwiftUI
+
+/// Dictation in progress, in place of the composer's mic: stop, the time since it started, and
+/// dots that follow the microphone's level (the desktop composer's pill).
+struct RecordingPill: View {
+ let dictation: Dictation
+ let height: CGFloat
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+
+ var body: some View {
+ HStack(spacing: 6) {
+ Button { dictation.stop() } label: {
+ Image(systemName: "stop.fill")
+ .font(.system(size: 11, weight: .bold))
+ .foregroundStyle(Palette.text)
+ .frame(width: height - 8, height: height - 8)
+ .contentShape(Circle())
+ }
+ .buttonStyle(PressScale())
+ .accessibilityLabel("Stop dictating")
+ .help("Stop dictating")
+ Text(timerInterval: dictation.startedAt...Date.distantFuture, countsDown: false)
+ .font(.subheadline.monospacedDigit())
+ .foregroundStyle(Palette.text)
+ LevelDots(level: dictation.level, speaking: false, working: false, color: Palette.text, reduceMotion: reduceMotion)
+ .frame(width: 32, height: 12)
+ .accessibilityLabel("Listening")
+ }
+ .padding(.leading, 4)
+ .padding(.trailing, 10)
+ .frame(height: height)
+ .background(Palette.bubbleAgent, in: Capsule())
+ }
+}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 4b20face..96376f0f 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -6,14 +6,10 @@ any left). tools/asc-submit.py reads the released version's section;
a version without one gets a generic "Bug fixes and improvements" line. Delete old sections.
-->
-## 2.21.0
+## 2.22.0
### zh-Hant
-- Routine 還沒動手就失敗(例如額度用完)時,會在 1、5、15 分鐘後自動再試;已經動過手或超過時間上限的失敗,通知旁有重試按鈕讓你決定
-- Bot 的記憶頁改成唯讀,想改記憶直接跟 bot 說;Dreams 分頁新增的記憶是綠色、拿掉的是紅色,旁邊的資訊按鈕說明做夢在做什麼
-- Bot 可以設定後備 agent:Claude Code 額度用完、被限流或登出時,下一個 agent(例如 Codex)會在同一個聊天接手,帶著記憶和這一輪做到哪裡;原本的 agent 恢復後自動換回來,也可以按 Switch back;如果是被登出,聊天裡會同時出現它的登入卡片,登入後就換回來。Bot 也能自己設定這份清單,可在設定中關閉
+- 用麥克風聽寫時,麥克風按鈕會變成錄音膠囊:停止鍵、錄了多久,還有跟著你說話起伏的點點
### en-US
-- A routine that fails before doing anything (a usage limit, say) tries again on its own after 1, 5 and 15 minutes; one that already acted or hit its time limit gets a retry button on its failure notice, so you decide
-- A bot's memory is now read-only: to change it, tell the bot. In the Dreams tab, added memories show in green, ones it took out in red, and an info button explains what dreaming does
-- Fallback agents: when a bot's agent runs out of usage, is rate limited or signed out, the next one (Codex, say) carries on in the same chat, with its memory and where the turn had got to; the bot goes back once its own agent recovers, or when you tap Switch back. If it was signed out, its sign-in card shows up in the chat too, and signing in brings it back. A bot can set this list itself, which you can turn off in its settings
+- While you dictate, the mic turns into a recording pill: a stop button, how long you've been talking, and dots that follow your voice