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 <noreply@anthropic.com>
This commit is contained in:
Jinjing
2026-11-09 23:44:04 -08:00
co-authored by Claude
parent 4ad59d36a5
commit 6388ee67e2
3 changed files with 14 additions and 6 deletions
@@ -13,7 +13,11 @@ export function loadSpeechCatalog(): Promise<SpeechModelManifest[]> {
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
@@ -30,6 +30,9 @@ export function useDictationSpeechModelSetup(
async (voice: Pick<VoiceSettings, 'enabled' | 'sttModel'>): Promise<boolean> => {
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
},
@@ -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 => {