mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 13:11:38 +00:00
fix(discord): reset realtime wake-name continuity
This commit is contained in:
@@ -44,7 +44,7 @@ export type TestRealtimeBridgeParams = {
|
||||
cfg?: unknown;
|
||||
instructions?: string;
|
||||
interruptResponseOnInputAudio?: boolean;
|
||||
onEvent?: (event: { detail?: string; direction: "server"; type: string }) => void;
|
||||
onEvent?: (event: { detail?: string; direction: "client" | "server"; type: string }) => void;
|
||||
onToolCall?: (
|
||||
event: { args: unknown; callId: string; itemId: string; name: string },
|
||||
session: unknown,
|
||||
|
||||
@@ -3359,6 +3359,29 @@ describe("DiscordVoiceManager", () => {
|
||||
expectUserMessageIncludes("wake answer");
|
||||
});
|
||||
|
||||
it("does not carry partial wake-name state across provider continuity resets", async () => {
|
||||
const { entry, bridgeParams } = await createWakeNameFixture();
|
||||
const wakeAckCount = () =>
|
||||
sentUserMessages().filter((message) => message.includes('Answer: "Yeah."')).length;
|
||||
|
||||
beginSpeakerTurn(entry);
|
||||
bridgeParams?.onEvent?.({ direction: "server", type: "input_audio_buffer.speech_started" });
|
||||
bridgeParams?.onTranscript?.("user", "Hey, Mol", false);
|
||||
bridgeParams?.onEvent?.({ direction: "client", type: "session.continuity.reset" });
|
||||
bridgeParams?.onEvent?.({ direction: "client", type: "session.continuity.reset" });
|
||||
bridgeParams?.onTranscript?.("user", "ty", false);
|
||||
|
||||
expect(wakeAckCount()).toBe(0);
|
||||
|
||||
bridgeParams?.onEvent?.({ direction: "client", type: "session.continuity.reset" });
|
||||
bridgeParams?.onTranscript?.("user", "Hey, Molty", false);
|
||||
expect(wakeAckCount()).toBe(1);
|
||||
|
||||
bridgeParams?.onEvent?.({ direction: "client", type: "session.continuity.reset" });
|
||||
bridgeParams?.onTranscript?.("user", "Hey, Molty", false);
|
||||
expect(wakeAckCount()).toBe(2);
|
||||
});
|
||||
|
||||
it("treats a bare wake name as an activation for the next realtime transcript", async () => {
|
||||
agentCommandMock.mockResolvedValueOnce({ payloads: [{ text: "follow-up answer" }] });
|
||||
const onUtterance = vi.fn();
|
||||
|
||||
@@ -517,6 +517,9 @@ export class DiscordRealtimeVoiceSession implements VoiceRealtimeSession {
|
||||
onToolCall: (event, session) => this.handleToolCall(event, session),
|
||||
onEvent: (event) => {
|
||||
const detail = event.detail ? ` ${event.detail}` : "";
|
||||
if (event.direction === "client" && event.type === "session.continuity.reset") {
|
||||
this.resetPartialWakeNameTracking();
|
||||
}
|
||||
if (event.direction === "server" && event.type === "input_audio_buffer.speech_started") {
|
||||
this.resetPartialWakeNameTracking();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user