From 115d93482ac0cf7761bdec3e1ae4b09553d7db6d Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 8 Apr 2026 13:03:34 -0700 Subject: [PATCH] Always poll status after start/stop, even on API error When apiPost throws (e.g. 400 "Already transcribing"), pollStatus never ran because it was in the try block. The button stayed stuck on "Start" even though transcription was running. Moved pollStatus to the finally block so it always syncs the UI with actual backend state. Also suppresses the error message for 400 responses since they just mean the state is already correct. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/lib/components/Controls.svelte | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/components/Controls.svelte b/src/lib/components/Controls.svelte index 987ace0..296f465 100644 --- a/src/lib/components/Controls.svelte +++ b/src/lib/components/Controls.svelte @@ -20,14 +20,17 @@ } else { await backendStore.apiPost("/api/start"); } - // Poll status to update UI immediately instead of waiting - // for WebSocket broadcast (which can be delayed or missed) - await backendStore.pollStatus(); } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); - console.error("Failed to toggle transcription:", msg); - errorMessage = msg; + // Ignore "Already transcribing/not transcribing" -- just sync the state + if (!msg.includes("400")) { + console.error("Failed to toggle transcription:", msg); + errorMessage = msg; + } } finally { + // Always poll status to sync UI with actual backend state, + // even if the API call failed (e.g. "Already transcribing") + await backendStore.pollStatus(); isLoading = false; } }