Skip to content

Commit 18b601b

Browse files
authored
voice - trigger keyword only when window has focus (microsoft#202737)
1 parent 98c2538 commit 18b601b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/co
4545
import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/browser/statusbar';
4646
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
4747
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
48+
import { IHostService } from 'vs/workbench/services/host/browser/host';
4849

4950
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 for voice chat.") });
5051
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 for voice chat.") });
@@ -772,7 +773,8 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
772773
@ICommandService private readonly commandService: ICommandService,
773774
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
774775
@IInstantiationService instantiationService: IInstantiationService,
775-
@ICodeEditorService private readonly codeEditorService: ICodeEditorService
776+
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
777+
@IHostService private readonly hostService: IHostService
776778
) {
777779
super();
778780

@@ -867,7 +869,11 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
867869
this.activeSession = undefined;
868870

869871
if (result === KeywordRecognitionStatus.Recognized) {
870-
this.commandService.executeCommand(this.getKeywordCommand());
872+
if (this.hostService.hasFocus) {
873+
this.commandService.executeCommand(this.getKeywordCommand());
874+
} else {
875+
this.handleKeywordActivation();
876+
}
871877
}
872878
}
873879

0 commit comments

Comments
 (0)