From 6388ee67e239f7a8b61525a3c2fa16b3e024fa63 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:44:04 -0800 Subject: [PATCH] fix(dictation): address review on the setup pill check - Drop a stale press before opening the setup pill, not only before recording. - Swallow cancelDownload rejections. - Don't cache a failed catalog load, and don't mark a model up to date from an empty catalog. Co-Authored-By: Claude --- .../components/dictation/speech-model-update-check.ts | 9 +++++++-- .../dictation/use-dictation-speech-model-setup.ts | 6 +++--- .../dictation/use-speech-model-update-download.ts | 5 ++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/components/dictation/speech-model-update-check.ts b/src/renderer/src/components/dictation/speech-model-update-check.ts index c847061edca..8f11c721f80 100644 --- a/src/renderer/src/components/dictation/speech-model-update-check.ts +++ b/src/renderer/src/components/dictation/speech-model-update-check.ts @@ -13,7 +13,11 @@ export function loadSpeechCatalog(): Promise { catalogRequest ??= Promise.resolve() // The paired web client's fallback resolves with nothing rather than a list. .then(async () => (await window.api.speech.getCatalog()) ?? []) - .catch(() => []) + .catch(() => { + // Not cached, so the next press asks again. + catalogRequest = null + return [] + }) return catalogRequest } @@ -35,7 +39,8 @@ export async function checkSpeechModelUpdate( ]) useAppStore.getState().setModelStates(states) const target = findSpeechModelUpdateTarget(voice, catalog, states) - if (!target) { + // An empty catalog proves nothing, so it isn't remembered as up to date. + if (!target && catalog.length > 0) { upToDateModelIds.add(voice.sttModel) } return target diff --git a/src/renderer/src/components/dictation/use-dictation-speech-model-setup.ts b/src/renderer/src/components/dictation/use-dictation-speech-model-setup.ts index d6c3affc3aa..6206e75287b 100644 --- a/src/renderer/src/components/dictation/use-dictation-speech-model-setup.ts +++ b/src/renderer/src/components/dictation/use-dictation-speech-model-setup.ts @@ -30,6 +30,9 @@ export function useDictationSpeechModelSetup( async (voice: Pick): Promise => { const request = ++startRequestRef.current const target = await checkSpeechModelUpdate(voice) + if (request !== startRequestRef.current) { + return false + } if (target) { if (isIdle()) { setPillAnchor(dictationPillAnchorFor(captureInsertionTarget())) @@ -37,9 +40,6 @@ export function useDictationSpeechModelSetup( } return false } - if (request !== startRequestRef.current) { - return false - } setSetupTarget(null) return true }, diff --git a/src/renderer/src/components/dictation/use-speech-model-update-download.ts b/src/renderer/src/components/dictation/use-speech-model-update-download.ts index 7816689c596..4241dc18d1d 100644 --- a/src/renderer/src/components/dictation/use-speech-model-update-download.ts +++ b/src/renderer/src/components/dictation/use-speech-model-update-download.ts @@ -53,7 +53,10 @@ export function useSpeechModelUpdateDownload( } const cancel = (): void => { - void window.api.speech.cancelDownload(model.id).finally(() => void refreshModelStates()) + void window.api.speech + .cancelDownload(model.id) + .catch(() => undefined) + .finally(() => void refreshModelStates()) } const deleteRetired = (): void => {