Skip to content

Commit 0e3926c

Browse files
authored
voice - fix bad controller when using toolbar actions (microsoft#191780)
1 parent bee68ce commit 0e3926c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { IViewsService } from 'vs/workbench/common/views';
3232
import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService';
3333
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
3434
import { KeyCode } from 'vs/base/common/keyCodes';
35+
import { isExecuteActionContext } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
3536

3637
const CONTEXT_VOICE_CHAT_GETTING_READY = new RawContextKey<boolean>('voiceChatGettingReady', false, { type: 'boolean', description: localize('voiceChatGettingReady', "True when getting ready for receiving voice input from the microphone.") });
3738
const CONTEXT_VOICE_CHAT_IN_PROGRESS = new RawContextKey<boolean>('voiceChatInProgress', false, { type: 'boolean', description: localize('voiceChatInProgress', "True when voice recording from microphone is in progress.") });
@@ -375,10 +376,18 @@ class StartVoiceChatAction extends Action2 {
375376
});
376377
}
377378

378-
async run(accessor: ServicesAccessor): Promise<void> {
379+
async run(accessor: ServicesAccessor, context: unknown): Promise<void> {
379380
const instantiationService = accessor.get(IInstantiationService);
380381
const commandService = accessor.get(ICommandService);
381382

383+
if (isExecuteActionContext(context)) {
384+
// if we already get a context when the action is executed
385+
// from a toolbar within the chat widget, then make sure
386+
// to move focus into the input field so that the controller
387+
// is properly retrieved
388+
context.widget.focusInput();
389+
}
390+
382391
const controller = await VoiceChatSessionControllerFactory.create(accessor, 'focussed');
383392
if (controller) {
384393
VoiceChatSession.getInstance(instantiationService).start(controller);

0 commit comments

Comments
 (0)