The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: keep desktop voice choice when storage is full
Tekniumdc51977799c8
diff --git a/apps/desktop/src/store/voice-prefs.test.ts b/apps/desktop/src/store/voice-prefs.test.tsindex 76227f2dc58..60be68c1615 100644--- a/apps/desktop/src/store/voice-prefs.test.ts+++ b/apps/desktop/src/store/voice-prefs.test.ts@@ -7,28 +7,53 @@ vi.mock('@/hermes', () => ({import { saveHermesConfig } from '@/hermes'-import { $autoSpeakReplies, $voiceStopPhrase, applyAutoSpeakFromConfig, applyVoiceStopPhraseFromConfig, setAutoSpeakReplies } from './voice-prefs'+import { $voiceStopPhrase, applyVoiceStopPhraseFromConfig } from './voice-prefs'it('keeps the desktop toggle local across config refreshes', async () => {- localStorage.clear()- $autoSpeakReplies.set(false)- vi.mocked(saveHermesConfig).mockClear()- await setAutoSpeakReplies(true)- applyAutoSpeakFromConfig({ voice: { auto_tts: false } })- expect($autoSpeakReplies.get()).toBe(true)- expect(saveHermesConfig).not.toHaveBeenCalled()- expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBe('true')+ for (const fails of [false, true]) {+ for (const enabled of [false, true]) {+ localStorage.clear()+ vi.resetModules()+ const prefs = await import('./voice-prefs')+ const write = vi.spyOn(localStorage, 'setItem')++ if (fails) {write.mockImplementation(() => { throw new DOMException('Full', 'QuotaExceededError') })}+ vi.mocked(saveHermesConfig).mockClear()++ try {+ await prefs.setAutoSpeakReplies(enabled)+ prefs.applyAutoSpeakFromConfig({ voice: { auto_tts: !enabled } })+ expect(prefs.$autoSpeakReplies.get()).toBe(enabled)+ expect(saveHermesConfig).not.toHaveBeenCalled()+ expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBe(fails ? null : String(enabled))+ } finally {+ write.mockRestore()+ }+ }+ }})-it('migrates the legacy preference once, not on every refresh', () => {- for (const enabled of [false, true]) {- localStorage.clear()- applyAutoSpeakFromConfig(null)- expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBeNull()- applyAutoSpeakFromConfig({ voice: { auto_tts: enabled } })- applyAutoSpeakFromConfig({ voice: { auto_tts: !enabled } })- expect($autoSpeakReplies.get()).toBe(enabled)- expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBe(String(enabled))+it('migrates the legacy preference once, not on every refresh', async () => {+ for (const fails of [false, true]) {+ for (const enabled of [false, true]) {+ localStorage.clear()+ vi.resetModules()+ const prefs = await import('./voice-prefs')+ const write = vi.spyOn(localStorage, 'setItem')++ if (fails) {write.mockImplementation(() => { throw new DOMException('Denied', 'SecurityError') })}++ try {+ prefs.applyAutoSpeakFromConfig(null)+ expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBeNull()+ prefs.applyAutoSpeakFromConfig({ voice: { auto_tts: enabled } })+ prefs.applyAutoSpeakFromConfig({ voice: { auto_tts: !enabled } })+ expect(prefs.$autoSpeakReplies.get()).toBe(enabled)+ expect(localStorage.getItem('hermes.desktop.autoSpeakReplies')).toBe(fails ? null : String(enabled))+ } finally {+ write.mockRestore()+ }+ }}})diff --git a/apps/desktop/src/store/voice-prefs.ts b/apps/desktop/src/store/voice-prefs.tsindex fdb13873ec0..00a412c4b69 100644--- a/apps/desktop/src/store/voice-prefs.ts+++ b/apps/desktop/src/store/voice-prefs.ts@@ -5,10 +5,12 @@ import { persistBoolean, readKey, storedBoolean } from '@/lib/storage'// Desktop read-aloud is local; voice.auto_tts belongs to the messaging gateway.const AUTO_SPEAK_KEY = 'hermes.desktop.autoSpeakReplies'export const $autoSpeakReplies = atom<boolean>(storedBoolean(AUTO_SPEAK_KEY, false))+// Best-effort persistence must not give config refresh authority again.+let autoSpeakChosen = readKey(AUTO_SPEAK_KEY) !== null/** Migrate the legacy value once without editing the backend configuration. */export function applyAutoSpeakFromConfig(config: { voice?: { auto_tts?: unknown } | null } | null | undefined) {- if (config != null && readKey(AUTO_SPEAK_KEY) === null) {+ if (config != null && !autoSpeakChosen) {void setAutoSpeakReplies(Boolean(config.voice?.auto_tts))}}@@ -51,6 +53,7 @@ export function applyThinkingSoundFromConfig(/** Persist even an unchanged value, so migrating false is also one-time. */export async function setAutoSpeakReplies(enabled: boolean): Promise<void> {+ autoSpeakChosen = truepersistBoolean(AUTO_SPEAK_KEY, enabled)$autoSpeakReplies.set(enabled)}diff --git a/website/docs/user-guide/features/tts.md b/website/docs/user-guide/features/tts.mdindex 7261b27e504..8cabbb842f8 100644--- a/website/docs/user-guide/features/tts.md+++ b/website/docs/user-guide/features/tts.md@@ -260,7 +260,7 @@ tts:Local engines (Piper, KittenTTS) load their model lazily, so without help the *first* spoken reply after you turn speech on pays the whole model load — and on a fresh install the voice download — as silence before the first word. Hermes treats the speech-output toggles as the signal that TTS is about to be needed:-- **Desktop** — **Read replies aloud** is a desktop-local preference, independent of the gateway's `voice.auto_tts` setting in Settings → Voice. It migrates the shared value once, then later gateway configuration changes do not override the desktop toggle. Turning on **Read replies aloud**, or starting a **voice conversation**, pre-loads the configured engine in the background right away. Turning both off again unloads the resident model (a Piper voice is tens of MB; KittenTTS up to ~80MB) so it isn't parked in RAM for nothing.+- **Desktop** — **Read replies aloud** is a desktop-local preference, independent of the gateway's `voice.auto_tts` setting in Settings → Voice. It migrates the shared value once, then later gateway configuration changes do not override the desktop toggle. If local storage is full or unavailable, the choice still lasts for this window; persistence across a reload remains best-effort. Turning on **Read replies aloud**, or starting a **voice conversation**, pre-loads the configured engine in the background right away. Turning both off again unloads the resident model (a Piper voice is tens of MB; KittenTTS up to ~80MB) so it isn't parked in RAM for nothing.- **CLI / TUI** — `/voice tts` (and `/voice on` when `voice.auto_tts` is set) do the same; `/voice off` releases.Each toggle holds a *lease* on the engine; the model is only unloaded when the last lease across surfaces is released, so switching off read-aloud in one Desktop window never pulls the voice out from under a conversation running in another. For cloud providers there is no model to hold — the toggle only makes sure a lazily-installed SDK (edge-tts, ElevenLabs, Mistral) is present. Warm-up is best-effort: if the engine can't load, the toggle still succeeds and the first reply falls back to loading on demand as before.