Skip to content

Commit 2a47374

Browse files
authored
re-add terminal voice action, stop it when appropriate (microsoft#230552)
1 parent acb2ed6 commit 2a47374

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ import { renderStringAsPlaintext } from '../../../../../base/browser/markdownRen
6262
type VoiceChatSessionContext = 'view' | 'inline' | 'terminal' | 'quick' | 'editor';
6363
const VoiceChatSessionContexts: VoiceChatSessionContext[] = ['view', 'inline', 'terminal', 'quick', 'editor'];
6464

65+
const TerminalChatExecute = MenuId.for('terminalChatInput'); // unfortunately, terminal decided to go with their own menu (https://github.com/microsoft/vscode/issues/208789)
66+
6567
// Global Context Keys (set on global context key service)
6668
const CanVoiceChat = ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, HasSpeechProvider);
6769
const FocusInChatInput = ContextKeyExpr.or(CTX_INLINE_CHAT_FOCUSED, CONTEXT_IN_CHAT_INPUT);
@@ -609,6 +611,16 @@ export class StartVoiceChatAction extends Action2 {
609611
group: 'navigation',
610612
order: 2
611613
},
614+
{
615+
id: TerminalChatExecute,
616+
when: ContextKeyExpr.and(
617+
HasSpeechProvider,
618+
ScopedChatSynthesisInProgress.negate(), // hide when text to speech is in progress
619+
AnyScopedVoiceChatInProgress?.negate(), // hide when voice chat is in progress
620+
),
621+
group: 'navigation',
622+
order: -1
623+
},
612624
]
613625
});
614626
}
@@ -656,6 +668,12 @@ export class StopListeningAction extends Action2 {
656668
when: ContextKeyExpr.and(CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel).negate(), AnyScopedVoiceChatInProgress),
657669
group: 'navigation',
658670
order: 2
671+
}, {
672+
673+
id: TerminalChatExecute,
674+
when: AnyScopedVoiceChatInProgress,
675+
group: 'navigation',
676+
order: -1
659677
},
660678
]
661679
});
@@ -991,6 +1009,12 @@ export class StopReadAloud extends Action2 {
9911009
group: 'navigation',
9921010
order: 2
9931011
},
1012+
{
1013+
id: TerminalChatExecute,
1014+
when: ScopedChatSynthesisInProgress,
1015+
group: 'navigation',
1016+
order: -1
1017+
}
9941018
]
9951019
});
9961020
}
@@ -1325,9 +1349,14 @@ export class InstallSpeechProviderForVoiceChatAction extends BaseInstallSpeechPr
13251349
precondition: InstallingSpeechProvider.negate(),
13261350
menu: [{
13271351
id: MenuId.ChatInput,
1328-
when: HasSpeechProvider.negate(),
1352+
when: ContextKeyExpr.and(HasSpeechProvider.negate(), CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Terminal).negate()),
13291353
group: 'navigation',
13301354
order: 3
1355+
}, {
1356+
id: TerminalChatExecute,
1357+
when: HasSpeechProvider.negate(),
1358+
group: 'navigation',
1359+
order: -1
13311360
}]
13321361
});
13331362
}

src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export class TerminalChatController extends Disposable implements ITerminalContr
216216
await this.reveal();
217217
}
218218
assertType(this._model.value);
219+
this._messages.fire(Message.ACCEPT_INPUT);
219220
const lastInput = this._terminalChatWidget.value.inlineChatWidget.value;
220221
if (!lastInput) {
221222
return;

0 commit comments

Comments
 (0)