From 41555b6f1e42db12e3655874108cd45bba760098 Mon Sep 17 00:00:00 2001 From: jpmarques19 <30353669+jpmarques19@users.noreply.github.com> Date: Sat, 14 Mar 2026 16:15:23 +0000 Subject: [PATCH] fix(voice): check GROQ_API_KEY before entering voice mode (#367) --- src/resources/extensions/voice/index.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/resources/extensions/voice/index.ts b/src/resources/extensions/voice/index.ts index 555350e5c..3c5698fa1 100644 --- a/src/resources/extensions/voice/index.ts +++ b/src/resources/extensions/voice/index.ts @@ -44,6 +44,12 @@ let linuxReady = false; function ensureLinuxReady(ctx: ExtensionContext): boolean { if (linuxReady) return true; + // Check GROQ_API_KEY is available + if (!process.env.GROQ_API_KEY) { + ctx.ui.notify("Voice: GROQ_API_KEY not set — run 'gsd config' to configure", "error"); + return false; + } + // Check python3 exists try { execSync("which python3", { stdio: "pipe" }); @@ -211,21 +217,8 @@ export default function (pi: ExtensionAPI) { onReady: () => void, ) { if (IS_LINUX) { - // Pass GROQ_API_KEY to the Python process — check process.env, then .env file - const spawnEnv = { ...process.env }; - if (!spawnEnv.GROQ_API_KEY) { - try { - const envPath = path.join(process.cwd(), ".env"); - const envContent = fs.readFileSync(envPath, "utf-8"); - const match = envContent.match(/^GROQ_API_KEY=(.+)$/m); - if (match) spawnEnv.GROQ_API_KEY = match[1].trim(); - } catch { - // .env not found — Python script will emit ERROR if key needed - } - } recognizerProcess = spawn(linuxPython(), [PYTHON_SCRIPT], { stdio: ["pipe", "pipe", "pipe"], - env: spawnEnv, }); } else { recognizerProcess = spawn(RECOGNIZER_BIN, [], { stdio: ["pipe", "pipe", "pipe"] });