Skip to content

Commit 5d07c11

Browse files
authored
fix(talk): initialize browser voice for OpenAI login (#133048)
1 parent 1e2408c commit 5d07c11

5 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎docs/providers/openai.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ value into `plugins.entries.openai.config.personality` when that key is unset.
10151015
ChatGPT OAuth profile created by
10161016
`openclaw models auth login --provider openai`.
10171017

1018+
The enabled OpenAI plugin starts its browser session broker automatically,
1019+
including when you sign in after the Gateway has started. No separate Talk
1020+
provider configuration or Platform API key is required for this browser
1021+
path. The broker opens a provider session only when you start Talk; signing
1022+
in does not open the microphone or start a voice session. Returning to the
1023+
browser after sign-in refreshes the chat microphone's readiness.
1024+
10181025
The two browser paths expose the same Talk session contract but keep
10191026
credentials on different sides of the trust boundary. Platform auth mints
10201027
an ephemeral client secret and the browser exchanges SDP directly with

‎extensions/openai/openclaw.plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "openai",
33
"activation": {
4-
"onStartup": false
4+
"onStartup": true
55
},
66
"enabledByDefault": true,
77
"providers": ["openai"],

‎src/plugins/bundled-plugin-metadata.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ function createRepoBundledManifestRegistry(): PluginManifestRegistry {
208208
manifestPath: path.join(repoRoot, "extensions", dirName, "openclaw.plugin.json"),
209209
activation: manifest.activation,
210210
setup: manifest.setup,
211+
modelCatalog: manifest.modelCatalog,
211212
hooks: [],
212213
contracts: manifest.contracts,
213214
})),
@@ -618,6 +619,33 @@ describe("bundled plugin metadata", () => {
618619
).toContain("bonjour");
619620
});
620621

622+
it.each([
623+
{ name: "before login", config: {} },
624+
{
625+
name: "with only an OpenAI login and chat model",
626+
config: {
627+
auth: { profiles: { "openai:default": { provider: "openai", mode: "oauth" as const } } },
628+
agents: {
629+
defaults: {
630+
model: { primary: "openai/gpt-5.6-sol" },
631+
models: { "openai/gpt-5.6-sol": {} },
632+
},
633+
},
634+
},
635+
},
636+
])("starts the OpenAI browser broker $name without Talk configuration", ({ config }) => {
637+
const manifestRegistry = createRepoBundledManifestRegistry();
638+
639+
expect(
640+
resolveGatewayStartupPluginIdsFromRegistry({
641+
config,
642+
env: {},
643+
index: createInstalledPluginIndexForManifests(manifestRegistry),
644+
manifestRegistry,
645+
}),
646+
).toContain("openai");
647+
});
648+
621649
it("starts Bonjour when explicitly enabled", () => {
622650
const manifestRegistry = createRepoBundledManifestRegistry();
623651
const index = createInstalledPluginIndexForManifests(manifestRegistry);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { createDeferred } from "../../../../test/helpers/promise.js";
3+
import type { GatewayBrowserClient } from "../../api/gateway.ts";
4+
import { ComposerMicrophonePicker } from "./composer-microphone-picker.ts";
5+
6+
function catalog(ready: boolean) {
7+
return {
8+
realtime: { ready, providers: [] },
9+
transcription: { ready, providers: [] },
10+
};
11+
}
12+
13+
let picker: ComposerMicrophonePicker;
14+
15+
afterEach(() => picker?.dispose());
16+
17+
describe("composer voice readiness", () => {
18+
it("refreshes after returning from login on the same Gateway connection", async () => {
19+
const request = vi.fn().mockResolvedValueOnce(catalog(false)).mockResolvedValue(catalog(true));
20+
const client = { request } as unknown as GatewayBrowserClient;
21+
picker = new ComposerMicrophonePicker(vi.fn());
22+
picker.syncCatalog(client, true);
23+
await vi.waitFor(() => expect(picker.realtimeStatus).toBe("unavailable"));
24+
25+
window.dispatchEvent(new Event("focus"));
26+
27+
await vi.waitFor(() => expect(picker.realtimeStatus).toBe("ready"));
28+
expect(picker.dictationStatus).toBe("ready");
29+
expect(request).toHaveBeenCalledTimes(2);
30+
expect(request).toHaveBeenLastCalledWith("talk.catalog", {});
31+
expect(picker.open).toBe(false);
32+
});
33+
34+
it("retires focus requests on disposal and reconnects a reused picker without stale results", async () => {
35+
const stale = createDeferred<ReturnType<typeof catalog>>();
36+
const request = vi
37+
.fn()
38+
.mockResolvedValueOnce(catalog(false))
39+
.mockReturnValueOnce(stale.promise)
40+
.mockResolvedValue(catalog(true));
41+
const client = { request } as unknown as GatewayBrowserClient;
42+
const requestUpdate = vi.fn();
43+
picker = new ComposerMicrophonePicker(requestUpdate);
44+
picker.syncCatalog(client, true);
45+
await vi.waitFor(() => expect(picker.realtimeStatus).toBe("unavailable"));
46+
window.dispatchEvent(new Event("focus"));
47+
expect(request).toHaveBeenCalledTimes(2);
48+
49+
picker.dispose();
50+
window.dispatchEvent(new Event("focus"));
51+
expect(request).toHaveBeenCalledTimes(2);
52+
expect(picker.realtimeStatus).toBe("unknown");
53+
54+
picker.syncCatalog(client, true);
55+
await vi.waitFor(() => expect(picker.realtimeStatus).toBe("ready"));
56+
requestUpdate.mockClear();
57+
stale.resolve(catalog(false));
58+
await stale.promise;
59+
await Promise.resolve();
60+
expect(picker.realtimeStatus).toBe("ready");
61+
expect(requestUpdate).not.toHaveBeenCalled();
62+
63+
window.dispatchEvent(new Event("focus"));
64+
expect(request).toHaveBeenCalledTimes(4);
65+
picker.syncCatalog(client, false);
66+
window.dispatchEvent(new Event("focus"));
67+
expect(request).toHaveBeenCalledTimes(4);
68+
});
69+
});

‎ui/src/pages/chat/composer-microphone-picker.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export class ComposerMicrophonePicker {
3030
private catalogRequest = 0;
3131
private realtimeStatusValue: ComposerTalkCapabilityStatus = "unknown";
3232
private dictationStatusValue: ComposerTalkCapabilityStatus = "unknown";
33+
// Terminal login changes credentials without replacing the Gateway connection.
34+
private readonly refreshOnFocus = (): void => this.loadCatalog();
3335

3436
constructor(private readonly requestUpdate: () => void) {}
3537

@@ -61,6 +63,7 @@ export class ComposerMicrophonePicker {
6163
if (client === this.catalogClient && connected === this.catalogConnected) {
6264
return;
6365
}
66+
window.removeEventListener("focus", this.refreshOnFocus);
6467
this.catalogClient = client;
6568
this.catalogConnected = connected;
6669
this.catalogRequest++;
@@ -69,6 +72,7 @@ export class ComposerMicrophonePicker {
6972
this.dictationStatusValue = "unknown";
7073
return;
7174
}
75+
window.addEventListener("focus", this.refreshOnFocus);
7276
this.loadCatalog(false);
7377
}
7478

@@ -99,6 +103,7 @@ export class ComposerMicrophonePicker {
99103

100104
/** Ends an in-flight discovery too, so a late result cannot revive the list. */
101105
dispose(): void {
106+
window.removeEventListener("focus", this.refreshOnFocus);
102107
this.release();
103108
this.discoveryRequest++;
104109
this.catalogRequest++;

0 commit comments

Comments
 (0)