From 8b8adb2d6a77cddac9f7c7e3cfcc5fbea5b2d98b Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Fri, 4 Oct 2024 14:07:51 -0700 Subject: [PATCH 1/2] bring back `TerminalChatExecute` menu so voice input is possible, fire `acceptInput` so recording stops appropriately (#230529) --- .../actions/voiceChatActions.ts | 31 ++++++++++++++++++- .../chat/browser/terminalChatController.ts | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts b/src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts index 636fd55a28487..b64c4c90309d6 100644 --- a/src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts +++ b/src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts @@ -62,6 +62,8 @@ import { renderStringAsPlaintext } from '../../../../../base/browser/markdownRen type VoiceChatSessionContext = 'view' | 'inline' | 'terminal' | 'quick' | 'editor'; const VoiceChatSessionContexts: VoiceChatSessionContext[] = ['view', 'inline', 'terminal', 'quick', 'editor']; +const TerminalChatExecute = MenuId.for('terminalChatInput'); // unfortunately, terminal decided to go with their own menu (https://github.com/microsoft/vscode/issues/208789) + // Global Context Keys (set on global context key service) const CanVoiceChat = ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, HasSpeechProvider); const FocusInChatInput = ContextKeyExpr.or(CTX_INLINE_CHAT_FOCUSED, CONTEXT_IN_CHAT_INPUT); @@ -609,6 +611,16 @@ export class StartVoiceChatAction extends Action2 { group: 'navigation', order: 2 }, + { + id: TerminalChatExecute, + when: ContextKeyExpr.and( + HasSpeechProvider, + ScopedChatSynthesisInProgress.negate(), // hide when text to speech is in progress + AnyScopedVoiceChatInProgress?.negate(), // hide when voice chat is in progress + ), + group: 'navigation', + order: -1 + }, ] }); } @@ -656,6 +668,12 @@ export class StopListeningAction extends Action2 { when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel).negate(), AnyScopedVoiceChatInProgress), group: 'navigation', order: 2 + }, { + + id: TerminalChatExecute, + when: AnyScopedVoiceChatInProgress, + group: 'navigation', + order: -1 }, ] }); @@ -991,6 +1009,12 @@ export class StopReadAloud extends Action2 { group: 'navigation', order: 2 }, + { + id: TerminalChatExecute, + when: ScopedChatSynthesisInProgress, + group: 'navigation', + order: -1 + } ] }); } @@ -1325,9 +1349,14 @@ export class InstallSpeechProviderForVoiceChatAction extends BaseInstallSpeechPr precondition: InstallingSpeechProvider.negate(), menu: [{ id: MenuId.ChatInput, - when: HasSpeechProvider.negate(), + when: ContextKeyExpr.and(HasSpeechProvider.negate(), CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Terminal).negate()), group: 'navigation', order: 3 + }, { + id: TerminalChatExecute, + when: HasSpeechProvider.negate(), + group: 'navigation', + order: -1 }] }); } diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts index 00dadb2a5cb1d..93d203ae24c04 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts @@ -216,6 +216,7 @@ export class TerminalChatController extends Disposable implements ITerminalContr await this.reveal(); } assertType(this._model.value); + this._messages.fire(Message.AcceptInput); const lastInput = this._terminalChatWidget.value.inlineChatWidget.value; if (!lastInput) { return; From 3c6fbbf6c29d5d997608faa1c0106481fbd9dc71 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 7 Oct 2024 12:34:01 -0700 Subject: [PATCH 2/2] fix name --- .../terminalContrib/chat/browser/terminalChatController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts index 93d203ae24c04..6ed1f888c50dc 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts @@ -216,7 +216,7 @@ export class TerminalChatController extends Disposable implements ITerminalContr await this.reveal(); } assertType(this._model.value); - this._messages.fire(Message.AcceptInput); + this._messages.fire(Message.ACCEPT_INPUT); const lastInput = this._terminalChatWidget.value.inlineChatWidget.value; if (!lastInput) { return;