From 426f8e0a07e4ab7ab03112960e7557ad0a2466a3 Mon Sep 17 00:00:00 2001 From: Douwe Osinga Date: Tue, 10 Feb 2026 23:32:20 +0100 Subject: [PATCH] Inline worklet source (#7128) Co-authored-by: Douwe Osinga --- Justfile | 10 ++++++++++ crates/goose/src/dictation/providers.rs | 2 ++ ui/desktop/{src => public}/audio-capture-worklet.js | 0 ui/desktop/src/hooks/useAudioRecorder.ts | 5 +++-- 4 files changed, 15 insertions(+), 2 deletions(-) rename ui/desktop/{src => public}/audio-capture-worklet.js (100%) diff --git a/Justfile b/Justfile index e723cbc0..b1394683 100644 --- a/Justfile +++ b/Justfile @@ -162,6 +162,16 @@ debug-ui-main-process: npm install && \ npm run start-gui-debug +# Package the desktop app locally for testing (macOS) +# Applies ad-hoc code signing with entitlements (needed for mic access, etc.) +package-ui: + @just release-binary + @echo "Packaging desktop app..." + cd ui/desktop && npm install && npm run package + @echo "Signing with entitlements..." + codesign --force --deep --sign - --entitlements ui/desktop/entitlements.plist ui/desktop/out/Goose-darwin-arm64/Goose.app + @echo "Done! Launch with: open ui/desktop/out/Goose-darwin-arm64/Goose.app" + # Run UI with alpha changes run-ui-alpha: @just release-binary diff --git a/crates/goose/src/dictation/providers.rs b/crates/goose/src/dictation/providers.rs index 356c1f61..37d86410 100644 --- a/crates/goose/src/dictation/providers.rs +++ b/crates/goose/src/dictation/providers.rs @@ -222,6 +222,8 @@ pub async fn transcribe_with_provider( anyhow::bail!("Invalid API key"); } else if status == 429 || error_text.contains("quota") { anyhow::bail!("Rate limit exceeded"); + } else if error_text.contains("too short") { + return Ok(String::new()); } else { anyhow::bail!("API error: {}", error_text); } diff --git a/ui/desktop/src/audio-capture-worklet.js b/ui/desktop/public/audio-capture-worklet.js similarity index 100% rename from ui/desktop/src/audio-capture-worklet.js rename to ui/desktop/public/audio-capture-worklet.js diff --git a/ui/desktop/src/hooks/useAudioRecorder.ts b/ui/desktop/src/hooks/useAudioRecorder.ts index ef218e06..5e53cac1 100644 --- a/ui/desktop/src/hooks/useAudioRecorder.ts +++ b/ui/desktop/src/hooks/useAudioRecorder.ts @@ -16,8 +16,9 @@ const MIN_SPEECH_MS = 200; // without clipping early speech onsets. Determined empirically for 16kHz mono input. const RMS_THRESHOLD = 0.015; -// Import the worklet module - Vite will handle this correctly -const WORKLET_URL = new URL('../audio-capture-worklet.js', import.meta.url).href; +// Resolve worklet URL at runtime from window.location so it works under both +// the dev server (http://localhost) and packaged builds (file://). +const WORKLET_URL = new URL('audio-capture-worklet.js', window.location.href.split('#')[0]).href; function encodeWav(samples: Float32Array, sampleRate: number): ArrayBuffer { const buf = new ArrayBuffer(44 + samples.length * 2);