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

+26
View File
@@ -4,6 +4,7 @@ import { geminiSocketUrl } from './geminiSession.js';
import { createVoiceSession } from './session.js';
import { createPointerTracker } from './pointerContext.js';
import { withToolCatalog } from './gevRealtime.js';
import { setLocale, t } from '../i18n/index.js';
import {
harness,
tick,
@@ -3662,3 +3663,28 @@ test('a missing server key reaches the error state flagged, other token failures
assert.equal(h.sockets.length, 0);
}
});
test('an error keeps its English catalog text beside the worded detail', async (t2) => {
t2.after(() => setLocale('en'));
setLocale('es');
const h = harness({
fetchImpl: async () =>
Response.json(
{ error: 'Gemini quota is unavailable. Try again later.' },
{ status: 503 },
),
});
await h.c.start();
const error = h.events
.filter((event) => event.type === 'state' && event.state === 'error')
.at(-1);
assert.equal(
error.sourceDetail,
'Gemini quota is unavailable. Try again later.',
);
assert.equal(
error.detail,
t('Gemini quota is unavailable. Try again later.'),
);
assert.notEqual(error.detail, error.sourceDetail);
});