Skip to content

Commit 8505713

Browse files
feat(webchat): add server-side dictation
1 parent 9e12718 commit 8505713

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

ui/src/ui/app.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,19 @@ describe("OpenClawApp dictation recorder lifecycle", () => {
136136
await app.toggleChatDictation();
137137
const recorder = MockMediaRecorder.instances[0];
138138
recorder.emitData(new Blob(["audio"], { type: "audio/webm" }));
139-
transcribeChatAudioMock.mockImplementationOnce(async () => {
140-
expect(app.chatDictationChunks).toEqual([]);
141-
return null;
142-
});
139+
const transcription = createDeferred<null>();
140+
transcribeChatAudioMock.mockReturnValueOnce(transcription.promise);
143141

144142
await app.toggleChatDictation();
145-
await Promise.resolve();
146143

147144
expect(app.chatDictationChunks).toEqual([]);
148145
expect(transcribeChatAudioMock).toHaveBeenCalledTimes(1);
149146
expect(transcribeChatAudioMock.mock.calls[0]?.[1]).toMatchObject({
150147
size: 5,
151148
type: "audio/webm",
152149
});
150+
transcription.resolve(null);
151+
await transcription.promise;
153152
});
154153

155154
it("ignores duplicate starts while microphone permission is pending", async () => {

ui/src/ui/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,7 @@ export class OpenClawApp extends LitElement {
10151015
if (this.chatDictationRecorder !== recorder) {
10161016
return;
10171017
}
1018-
const chunks = [...this.chatDictationChunks];
1019-
this.chatDictationChunks = [];
1018+
const chunks = this.chatDictationChunks.splice(0);
10201019
const canceledByRequest = this.chatDictationCancelNextStop;
10211020
this.chatDictationCancelNextStop = false;
10221021
this.chatDictationRecorder = null;

0 commit comments

Comments
 (0)