diff --git a/apps/desktop/src/app/settings/voice-provider-fields.tsx b/apps/desktop/src/app/settings/voice-provider-fields.tsx index c03d6d12e8..b20c45cf1b 100644 --- a/apps/desktop/src/app/settings/voice-provider-fields.tsx +++ b/apps/desktop/src/app/settings/voice-provider-fields.tsx @@ -1,7 +1,13 @@ import { useQuery } from '@tanstack/react-query' import { useEffect, useMemo, useRef, useState } from 'react' -import { getElevenLabsVoices, getHermesConfigSchema, type ProfileScope, saveHermesConfigRecord } from '@/hermes' +import { + getElevenLabsVoices, + getHermesConfigSchema, + type ProfileScope, + profileScopeKey, + saveHermesConfigRecord +} from '@/hermes' import { useI18n } from '@/i18n' import { notifyError } from '@/store/notifications' import type { HermesConfigRecord } from '@/types/hermes' @@ -48,7 +54,13 @@ export function VoiceProviderFields({ const { t } = useI18n() const keys = useMemo(() => voiceProviderKeys(section, providerKey), [section, providerKey]) const { data: loadedConfig } = useHermesConfigRecord(profile) - const writeConfigCache = useMemo(() => hermesConfigCacheWriter(profile), [profile]) + // Parents pass `profile` as a fresh object literal each render; keying the + // writer and the autosave effect on its identity would re-arm the 550ms + // timer on every unrelated re-render. Key on the scope string instead + // (null when unscoped, which maps to the bare cache row). + const scopeKey = profile == null ? null : profileScopeKey(profile) + // eslint-disable-next-line react-hooks/exhaustive-deps -- scopeKey is the identity of `profile` + const writeConfigCache = useMemo(() => hermesConfigCacheWriter(profile), [scopeKey]) const { data: schemaResponse } = useQuery({ queryKey: ['hermes-config-schema'], @@ -94,8 +106,8 @@ export function VoiceProviderFields({ }, 550) return () => window.clearTimeout(timeout) - // eslint-disable-next-line react-hooks/exhaustive-deps -- copy is stable; avoid re-scheduling autosave on locale change - }, [config, profile, saveVersion, writeConfigCache]) + // eslint-disable-next-line react-hooks/exhaustive-deps -- copy is stable; `profile` is keyed by scopeKey; avoid re-scheduling autosave on locale change + }, [config, scopeKey, saveVersion, writeConfigCache]) // ElevenLabs cloned/library voices from the live account, when available — // mirrors the Settings → Voice dynamic voice list.