Skip to content

Commit ef18b65

Browse files
authored
by default, play tool user action required when window is not focused (microsoft#249379)
fix issue
1 parent 5c28bf5 commit ef18b65

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/vs/base/browser/dom.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,11 @@ export function getActiveWindow(): CodeWindow {
944944

945945
export function getFocusedWindow(): CodeWindow | undefined {
946946
const document = getActiveDocument();
947-
return (document.defaultView?.window) as CodeWindow | undefined;
947+
// This check is needed to ensure the window has focus
948+
if (document.defaultView?.window.document.hasFocus()) {
949+
return (document.defaultView?.window) as CodeWindow;
950+
}
951+
return;
948952
}
949953

950954
interface IMutationObserver {

src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,15 @@ const configuration: IConfigurationNode = {
753753
},
754754
'accessibility.signals.chatUserActionRequired': {
755755
...signalFeatureBase,
756-
'markdownDescription': localize('accessibility.signals.chatUserActionRequired', "Plays a signal - sound (audio cue) and/or announcement (alert) - when user action is required in the chat."),
756+
'markdownDescription': localize('accessibility.signals.chatUserActionRequired', "Plays a signal - sound (audio cue) and/or announcement (alert) - when user action is required in the chat. Note that {0} will impact the `auto` behavior of this setting.", '`#chat.focusWindowOnConfirmation#`'),
757757
'properties': {
758758
'sound': {
759759
'description': localize('accessibility.signals.chatUserActionRequired.sound', "Plays a sound when user action is required in the chat."),
760760
'type': 'string',
761761
'enum': ['auto', 'on', 'off'],
762762
'default': 'auto',
763763
'enumDescriptions': [
764-
localize('sound.enabled.autoWindow', "Enable sound when a screen reader is attached or when the current window is focused."),
764+
localize('sound.enabled.autoWindow', "Enable sound when a screen reader is attached or when the current window is not focused."),
765765
localize('sound.enabled.on', "Enable sound."),
766766
localize('sound.enabled.off', "Disable sound.")
767767
],

src/vs/workbench/contrib/chat/browser/languageModelToolsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
367367
private playAccessibilitySignal(toolInvocations: ChatToolInvocation[]): void {
368368
const hasFocusedWindow = getFocusedWindow();
369369
const setting: { sound: 'auto' | 'on' | 'off' } = this._configurationService.getValue(AccessibilitySignal.chatUserActionRequired.settingsKey);
370-
if (setting.sound === 'on' || (setting.sound === 'auto' && (this._accessibilityService.isScreenReaderOptimized() || hasFocusedWindow))) {
370+
if (setting.sound === 'on' || (setting.sound === 'auto' && (this._accessibilityService.isScreenReaderOptimized() || !hasFocusedWindow))) {
371371
this._accessibilitySignalService.playSignal(AccessibilitySignal.chatUserActionRequired, { customAlertMessage: this._instantiationService.invokeFunction(getToolConfirmationAlert, toolInvocations), userGesture: true });
372372
}
373373
}

0 commit comments

Comments
 (0)