fix(voice): Gemini voice messages follow a language change

The Gemini session translated each status and error message once, when it
happened, so after a language change the voice control kept showing it in
the old language. The state event now also carries the English catalog text
as sourceDetail, and the control words it when shown. The local server's
known token errors stay catalog text until then instead of being translated
on arrival.
This commit is contained in:
Sameh Khamis committed 2026-11-10 18:04:52 -08:00
1 parent 962f7293c6
commit b1c5de0ed1
5 files changed
+77 -8

No files matched your search

+31
View File
@@ -11,6 +11,7 @@ import { createGevActionRunner } from './gevActions.js';
import { createPointerTracker } from './pointerContext.js';
import { createReferentRegistry } from './referents.js';
import { createTestVoiceUi } from '../testSupport/voiceUi.mjs';
import { setLocale, t } from '../i18n/index.js';
const PROVIDER_KEY = 'gev.voice.provider';
const settle = () => new Promise((resolve) => setImmediate(resolve));
@@ -897,3 +898,33 @@ test('a missing-key error hides the microphone hint; other errors keep it', asyn
assert.equal(ui.state.error.text, 'Socket closed');
assert.equal(ui.state.error.hint, true);
});
test('a provider message is worded again after a language change', async (t2) => {
t2.after(() => setLocale('en'));
const f = compositionFixture(t2, {});
f.select('gemini');
await settle();
const instance = f.instances.at(-1);
const ui = f.views.at(-1);
const quota = 'Gemini quota is unavailable. Try again later.';
instance.hooks.emit({
type: 'state',
state: 'error',
detail: quota,
sourceDetail: quota,
});
assert.equal(ui.state.error.text, quota);
setLocale('es');
assert.equal(ui.state.error.text, t(quota));
assert.notEqual(ui.state.error.text, quota);
setLocale('en');
instance.hooks.emit({
type: 'state',
state: 'listening',
detail: 'Ask or command',
sourceDetail: 'Ask or command',
});
setLocale('es');
assert.equal(ui.state.detail.text, t('Ask or command'));
assert.notEqual(ui.state.detail.text, 'Ask or command');
});