The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(voice): wire up local Whisper STT mic + never auto-send dictation
purple3d232cb214b0
diff --git a/src/App.tsx b/src/App.tsxindex d65b2213..347a3f2b 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -1,6 +1,7 @@import { useEffect } from 'react'import { AppShell } from './components/layout/AppShell'import { useSettingsStore } from './stores/settingsStore'+import { useVoiceStore } from './stores/voiceStore'function App() {useEffect(() => {@@ -11,6 +12,17 @@ function App() {})}+ // Probe local Whisper (STT) once at boot and push the result into the voice+ // store so the mic button reflects real availability. initWhisperCheck() was+ // previously never called anywhere → isSpeechRecognitionSupported() stayed+ // false forever → the mic was permanently disabled even with faster-whisper+ // installed and running. Fire-and-forget; never blocks first render.+ import('./api/voice').then(({ initWhisperCheck }) => {+ initWhisperCheck()+ .then((ok) => useVoiceStore.getState().setSttAvailable(ok))+ .catch(() => {})+ })+// Bug BB v2.5.0 — push persisted GPU selection from localStorage into// AppState at app boot so the next Ollama / ComfyUI spawn picks it up// without the user having to open Settings first. Read the settingdiff --git a/src/api/voice.ts b/src/api/voice.tsindex e428dc52..46a5ffdd 100644--- a/src/api/voice.ts+++ b/src/api/voice.ts@@ -26,6 +26,15 @@ export async function initWhisperCheck(): Promise<boolean> {return whisperAvailable}+// Force a fresh availability probe, bypassing the one-shot cache. Used after+// the in-app faster-whisper install finishes, and when the mic button mounts+// while STT shows unavailable — the persistent Whisper server can take a while+// to load its model after boot, so the first startup probe may have been early.+export async function recheckWhisperAvailable(): Promise<boolean> {+ whisperChecked = false+ return initWhisperCheck()+}+export function isSpeechSynthesisSupported(): boolean {return !!window.speechSynthesis;}diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex 194e9e81..e54a94fd 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -176,7 +176,10 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp/><VoiceButton- onTranscript={(text) => { setInput(text); requestAnimationFrame(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 200) + 'px' } }) }}+ // Dictation fills the input and NEVER auto-sends — the user reviews+ // and presses Send (David 2026-06-06). Append to any text already+ // typed instead of replacing it, so a transcript can't wipe input.+ onTranscript={(text) => { setInput((prev) => (prev.trim() ? prev.replace(/\s+$/, '') + ' ' + text : text)); requestAnimationFrame(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 200) + 'px' } }) }}onRecordingChange={(r) => setIsVoiceRecording(r)}disabled={isGenerating}/>diff --git a/src/components/chat/VoiceButton.tsx b/src/components/chat/VoiceButton.tsxindex 6a2b1286..bdfb86a1 100644--- a/src/components/chat/VoiceButton.tsx+++ b/src/components/chat/VoiceButton.tsx@@ -1,3 +1,4 @@+import { useEffect } from "react"import { motion } from "framer-motion"import { Mic, MicOff, Loader2 } from "lucide-react"import { useVoice } from "../../hooks/useVoice"@@ -9,7 +10,15 @@ interface Props {}export function VoiceButton({ onTranscript, onRecordingChange, disabled }: Props) {- const { isRecording, isTranscribing, sttSupported, startRecording, stopRecording } = useVoice()+ const { isRecording, isTranscribing, sttSupported, startRecording, stopRecording, recheckStt } = useVoice()++ useEffect(() => {+ // The startup probe (App.tsx) can run before the persistent Whisper server+ // has finished loading its model. If STT still reads unavailable when the+ // mic mounts, do one fresh probe so a late-ready server lights it up.+ if (!sttSupported) void recheckStt()+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [])const handleClick = async () => {if (disabled || isTranscribing) return@@ -37,7 +46,7 @@ export function VoiceButton({ onTranscript, onRecordingChange, disabled }: Props<MicOff size={14} /></button><div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-gray-800 dark:bg-gray-700 text-white text-[0.6rem] rounded whitespace-nowrap opacity-0 group-hover/mic:opacity-100 transition-opacity pointer-events-none">- Speech recognition not available+ Speech-to-text off — enable it in Settings → Voice & Remote</div></div>)diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex dfc51e4e..067429d7 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -1,5 +1,5 @@import { useState, useEffect, useRef, type ReactNode, type ChangeEvent } from 'react'-import { ArrowLeft, RotateCcw, Sun, Moon, Mic, Volume2, Check, X, Loader2, Shield, ChevronRight, GraduationCap, Lock, Sliders, Plug, Bot, Phone, User } from 'lucide-react'+import { ArrowLeft, RotateCcw, Sun, Moon, Volume2, Check, X, Loader2, Shield, ChevronRight, GraduationCap, Lock, Sliders, Plug, Bot, Phone, User } from 'lucide-react'import { motion, AnimatePresence } from 'framer-motion'import { useSettingsStore } from '../../stores/settingsStore'import { useUIStore } from '../../stores/uiStore'@@ -703,7 +703,12 @@ export function SettingsPage() {const refreshWhisper = () => {setWhisperLoading(true)return checkWhisperAvailable()- .then(setWhisperStatus)+ .then((s) => {+ setWhisperStatus(s)+ // Drive the mic button's availability from the same probe so it lights+ // up immediately after the in-app install — no restart needed.+ voiceSettings.setSttAvailable(!!s.available)+ }).finally(() => setWhisperLoading(false))}@@ -1085,7 +1090,6 @@ export function SettingsPage() {</div><SliderControl label="Rate" value={voiceSettings.ttsRate} min={0.5} max={2} step={0.1} onChange={(v) => voiceSettings.updateVoiceSettings({ ttsRate: v })} /><SliderControl label="Pitch" value={voiceSettings.ttsPitch} min={0.5} max={2} step={0.1} onChange={(v) => voiceSettings.updateVoiceSettings({ ttsPitch: v })} />- <InlineToggle label="Auto-send on Transcribe" enabled={voiceSettings.autoSendOnTranscribe} onChange={() => voiceSettings.updateVoiceSettings({ autoSendOnTranscribe: !voiceSettings.autoSendOnTranscribe })} icon={<Mic size={11} className="text-gray-500" />} /></Section><Section title="Remote Access">diff --git a/src/hooks/useVoice.ts b/src/hooks/useVoice.tsindex 01649a12..7e7d616d 100644--- a/src/hooks/useVoice.ts+++ b/src/hooks/useVoice.ts@@ -1,7 +1,7 @@import { useCallback, useRef } from "react";import { useVoiceStore } from "../stores/voiceStore";import {- isSpeechRecognitionSupported,+ recheckWhisperAvailable,isSpeechSynthesisSupported,speak,speakStreaming,@@ -17,9 +17,19 @@ export function useVoice() {const store = useVoiceStore();const recorderRef = useRef<AudioRecorder | null>(null);- const sttSupported = isSpeechRecognitionSupported();+ // Reactive: the source of truth is the store flag set by the startup probe+ // (App.tsx) and the in-app install (Settings). Reading a module-level boolean+ // here was the bug — it never re-rendered when Whisper came up.+ const sttSupported = store.sttAvailable;const ttsSupported = isSpeechSynthesisSupported();+ // Re-probe Whisper on demand (mic mount / after install) and sync the store.+ const recheckStt = useCallback(async (): Promise<boolean> => {+ const ok = await recheckWhisperAvailable();+ store.setSttAvailable(ok);+ return ok;+ }, [store]);+const startRecording = useCallback(async () => {if (recorderRef.current?.isRecording()) return;@@ -128,6 +138,7 @@ export function useVoice() {ttsSupported,startRecording,stopRecording,+ recheckStt,speakText,speakTextStreaming,stopSpeaking,diff --git a/src/stores/__tests__/sessionStores.test.ts b/src/stores/__tests__/sessionStores.test.tsindex e47cd6f7..0eff2fac 100644--- a/src/stores/__tests__/sessionStores.test.ts+++ b/src/stores/__tests__/sessionStores.test.ts@@ -139,12 +139,12 @@ describe('voiceStore', () => {isTranscribing: false,isSpeaking: false,transcript: '',+ sttAvailable: false,sttEnabled: true,ttsEnabled: false,ttsVoice: '',ttsRate: 1.0,ttsPitch: 1.0,- autoSendOnTranscribe: true,})})@@ -163,9 +163,14 @@ describe('voiceStore', () => {expect(useVoiceStore.getState().ttsPitch).toBe(0.8)})- it('can disable autoSendOnTranscribe', () => {- useVoiceStore.getState().updateVoiceSettings({ autoSendOnTranscribe: false })- expect(useVoiceStore.getState().autoSendOnTranscribe).toBe(false)+ })++ describe('setSttAvailable', () => {+ it('toggles transient STT availability', () => {+ useVoiceStore.getState().setSttAvailable(true)+ expect(useVoiceStore.getState().sttAvailable).toBe(true)+ useVoiceStore.getState().setSttAvailable(false)+ expect(useVoiceStore.getState().sttAvailable).toBe(false)})})diff --git a/src/stores/voiceStore.ts b/src/stores/voiceStore.tsindex c96e91fd..f7fbcfc6 100644--- a/src/stores/voiceStore.ts+++ b/src/stores/voiceStore.ts@@ -7,6 +7,11 @@ interface VoiceState {isTranscribing: boolean;isSpeaking: boolean;transcript: string;+ // Whether local Whisper STT is actually available. Probed at startup and+ // after the in-app install — transient (re-probed every launch) so a stale+ // "available" can never light up the mic on a machine where Whisper is gone,+ // and a fresh install lights it up without a restart.+ sttAvailable: boolean;// Persisted settingssttEnabled: boolean;@@ -14,13 +19,13 @@ interface VoiceState {ttsVoice: string;ttsRate: number;ttsPitch: number;- autoSendOnTranscribe: boolean;// ActionssetRecording: (recording: boolean) => void;setTranscribing: (transcribing: boolean) => void;setSpeaking: (speaking: boolean) => void;setTranscript: (transcript: string) => void;+ setSttAvailable: (available: boolean) => void;updateVoiceSettings: (settings: Partial<{sttEnabled: boolean;@@ -28,7 +33,6 @@ interface VoiceState {ttsVoice: string;ttsRate: number;ttsPitch: number;- autoSendOnTranscribe: boolean;}>) => void;resetTransient: () => void;@@ -42,6 +46,7 @@ export const useVoiceStore = create<VoiceState>()(isTranscribing: false,isSpeaking: false,transcript: "",+ sttAvailable: false,// Persisted settingssttEnabled: true,@@ -49,13 +54,13 @@ export const useVoiceStore = create<VoiceState>()(ttsVoice: "",ttsRate: 1.0,ttsPitch: 1.0,- autoSendOnTranscribe: true,// ActionssetRecording: (recording) => set({ isRecording: recording }),setTranscribing: (transcribing) => set({ isTranscribing: transcribing }),setSpeaking: (speaking) => set({ isSpeaking: speaking }),setTranscript: (transcript) => set({ transcript }),+ setSttAvailable: (available) => set({ sttAvailable: available }),updateVoiceSettings: (settings) => set((state) => ({ ...state, ...settings })),@@ -75,7 +80,6 @@ export const useVoiceStore = create<VoiceState>()(ttsVoice: state.ttsVoice,ttsRate: state.ttsRate,ttsPitch: state.ttsPitch,- autoSendOnTranscribe: state.autoSendOnTranscribe,}),})diff --git a/src/types/settings.ts b/src/types/settings.tsindex 872f69d3..782805af 100644--- a/src/types/settings.ts+++ b/src/types/settings.ts@@ -150,6 +150,6 @@ export interface Persona {isBuiltIn: boolean}-// Voice settings (sttEnabled, ttsEnabled, ttsVoice, ttsRate, ttsPitch,-// autoSendOnTranscribe) are managed in src/stores/voiceStore.ts via-// the dedicated Zustand voice store with persistence.+// Voice settings (sttEnabled, ttsEnabled, ttsVoice, ttsRate, ttsPitch) are+// managed in src/stores/voiceStore.ts via the dedicated Zustand voice store+// with persistence.