Skip to content

Commit e1d235c

Browse files
authored
voice - make sure speech context counters do not get out of sync (microsoft#213637) (microsoft#213898)
1 parent fa23e5f commit e1d235c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/vs/workbench/contrib/chat/common/voiceChatService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class VoiceChatService extends Disposable implements IVoiceChatService {
126126
const disposables = new DisposableStore();
127127

128128
const onSessionStoppedOrCanceled = (dispose: boolean) => {
129-
this.activeVoiceChatSessions--;
129+
this.activeVoiceChatSessions = Math.max(0, this.activeVoiceChatSessions - 1);
130130
if (this.activeVoiceChatSessions === 0) {
131131
this.voiceChatInProgress.reset();
132132
}

src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,10 @@ export class StopListeningAndSubmitAction extends Action2 {
665665
f1: true,
666666
keybinding: {
667667
weight: KeybindingWeight.WorkbenchContrib,
668-
when: FocusInChatInput,
668+
when: ContextKeyExpr.and(
669+
FocusInChatInput,
670+
AnyScopedVoiceChatInProgress
671+
),
669672
primary: KeyMod.CtrlCmd | KeyCode.KeyI
670673
},
671674
precondition: GlobalVoiceChatInProgress // need global context here because of `f1: true`

src/vs/workbench/contrib/speech/browser/speechService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class SpeechService extends Disposable implements ISpeechService {
153153
const disposables = new DisposableStore();
154154

155155
const onSessionStoppedOrCanceled = () => {
156-
this.activeSpeechToTextSessions--;
156+
this.activeSpeechToTextSessions = Math.max(0, this.activeSpeechToTextSessions - 1);
157157
if (!this.hasActiveSpeechToTextSession) {
158158
this.speechToTextInProgress.reset();
159159
}
@@ -264,7 +264,7 @@ export class SpeechService extends Disposable implements ISpeechService {
264264
const disposables = new DisposableStore();
265265

266266
const onSessionStoppedOrCanceled = (dispose: boolean) => {
267-
this.activeTextToSpeechSessions--;
267+
this.activeTextToSpeechSessions = Math.max(0, this.activeTextToSpeechSessions - 1);
268268
if (!this.hasActiveTextToSpeechSession) {
269269
this.textToSpeechInProgress.reset();
270270
}
@@ -406,7 +406,7 @@ export class SpeechService extends Disposable implements ISpeechService {
406406
const disposables = new DisposableStore();
407407

408408
const onSessionStoppedOrCanceled = () => {
409-
this.activeKeywordRecognitionSessions--;
409+
this.activeKeywordRecognitionSessions = Math.max(0, this.activeKeywordRecognitionSessions - 1);
410410
this._onDidEndKeywordRecognition.fire();
411411

412412
disposables.dispose();

0 commit comments

Comments
 (0)