Skip to content

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.

fix(voice): say which part of neural TTS is missing, not a guess

purplee222e6a5f5b1
diff --git a/src/api/__tests__/tts-status-detail.test.ts b/src/api/__tests__/tts-status-detail.test.ts
new file mode 100644
index 00000000..60696d8b
--- /dev/null
+++ b/src/api/__tests__/tts-status-detail.test.ts
@@ -0,0 +1,61 @@
+/**
+ * `tts_status` answers three different questions — is the piper package
+ * importable, is a complete voice on disk, and is the combination usable. The
+ * frontend collapsed all three into one boolean, so read-aloud's fallback
+ * notice told a user who had never installed Piper that Piper "is installed
+ * but not responding" — pointing them at a fault that did not exist.
+ *
+ * These lock the sub-flags surviving the probe, which is what the notice
+ * words itself from.
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+const backendCall = vi.fn()
+vi.mock('../backend', () => ({
+ backendCall: (...a: unknown[]) => backendCall(...a),
+ isTauri: () => true,
+}))
+
+import { initTtsCheck, recheckTtsAvailable, getLastTtsStatus } from '../voice'
+
+beforeEach(() => {
+ backendCall.mockReset()
+})
+
+describe('tts status detail', () => {
+ it('keeps "piper missing" distinguishable from "voice missing"', async () => {
+ backendCall.mockResolvedValueOnce({ available: false, piper: false, voice: false })
+ await recheckTtsAvailable('de_DE-thorsten-medium')
+ expect(getLastTtsStatus()).toMatchObject({ piper: false })
+
+ backendCall.mockResolvedValueOnce({ available: false, piper: true, voice: false })
+ await recheckTtsAvailable('de_DE-thorsten-medium')
+ const st = getLastTtsStatus()
+ expect(st.piper).toBe(true)
+ expect(st.voice).toBe(false)
+ })
+
+ it('reports the ready case as available with both sub-flags set', async () => {
+ backendCall.mockResolvedValueOnce({ available: true, piper: true, voice: true })
+ expect(await recheckTtsAvailable('de_DE-thorsten-medium')).toBe(true)
+ expect(getLastTtsStatus()).toEqual({ available: true, piper: true, voice: true })
+ })
+
+ it('falls back to "nothing known" when the probe throws', async () => {
+ // A thrown probe must not leave the previous run's sub-flags standing, or
+ // the notice would explain a state that is no longer being observed.
+ backendCall.mockResolvedValueOnce({ available: true, piper: true, voice: true })
+ await recheckTtsAvailable('a')
+ backendCall.mockRejectedValueOnce(new Error('backend gone'))
+ await recheckTtsAvailable('b')
+ expect(getLastTtsStatus()).toEqual({ available: false })
+ })
+
+ it('does not re-probe once a positive result is cached for the same voice', async () => {
+ backendCall.mockResolvedValue({ available: true, piper: true, voice: true })
+ await recheckTtsAvailable('same')
+ const callsAfterFirst = backendCall.mock.calls.length
+ await initTtsCheck('same')
+ expect(backendCall.mock.calls.length).toBe(callsAfterFirst)
+ })
+})
diff --git a/src/api/agents/error-hints.ts b/src/api/agents/error-hints.ts
index c5234a46..df9ba582 100644
--- a/src/api/agents/error-hints.ts
+++ b/src/api/agents/error-hints.ts
@@ -78,7 +78,11 @@ const TOOL_HINTS: Record<string, HintRule[]> = {
{ pattern: /no image models|not available|ComfyUI has no/i, hint: 'No image model installed. Surface to the user, they need to install one in Model Manager.' },
{ pattern: /timed out|timeout/i, hint: 'Generation timed out. Try a smaller resolution or simpler prompt.' },
{ pattern: /CUDA|out of memory|OOM/i, hint: 'GPU out of memory. Pick a lighter model or lower resolution.' },
- { pattern: /Generation failed/i, hint: 'ComfyUI returned an error. Surface the full error to the user; do not retry without changes.' },
+ // Do not name the engine here. This hint goes into the agent's context, and
+ // on a Mac the image backend is MLX — telling the model "ComfyUI returned
+ // an error" made it advise users to check software their machine has never
+ // had. The raw error the hint is appended to already names the real one.
+ { pattern: /Generation failed/i, hint: 'The image backend returned an error. Surface the full error to the user; do not retry without changes.' },
],
run_workflow: [
{ pattern: /not found/i, hint: 'Workflow name unknown. The error already lists available names, pick one.' },
diff --git a/src/api/voice.ts b/src/api/voice.ts
index b4d946f9..cab9fbf0 100644
--- a/src/api/voice.ts
+++ b/src/api/voice.ts
@@ -327,6 +327,15 @@ export async function synthesizeCloud(text: string, voice?: string, signal?: Abo
let ttsChecked = false;
let ttsAvailableFlag = false;
let ttsCheckedVoice: string | undefined;
+/** The last full probe, not just its boolean. `tts_status` distinguishes "the
+ * piper package is missing" from "no complete voice on disk"; collapsing that
+ * to one flag is what made read-aloud tell a user with no Piper at all that
+ * Piper "is installed but not responding". */
+let lastTtsStatus: { available: boolean; piper?: boolean; voice?: boolean } = { available: false };
+
+export function getLastTtsStatus(): { available: boolean; piper?: boolean; voice?: boolean } {
+ return lastTtsStatus;
+}
/** Probe neural TTS. Pass the SELECTED voice — readiness is per voice: having
* some other voice on disk says nothing about the one that is about to speak. */
@@ -351,8 +360,10 @@ export async function initTtsCheck(voice?: string): Promise<boolean> {
// must not vouch for the one the user switched to.
if (ttsChecked && ttsAvailableFlag && ttsCheckedVoice === voice) return ttsAvailableFlag;
try {
- ttsAvailableFlag = (await checkTtsAvailable(voice)).available;
+ lastTtsStatus = await checkTtsAvailable(voice);
+ ttsAvailableFlag = lastTtsStatus.available;
} catch {
+ lastTtsStatus = { available: false };
ttsAvailableFlag = false;
}
ttsChecked = ttsAvailableFlag;
diff --git a/src/components/models/ModelRecommendation.tsx b/src/components/models/ModelRecommendation.tsx
deleted file mode 100644
index 8548474c..00000000
--- a/src/components/models/ModelRecommendation.tsx
+++ /dev/null
@@ -1,201 +0,0 @@
-import { useState, useEffect } from 'react'
-import { motion, AnimatePresence } from 'framer-motion'
-import { Cpu, Download, X, Zap, Brain, Image, Video } from 'lucide-react'
-import { useModels } from '../../hooks/useModels'
-import { GlassCard } from '../ui/GlassCard'
-import { GlowButton } from '../ui/GlowButton'
-import { ProgressBar } from '../ui/ProgressBar'
-
-interface SystemInfo {
- vram: number | null
- ram: number | null
- gpu: string | null
-}
-
-interface Recommendation {
- name: string
- pullName: string
- description: string
- vramNeeded: string
- category: 'text' | 'image' | 'video'
- icon: typeof Brain
-}
-
-function getRecommendations(sys: SystemInfo): Recommendation[] {
- const vram = sys.vram || 0
- const recs: Recommendation[] = []
-
- // Text models
- if (vram >= 10) {
- recs.push({
- name: 'Mistral Nemo 12B (Unfiltered)',
- pullName: 'krith/mistral-nemo-instruct-2407-abliterated:IQ4_XS',
- description: 'Very smart, unfiltered, fits your GPU',
- vramNeeded: '~7 GB VRAM',
- category: 'text',
- icon: Brain,
- })
- }
- if (vram >= 6) {
- recs.push({
- name: 'Llama 3.1 8B (Unfiltered)',
- pullName: 'mannix/llama3.1-8b-abliterated:q5_K_M',
- description: 'Fast & unfiltered, ideal to get started',
- vramNeeded: '~5.5 GB VRAM',
- category: 'text',
- icon: Zap,
- })
- }
- if (vram >= 8) {
- recs.push({
- name: 'DeepSeek R1 8B (Unfiltered)',
- pullName: 'huihui_ai/deepseek-r1-abliterated:8b',
- description: 'Thinks before it answers, unfiltered',
- vramNeeded: '~6 GB VRAM',
- category: 'text',
- icon: Brain,
- })
- }
-
- // Image models (ComfyUI)
- if (vram >= 8) {
- recs.push({
- name: 'SDXL / Juggernaut XL',
- pullName: '',
- description: 'Photorealistic, unfiltered. Install in ComfyUI.',
- vramNeeded: '~8 GB VRAM',
- category: 'image',
- icon: Image,
- })
- }
-
- // Video models
- if (vram >= 10) {
- recs.push({
- name: 'Wan2.2 1.3B (Video)',
- pullName: '',
- description: 'Text-to-Video, 480p. Install in ComfyUI.',
- vramNeeded: '~8-10 GB VRAM',
- category: 'video',
- icon: Video,
- })
- }
-
- return recs
-}
-
-export function ModelRecommendation() {
- const { models, pullModel, isPulling, pullProgress } = useModels()
- const [dismissed, setDismissed] = useState(false)
- const [systemInfo, setSystemInfo] = useState<SystemInfo>({ vram: null, ram: null, gpu: null })
- const [loading, setLoading] = useState(true)
-
- // Check if we should show this at all
- const hasTextModels = models.some((m) => m.type === 'text')
-
- useEffect(() => {
- // Try to detect system info via Ollama's ps endpoint
- async function detectSystem() {
- try {
- // We'll use a simple heuristic based on known GPU info
- // Since we can't directly query GPU from browser, use stored info or defaults
- const stored = localStorage.getItem('system-info')
- if (stored) {
- setSystemInfo(JSON.parse(stored))
- } else {
- // Default: assume 8GB VRAM (most common consumer GPU)
- const info: SystemInfo = { vram: 8, ram: 16, gpu: null }
- setSystemInfo(info)
- }
- } catch {
- setSystemInfo({ vram: 8, ram: 16, gpu: null })
- }
- setLoading(false)
- }
- detectSystem()
- }, [])
-
- if (loading || dismissed || hasTextModels) return null
-
- const recommendations = getRecommendations(systemInfo)
- const textRecs = recommendations.filter((r) => r.category === 'text')
-
- const progress = pullProgress?.total && pullProgress?.completed
- ? (pullProgress.completed / pullProgress.total) * 100
- : 0
-
- return (
- <AnimatePresence>
- <motion.div
- initial={{ opacity: 0, y: 20 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -20 }}
- className="max-w-2xl mx-auto p-6"
- >
- <GlassCard className="p-6 relative">
- <button
- onClick={() => setDismissed(true)}
- className="absolute top-3 right-3 p-1 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/10 transition-colors"
- >
- <X size={16} />
- </button>
-
- <div className="flex items-center gap-3 mb-4">
- <div className="w-10 h-10 rounded-xl bg-blue-500/10 flex items-center justify-center">
- <Cpu size={20} className="text-blue-400" />
- </div>
- <div>
- <h2 className="text-lg font-bold text-gray-900 dark:text-white">Welcome to LU</h2>
- <p className="text-sm text-gray-500">
- {systemInfo.gpu ? `${systemInfo.gpu} (${systemInfo.vram} GB VRAM)` : 'No model installed. Here are some recommendations:'}
- </p>
- </div>
- </div>
-
- {isPulling && pullProgress && (
- <div className="mb-4 p-3 rounded-lg bg-gray-100 dark:bg-white/5">
- <p className="text-sm text-gray-600 dark:text-gray-300 mb-2">{pullProgress.status}</p>
- {pullProgress.total && pullProgress.completed !== undefined && (
- <ProgressBar progress={progress} />
- )}
- </div>
- )}
-
- <div className="space-y-3">
- <h3 className="text-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Recommended Text Models</h3>
- {textRecs.map((rec) => {
- const Icon = rec.icon
- return (
- <div
- key={rec.pullName}
- className="flex items-center gap-3 p-3 rounded-lg bg-gray-50 dark:bg-white/5 hover:bg-gray-100 dark:hover:bg-white/8 transition-colors"
- >
- <div className="w-8 h-8 rounded-lg bg-blue-500/10 flex items-center justify-center shrink-0">
- <Icon size={16} className="text-blue-400" />
- </div>
- <div className="flex-1 min-w-0">
- <p className="text-sm font-medium text-gray-900 dark:text-white">{rec.name}</p>
- <p className="text-xs text-gray-500">{rec.description}. {rec.vramNeeded}</p>
- </div>
- {rec.pullName && (
- <GlowButton
- onClick={() => pullModel(rec.pullName)}
- disabled={isPulling}
- className="shrink-0 flex items-center gap-1 text-xs"
- >
- <Download size={14} /> Install
- </GlowButton>
- )}
- </div>
- )
- })}
- </div>
-
- <p className="text-xs text-gray-500 mt-4 text-center">
- You can install more models in the Model Manager anytime.
- </p>
- </GlassCard>
- </motion.div>
- </AnimatePresence>
- )
-}
diff --git a/src/hooks/useVoice.ts b/src/hooks/useVoice.ts
index fc139dce..b214599a 100644
--- a/src/hooks/useVoice.ts
+++ b/src/hooks/useVoice.ts
@@ -19,6 +19,7 @@ import {
createAudioRecorder,
transcribeAudio,
transcribeAudioCloud,
+ getLastTtsStatus,
type AudioRecorder,
} from "../api/voice";
import { CloudJobError } from "../api/cloud/client";
@@ -370,8 +371,17 @@ export function useVoice() {
);
}
} else if (store.ttsMode !== "external") {
+ // Say which of the three things is actually missing. The old text
+ // asserted "installed but not responding" for all of them, so a
+ // user who had never set Piper up was sent looking for a fault
+ // that did not exist.
+ const st = getLastTtsStatus();
store.setTtsFallbackReason(
- "Piper is installed but not responding, so read-aloud used the system voice instead.",
+ st.piper === false
+ ? "Neural TTS (Piper) is not set up yet, so read-aloud used the system voice. Install it in Settings → Voice."
+ : st.voice === false
+ ? "No Piper voice is fully downloaded yet, so read-aloud used the system voice. Pick one in Settings → Voice."
+ : "Piper is installed but not responding, so read-aloud used the system voice instead.",
);
}
}