Skip to content

Commit 41766c0

Browse files
authored
Merge pull request microsoft#183150 from microsoft/merogge/chat-toolbar
always render toolbar when in screen reader mode
2 parents bc1090c + 8800bc8 commit 41766c0

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export function getAccessibilityHelpText(accessor: ServicesAccessor, type: 'chat
2323
if (type === 'chat') {
2424
content.push(descriptionForCommand('chat.action.focus', localize('workbench.action.chat.focus', 'The Focus Chat command ({0}) focuses the chat request/response list, which can be navigated with UpArrow/DownArrow.',), localize('workbench.action.chat.focusNoKb', 'The Focus Chat List command focuses the chat request/response list, which can be navigated with UpArrow/DownArrow and is currently not triggerable by a keybinding.'), keybindingService));
2525
content.push(descriptionForCommand('workbench.action.chat.focusInput', localize('workbench.action.chat.focusInput', 'The Focus Chat Input command ({0}) focuses the input box for chat requests.'), localize('workbench.action.interactiveSession.focusInputNoKb', 'Focus Chat Input command focuses the input box for chat requests and is currently not triggerable by a keybinding.'), keybindingService));
26-
content.push('Chat responses may contain code blocks which can be tabbed to. Use typical editor keybindings to select and copy text. To further interact with these code blocks, run the following commands:');
27-
content.push(descriptionForCommand('workbench.action.chat.insertCodeBlock', localize('workbench.action.chat.insertCodeBlock', 'Insert Code Block ({0}) inserts the code at the current cursor location in last active editor'), localize('workbench.action.chat.insertCodeBlockNoKb', 'Insert Code Block inserts the code at the current cursor location and is currently not triggerable by a keybinding.'), keybindingService));
28-
content.push(descriptionForCommand('workbench.action.chat.insertIntoNewFile', localize('workbench.action.chat.insertIntoNewFile', 'Insert into New File ({0}) creates a new file with the code block as its content'), localize('workbench.action.chat.insertIntoNewFileNoKb', 'Insert into New File creates a new file with the code block as its content and is currently not triggerable by a keybinding.'), keybindingService));
29-
content.push(descriptionForCommand('workbench.action.chat.runInTerminal', localize('workbench.action.chat.runInTerminal', 'Run in Terminal ({0}) runs the code block in the terminal'), localize('workbench.action.chat.runInTerminalNoKb', 'Run in Terminal runs the code block in the terminal and is currently not triggerable by a keybinding.'), keybindingService));
3026
} else {
3127
content.push(localize('interactiveSession.makeRequest', "Tab once to reach the make request button, which will re-run the request."));
3228
const regex = /^(\/fix|\/explain)/;

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { CONTEXT_RESPONSE_HAS_PROVIDER_ID, CONTEXT_RESPONSE_VOTE } from 'vs/work
5858
import { IChatReplyFollowup, IChatService, ISlashCommand, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService';
5959
import { IChatRequestViewModel, IChatResponseViewModel, IChatWelcomeMessageViewModel, isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
6060
import { IWordCountResult, getNWords } from 'vs/workbench/contrib/chat/common/chatWordCounter';
61+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
6162
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
6263

6364
const $ = dom.$;
@@ -583,11 +584,11 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
583584
@IContextKeyService contextKeyService: IContextKeyService,
584585
@ILanguageService private readonly languageService: ILanguageService,
585586
@IModelService private readonly modelService: IModelService,
586-
@IConfigurationService private readonly _configurationService: IConfigurationService
587+
@IConfigurationService private readonly _configurationService: IConfigurationService,
588+
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
587589
) {
588590
super();
589591
this.element = $('.interactive-result-editor-wrapper');
590-
591592
this.contextKeyService = this._register(contextKeyService.createScoped(this.element));
592593
const scopedInstantiationService = instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService]));
593594
this.toolbar = this._register(scopedInstantiationService.createInstance(MenuWorkbenchToolBar, this.element, MenuId.ChatCodeBlock, {
@@ -596,6 +597,13 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
596597
}
597598
}));
598599

600+
this._configureForScreenReader();
601+
this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => this._configureForScreenReader()));
602+
this._register(this._configurationService.onDidChangeConfiguration((e) => {
603+
if (e.affectedKeys.has(AccessibilityVerbositySettingId.Chat)) {
604+
this._configureForScreenReader();
605+
}
606+
}));
599607
const editorElement = dom.append(this.element, $('.interactive-result-editor'));
600608
this.editor = this._register(scopedInstantiationService.createInstance(CodeEditorWidget, editorElement, {
601609
...getSimpleEditorOptions(),
@@ -610,7 +618,7 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
610618
scrollbar: {
611619
alwaysConsumeMouseWheel: false
612620
},
613-
ariaLabel: this._configurationService.getValue(AccessibilityVerbositySettingId.Chat) ? localize('chat.codeBlockHelp', 'Code block, to discover ways this can be interacted with, search the command palette for Chat: Insert and Chat: Run.') : localize('chat.codeBlock', 'Code block'),
621+
ariaLabel: localize('chat.codeBlockHelp', 'Code block'),
614622
...this.getEditorOptionsFromConfig()
615623
}, {
616624
isSimpleWidget: true,
@@ -665,6 +673,17 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
665673
this.editor.updateOptions({ padding: { top: defaultCodeblockPadding, bottom: bottomPadding } });
666674
}
667675

676+
private _configureForScreenReader(): void {
677+
const toolbarElt = this.toolbar.getElement();
678+
if (this._accessibilityService.isScreenReaderOptimized()) {
679+
toolbarElt.style.display = 'block';
680+
toolbarElt.ariaLabel = this._configurationService.getValue(AccessibilityVerbositySettingId.Chat) ? localize('chat.codeBlock.toolbarVerbose', 'Toolbar for code block which can be reached via tab') : localize('chat.codeBlock.toolbar', 'Code block toolbar');
681+
} else {
682+
toolbarElt.style.display = '';
683+
}
684+
685+
}
686+
668687
private getEditorOptionsFromConfig(): IEditorOptions {
669688
return {
670689
wordWrap: this.options.configuration.resultEditor.wordWrap,

0 commit comments

Comments
 (0)