Skip to content

Commit 4b1d397

Browse files
author
Peter Steinberger
committed
fix(google): bound realtime browser activation expiry
1 parent 71a5951 commit 4b1d397

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎extensions/google/realtime-voice-provider.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,32 @@ describe("buildGoogleRealtimeVoiceProvider", () => {
620620
]);
621621
});
622622

623+
it("returns browser expiry in the epoch milliseconds required by the Talk gateway", async () => {
624+
vi.useFakeTimers();
625+
const nowMs = Date.UTC(2026, 7, 1, 12, 34, 56, 789);
626+
vi.setSystemTime(nowMs);
627+
const provider = buildGoogleRealtimeVoiceProvider();
628+
629+
const sessionLocal = await provider.createBrowserSession?.({
630+
providerConfig: { apiKey: "gemini-key" },
631+
});
632+
633+
const tokenConfig = requireFirstMockArg(createTokenMock, "Google Live auth token config") as {
634+
config?: {
635+
expireTime?: string;
636+
newSessionExpireTime?: string;
637+
};
638+
};
639+
expect(tokenConfig.config?.expireTime).toBe(new Date(nowMs + 30 * 60 * 1000).toISOString());
640+
expect(tokenConfig.config?.newSessionExpireTime).toBe(
641+
new Date(nowMs + 60 * 1000).toISOString(),
642+
);
643+
expect(sessionLocal?.expiresAt).toBeGreaterThan(nowMs + 5_000);
644+
vi.advanceTimersByTime(60_001);
645+
expect(sessionLocal?.expiresAt).toBeLessThanOrEqual(Date.now() + 5_000);
646+
expect(sessionLocal?.expiresAt).toBe(nowMs + 60 * 1000);
647+
});
648+
623649
it("constrains default browser sessions to Gemini 3.1 capabilities", async () => {
624650
const provider = buildGoogleRealtimeVoiceProvider();
625651

‎extensions/google/realtime-voice-provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ async function createGoogleRealtimeBrowserSession(
11551155
initialMessage: buildBrowserInitialSetup(model),
11561156
model,
11571157
voice,
1158-
expiresAt: Math.floor(expiresAtMs / 1000),
1158+
expiresAt: newSessionExpiresAtMs,
11591159
};
11601160
}
11611161

0 commit comments

Comments
 (0)