fix(voice): keyless Gemini voice drops the microphone hint

The Gemini token route now answers a missing key with code API_KEY_MISSING,
the session carries it to the error state as missingKey, and the voice
control hides "Check microphone permission" for that error, as it already
does for OpenAI. The OpenAI controller sends the same flag, so the shared
control and the controller agree whichever updates last.
This commit is contained in:
Sameh Khamis committed 2026-11-10 17:06:50 -08:00
1 parent 9560a6dcd1
commit b89f81b729
8 files changed
+74 -12

No files matched your search

+18 -8
View File
@@ -359,7 +359,11 @@ export class GeminiSessionController {
);
}
setStatus(status, detail, recovery) {
/**
* @param {{missingKey?: boolean}} [options] True when the server has no
* Gemini key: the control then drops its microphone hint.
*/
setStatus(status, detail, recovery, { missingKey = false } = {}) {
this.status = status;
if (status === 'listening' && this.input.pushToTalkMode)
detail = this.input.pushToTalkKeyHeld
@@ -371,6 +375,7 @@ export class GeminiSessionController {
detail: translateKnown(detail),
};
if (recovery) event.recovery = translateKnown(recovery);
if (missingKey) event.missingKey = true;
this.emit(event);
this.input.updateVoiceButtonLabel();
if (['idle', 'connecting', 'error'].includes(status))
@@ -584,12 +589,15 @@ export class GeminiSessionController {
const data = await readResponseJsonCapped(response, 256 * 1024, signal);
signal.throwIfAborted();
if (!response.ok)
throw new Error(
typeof data?.error === 'string'
? tokenErrorMessage(data.error)
: t('Gemini token request failed (HTTP {status})', {
status: response.status,
}),
throw Object.assign(
new Error(
typeof data?.error === 'string'
? tokenErrorMessage(data.error)
: t('Gemini token request failed (HTTP {status})', {
status: response.status,
}),
),
typeof data?.code === 'string' ? { code: data.code } : {},
);
if (
typeof data?.model !== 'string' ||
@@ -966,7 +974,9 @@ export class GeminiSessionController {
: error?.message || msg('Gemini voice could not start');
this.lastError = detail;
this.stop({ preserveStatus: true });
this.setStatus('error', detail, recovery);
this.setStatus('error', detail, recovery, {
missingKey: error?.code === 'API_KEY_MISSING',
});
}
abortTools() {