fix(voice): a missing-key error keeps its wording and hides the microphone hint after a language change (#1599)

The voice error was matched against the translated key message to decide
whether to show the microphone hint, so switching language brought the hint
back and left the message in the old language. The error now carries a
missing-key flag into the status, which words the message at render time.
A controller test covers the language switch, and CURRENT-STATE.md documents
the keyless voice response.
This commit is contained in:
Sameh Khamis committed 2026-11-10 16:11:30 -08:00
1 parent 0687e0e3da
commit f86b8954f6
4 files changed
+48 -6

No files matched your search

+30
View File
@@ -35,6 +35,7 @@ import {
} from './gevRealtime.js';
import { createVoiceCostTracker } from './voiceCost.js';
import { createTestVoiceUi } from '../testSupport/voiceUi.mjs';
import { setLocale } from '../i18n/index.js';
test('push-to-talk recognizes Space by code or key', () => {
assert.equal(PUSH_TO_TALK_HOLD_DELAY_MS, 500);
@@ -3734,3 +3735,32 @@ test('the controller forwards viewport escalation diagnostics to its debug log',
}],
);
});
test('a missing server key says where to add it, without the microphone hint, in every language', () => {
const ui = createTestVoiceUi();
const controller = new GevRealtimeController({
ui,
runner: async () => ({ ok: true }),
radioLayer: { subscribePlaybackControls: () => () => {}, setVoiceDucked() {} },
});
try {
controller.reportError(
'Realtime connection',
Object.assign(new Error('OPENAI_API_KEY is not set'), { code: 'API_KEY_MISSING' }),
);
assert.equal(ui.state.error.text, 'Needs OPENAI_API_KEY — add it in Provider Settings');
assert.equal(ui.state.error.hint, false);
setLocale('es');
assert.notEqual(ui.state.error.text, 'Needs OPENAI_API_KEY — add it in Provider Settings');
assert.match(ui.state.error.text, /OPENAI_API_KEY/);
assert.equal(ui.state.error.hint, false);
setLocale('en');
controller.reportError('Realtime connection', new Error('ICE failed'));
assert.match(ui.state.error.text, /ICE failed/);
assert.equal(ui.state.error.hint, true);
} finally {
setLocale('en');
}
});