Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ interface IActiveVoiceChatSession extends IVoiceChatSession {
readonly id: number;
readonly controller: IVoiceChatSessionController;
readonly disposables: DisposableStore;

hasRecognizedInput: boolean;
}

class VoiceChatSessions {
Expand Down Expand Up @@ -280,6 +282,7 @@ class VoiceChatSessions {
const session: IActiveVoiceChatSession = this.currentVoiceChatSession = {
id: sessionId,
controller,
hasRecognizedInput: false,
disposables: new DisposableStore(),
setTimeoutDisabled: (disabled: boolean) => { disableTimeout = disabled; },
accept: () => this.accept(sessionId),
Expand Down Expand Up @@ -317,6 +320,7 @@ class VoiceChatSessions {
break;
case SpeechToTextStatus.Recognizing:
if (text) {
session.hasRecognizedInput = true;
session.controller.updateInput(inputValue ? [inputValue, text].join(' ') : text);
if (voiceChatTimeout > 0 && context?.voice?.disableTimeout !== true && !disableTimeout) {
acceptTranscriptionScheduler.cancel();
Expand All @@ -325,6 +329,7 @@ class VoiceChatSessions {
break;
case SpeechToTextStatus.Recognized:
if (text) {
session.hasRecognizedInput = true;
inputValue = inputValue ? [inputValue, text].join(' ') : text;
session.controller.updateInput(inputValue);
if (voiceChatTimeout > 0 && context?.voice?.disableTimeout !== true && !waitingForInput && !disableTimeout) {
Expand Down Expand Up @@ -381,6 +386,15 @@ class VoiceChatSessions {
return;
}

if (!this.currentVoiceChatSession.hasRecognizedInput) {
// If we have an active session but without recognized
// input, we do not want to just accept the input that
// was maybe typed before. But we still want to stop the
// voice session because `acceptInput` would do that.
this.stop(voiceChatSessionId, this.currentVoiceChatSession.controller.context);
return;
}

const controller = this.currentVoiceChatSession.controller;
const response = await controller.acceptInput();
if (!response) {
Expand Down