Skip to content

Commit 161b585

Browse files
committed
fix(talk): report runtime-selected catalog provider
1 parent b883971 commit 161b585

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

src/gateway/server-methods/talk.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,81 @@ describe("talk.catalog handler", () => {
453453
});
454454
});
455455

456+
it("reports the provider selected by runtime resolution when aliases collide", async () => {
457+
const transcriptionAlias = {
458+
id: "transcription-alias",
459+
label: "Transcription Alias",
460+
aliases: ["shared-transcription"],
461+
isConfigured: vi.fn(() => true),
462+
};
463+
const transcriptionDirect = {
464+
id: "shared-transcription",
465+
label: "Transcription Direct",
466+
isConfigured: vi.fn(() => true),
467+
};
468+
const realtimeAlias = {
469+
id: "realtime-alias",
470+
label: "Realtime Alias",
471+
aliases: ["shared-realtime"],
472+
isConfigured: vi.fn(() => true),
473+
createBridge: vi.fn(),
474+
};
475+
const realtimeDirect = {
476+
id: "shared-realtime",
477+
label: "Realtime Direct",
478+
isConfigured: vi.fn(() => true),
479+
createBridge: vi.fn(),
480+
};
481+
mocks.listRealtimeTranscriptionProviders.mockReturnValue([
482+
transcriptionAlias,
483+
transcriptionDirect,
484+
] as never);
485+
mocks.listRealtimeVoiceProviders.mockReturnValue([realtimeAlias, realtimeDirect] as never);
486+
mocks.canonicalizeRealtimeTranscriptionProviderId.mockReturnValueOnce("shared-transcription");
487+
mocks.canonicalizeRealtimeVoiceProviderId.mockReturnValueOnce("shared-realtime");
488+
mocks.resolveConfiguredRealtimeVoiceProvider.mockReturnValue({
489+
provider: realtimeAlias,
490+
providerConfig: { enabled: true },
491+
} as never);
492+
493+
const respond = vi.fn();
494+
await talkHandlers["talk.catalog"]({
495+
req: { type: "req", id: "1", method: "talk.catalog" },
496+
params: {},
497+
client: { connect: { scopes: ["operator.read"] } } as never,
498+
isWebchatConnect: () => false,
499+
respond: respond as never,
500+
context: {
501+
getRuntimeConfig: () =>
502+
({
503+
talk: {
504+
realtime: {
505+
provider: "shared-realtime",
506+
providers: { "shared-realtime": { enabled: true } },
507+
},
508+
},
509+
plugins: {
510+
entries: {
511+
"voice-call": {
512+
config: {
513+
streaming: {
514+
provider: "shared-transcription",
515+
providers: { "shared-transcription": { enabled: true } },
516+
},
517+
},
518+
},
519+
},
520+
},
521+
}) as OpenClawConfig,
522+
} as never,
523+
});
524+
525+
expect(mockCallArg(respond, 0, 1)).toMatchObject({
526+
transcription: { ready: true, activeProvider: "transcription-alias" },
527+
realtime: { ready: true, activeProvider: "realtime-alias" },
528+
});
529+
});
530+
456531
it("reports an authoritative setup requirement when automatic selection fails", async () => {
457532
mocks.listRealtimeTranscriptionProviders.mockReturnValue([
458533
{

src/gateway/server-methods/talk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function resolveCatalogProviderSelection(
8787
try {
8888
const resolvedProvider = resolveAutomaticProvider();
8989
return {
90-
activeProvider: configuredProvider ?? resolvedProvider,
90+
activeProvider: resolvedProvider,
9191
ready: true,
9292
};
9393
} catch {

0 commit comments

Comments
 (0)