The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(voice): prevent crash when voice panel opens without audio devices
Steven Enamakelc60529f930ff
diff --git a/app/src/components/settings/panels/VoicePanel.tsx b/app/src/components/settings/panels/VoicePanel.tsxindex fad5d309fd..925cbb164e 100644--- a/app/src/components/settings/panels/VoicePanel.tsx+++ b/app/src/components/settings/panels/VoicePanel.tsx@@ -5,11 +5,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';import { cn } from '../../../lib/cn';import { useT } from '../../../lib/i18n/I18nContext';import PttSettingsPanel from '../../../pages/settings/voice/PttSettingsPanel';-import {- installPiper,- piperInstallStatus,- type VoiceInstallStatus,-} from '../../../services/api/voiceInstallApi';import {clearVoiceProviderKey,loadVoiceSettings,@@ -53,7 +48,6 @@ const PIPER_VOICE_PRESET_IDS = ['en_GB-northern_english_male-medium',] as const;-const LOCAL_INSTALL_STATUS_POLL_MS = 2_000;const log = debug('voice:settings');interface VoicePanelProps {@@ -81,8 +75,7 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {const [ttsVoice, setTtsVoice] = useState<string>('');const [elevenlabsVoiceId, setElevenlabsVoiceId] = useState<string>('JBFqnCBsd6RMkjVDRZzb');const [isSavingProviders, setIsSavingProviders] = useState(false);- const [piperInstall, setPiperInstall] = useState<VoiceInstallStatus | null>(null);- const [isInstallingPiper, setIsInstallingPiper] = useState(false);+ const [isCheckingPiper, setIsCheckingPiper] = useState(false);const [, setIsLoading] = useState(true);const [error, setError] = useState<string | null>(null);const [notice, setNotice] = useState<string | null>(null);@@ -118,18 +111,10 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {const loadData = async (forceSettings = false) => {try {- const [settingsResponse, voiceResponse, piperStatusResponse] = await Promise.all([+ const [settingsResponse, voiceResponse] = await Promise.all([openhumanGetVoiceServerSettings(),openhumanVoiceStatus(),- piperInstallStatus().catch(err => {- // Status polls happen on a 2s loop; a single transient error- // shouldn't blow up the entire settings panel. Log + keep the- // previous snapshot.- log('[voice-install:piper] status poll failed %o', err);- return null;- }),]);- if (piperStatusResponse) setPiperInstall(piperStatusResponse);const currentSettings = settingsRef.current;const currentSavedSettings = savedSettingsRef.current;if (@@ -207,40 +192,6 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {void loadData(true);}, []);- const shouldPollPiperInstall = piperInstall?.state === 'installing';-- useEffect(() => {- if (!shouldPollPiperInstall) return;-- let cancelled = false;- let inFlight = false;- const pollInstallStatus = async () => {- if (inFlight) return;- inFlight = true;- try {- const nextPiperStatus = await piperInstallStatus().catch(err => {- log('[voice-install:piper] status poll failed %o', err);- return null;- });-- if (cancelled) return;- if (nextPiperStatus) setPiperInstall(nextPiperStatus);- } finally {- inFlight = false;- }- };-- void pollInstallStatus();- const intervalId = window.setInterval(() => {- void pollInstallStatus();- }, LOCAL_INSTALL_STATUS_POLL_MS);-- return () => {- cancelled = true;- window.clearInterval(intervalId);- };- }, [shouldPollPiperInstall]);-const persistProviders = async (update: Partial<VoiceProvidersSnapshot> & {stt_provider?: string;@@ -428,39 +379,30 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {// gender, and locale-default toggle all live in `mascotSlice`; this// panel only handles Piper / dictation now.- const handleInstallPiper = async () => {- setIsInstallingPiper(true);++ // Piper is user-supplied: OpenHuman never downloads the binary or its+ // voices. Readiness is whatever `voice_status` resolves — a `piper` binary+ // (PATH or PIPER_BIN) plus the selected voice's .onnx file. After the user+ // installs Piper themselves, "Check again" re-reads that status.+ const handleRecheckPiper = async () => {+ setIsCheckingPiper(true);setError(null);setNotice(null);+ log('[voice:piper] re-checking user-supplied piper binary and voice');try {- const force = piperInstall?.state === 'installed';- log('[voice-install:piper] install click force=%s', force);- const result = await installPiper({ voiceId: ttsVoice || undefined, force });- setPiperInstall(result);- setNotice(- result.state === 'installed'- ? t('voice.providers.piperReady')- : `${t('voice.providers.piperInstallStarted')} (${result.stage ?? t('voice.providers.queued')})`- );- } catch (err) {- const message =- err instanceof Error ? err.message : t('voice.providers.failedToInstallPiper');- setError(message);- } finally {- setIsInstallingPiper(false);await loadData(false);+ } finally {+ setIsCheckingPiper(false);}};- const piperReady =- piperInstall?.state !== 'installing' &&- (piperInstall?.state === 'installed' || Boolean(voiceStatus?.tts_available));+ const piperReady = Boolean(voiceStatus?.tts_available);const pendingLocalProviderReady = pendingKeySlug === 'piper' ? piperReady : true;- // Piper must finish downloading before its Test button does anything useful- // — exercising an un-installed engine just errors out on a missing binary or- // voice file. STT has no local artifact at all now (every engine is a hosted- // HTTP call), so its Test button is never gated on an install.+ // Piper's Test button is useless until the user-supplied binary and voice+ // file resolve — exercising it just errors out on a missing binary or voice+ // file. STT has no local artifact at all (every engine is a hosted HTTP+ // call), so its Test button is never gated.const ttsTestBlockedByInstall = ttsProvider === 'piper' && !piperReady;return (@@ -511,8 +453,6 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {onSttProviderChange={onSttProviderChange}onTtsProviderChange={onTtsProviderChange}voiceSettings={voiceSettings}- isInstallingPiper={isInstallingPiper}- piperInstall={piperInstall}isSavingPendingKey={isSavingPendingKey}setPendingKeySlug={setPendingKeySlug}setPendingKeyValue={setPendingKeyValue}@@ -533,9 +473,8 @@ const VoicePanel = ({ embedded = false, scrollable = true }: VoicePanelProps = {setTtsVoice={setTtsVoice}piperVoicePresets={piperVoicePresets}piperVoicePresetIds={PIPER_VOICE_PRESET_IDS}- piperInstall={piperInstall}- isInstallingPiper={isInstallingPiper}- handleInstallPiper={handleInstallPiper}+ isCheckingPiper={isCheckingPiper}+ handleRecheckPiper={handleRecheckPiper}piperReady={piperReady}pendingLocalProviderReady={pendingLocalProviderReady}isSavingProviders={isSavingProviders}