From e2c4a5264c691dc528be8ae9ca668676da53c976 Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 14 Sep 2026 20:06:45 -0400 Subject: [PATCH] fix: check API key before starting recording Previously the API key was only validated after stopping the recording, wasting a full take if no key was configured. Now startRecording() checks the transcription provider's API key up front and aborts with a notice before touching the mic. --- main.ts | 4 ++++ src/transcription/AudioHandler.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 65210be..d821ad4 100644 --- a/main.ts +++ b/main.ts @@ -89,6 +89,10 @@ export default class NibbleAI extends Plugin { new Notice("Already recording"); return; } + if (!this.audioHandler.getTranscriptionApiKey()) { + new Notice("✘ Add your API key for the selected transcription provider in NibbleAI settings"); + return; + } try { await this.recorder.startRecording(); this.statusBar.updateStatus(RecordingStatus.Recording); diff --git a/src/transcription/AudioHandler.ts b/src/transcription/AudioHandler.ts index a6fbc48..4bcd70b 100644 --- a/src/transcription/AudioHandler.ts +++ b/src/transcription/AudioHandler.ts @@ -30,7 +30,7 @@ export class AudioHandler { } } - private getTranscriptionApiKey(): string { + getTranscriptionApiKey(): string { switch (this.plugin.settings.transcriptionProvider) { case "groq": return this.plugin.settings.groqApiKey;