Skip to content

Commit

Permalink
voice - limit Escape key to context key scopes (might help for #213017
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bpasero committed May 20, 2024
1 parent 7c8252c commit 169d8b4
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ class VoiceChatSessionControllerFactory {
switch (state) {
case VoiceChatSessionState.GettingReady:
contextVoiceChatGettingReady.set(true);
contextVoiceChatInProgress.set(undefined);
contextVoiceChatInProgress.reset();
break;
case VoiceChatSessionState.Started:
contextVoiceChatGettingReady.set(false);
contextVoiceChatGettingReady.reset();
contextVoiceChatInProgress.set(context);
break;
case VoiceChatSessionState.Stopped:
contextVoiceChatGettingReady.set(false);
contextVoiceChatInProgress.set(undefined);
contextVoiceChatGettingReady.reset();
contextVoiceChatInProgress.reset();
break;
}
};
Expand Down Expand Up @@ -629,7 +629,8 @@ export class StopListeningAction extends Action2 {
f1: true,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib + 100,
primary: KeyCode.Escape
primary: KeyCode.Escape,
when: AnyScopedVoiceChatInProgress
},
icon: spinningLoading,
precondition: GlobalVoiceChatInProgress, // need global context here because of `f1: true`
Expand Down Expand Up @@ -775,15 +776,15 @@ class ChatSynthesizerSessions {
disposables.add(controller.onDidHideChat(() => this.stop()));

const scopedChatToSpeechInProgress = ScopedChatSynthesisInProgress.bindTo(controller.contextKeyService);
disposables.add(toDisposable(() => scopedChatToSpeechInProgress.set(false)));
disposables.add(toDisposable(() => scopedChatToSpeechInProgress.reset()));

disposables.add(session.onDidChange(e => {
switch (e.status) {
case TextToSpeechStatus.Started:
scopedChatToSpeechInProgress.set(true);
break;
case TextToSpeechStatus.Stopped:
scopedChatToSpeechInProgress.set(false);
scopedChatToSpeechInProgress.reset();
break;
}
}));
Expand Down Expand Up @@ -917,6 +918,7 @@ export class StopReadAloud extends Action2 {
keybinding: {
weight: KeybindingWeight.WorkbenchContrib + 100,
primary: KeyCode.Escape,
when: ScopedChatSynthesisInProgress
},
menu: [
{
Expand Down Expand Up @@ -1237,7 +1239,7 @@ abstract class BaseInstallSpeechProviderAction extends Action2 {
enable: true
}, ProgressLocation.Notification);
} finally {
InstallingSpeechProvider.bindTo(contextKeyService).set(false);
InstallingSpeechProvider.bindTo(contextKeyService).reset();
}
}

Expand Down

0 comments on commit 169d8b4

Please sign in to comment.