-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Fix accessibility issues with confirmation widget, add command to focus it directly if present, announce none if not present #261874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0396589
Initial plan
Copilot 8e5c7dd
Implement chat confirmation dialog announcement command for accessibi…
Copilot b2ea92e
Add documentation for Announce Chat Confirmation Status command to ac…
Copilot 60aae04
Merge branch 'main' into copilot/fix-261864
meganrogge d4cae60
add container around element and aria label
meganrogge 05fda94
deal with htmlelement type
meganrogge 4f5c0a0
rm period
meganrogge 014c45c
clean up
meganrogge ff0696b
more clean up
meganrogge a534295
fix issue
meganrogge 52c6bf6
rearrange
meganrogge 5ed82ab
only when in screen reader mode
meganrogge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityActions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { alert } from '../../../../../base/browser/ui/aria/aria.js'; | ||
import { localize } from '../../../../../nls.js'; | ||
import { Action2, MenuId, registerAction2 } from '../../../../../platform/actions/common/actions.js'; | ||
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js'; | ||
import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js'; | ||
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js'; | ||
import { KeyCode, KeyMod } from '../../../../../base/common/keyCodes.js'; | ||
import { IChatWidgetService } from '../chat.js'; | ||
import { ChatContextKeys } from '../../common/chatContextKeys.js'; | ||
import { ChatAgentLocation } from '../../common/constants.js'; | ||
import { isResponseVM } from '../../common/chatViewModel.js'; | ||
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../../../../../platform/accessibility/common/accessibility.js'; | ||
|
||
export const ACTION_ID_FOCUS_CHAT_CONFIRMATION = 'workbench.action.chat.focusConfirmation'; | ||
|
||
class AnnounceChatConfirmationAction extends Action2 { | ||
constructor() { | ||
super({ | ||
id: ACTION_ID_FOCUS_CHAT_CONFIRMATION, | ||
title: { value: localize('focusChatConfirmation', 'Focus Chat Confirmation'), original: 'Focus Chat Confirmation' }, | ||
category: { value: localize('chat.category', 'Chat'), original: 'Chat' }, | ||
f1: true, | ||
keybinding: { | ||
weight: KeybindingWeight.WorkbenchContrib, | ||
primary: KeyMod.Alt | KeyCode.KeyA, | ||
when: ContextKeyExpr.and( | ||
ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel), | ||
ChatContextKeys.inChatSession, | ||
CONTEXT_ACCESSIBILITY_MODE_ENABLED | ||
) | ||
}, | ||
menu: [ | ||
{ | ||
id: MenuId.ChatConfirmationMenu, | ||
when: ChatContextKeys.inChatSession, | ||
group: '0_main' | ||
} | ||
] | ||
}); | ||
} | ||
|
||
async run(accessor: ServicesAccessor): Promise<void> { | ||
const chatWidgetService = accessor.get(IChatWidgetService); | ||
const lastFocusedWidget = chatWidgetService.lastFocusedWidget; | ||
|
||
if (!lastFocusedWidget) { | ||
alert(localize('noChatSession', 'No active chat session found.')); | ||
return; | ||
} | ||
|
||
const viewModel = lastFocusedWidget.viewModel; | ||
if (!viewModel) { | ||
alert(localize('chatNotReady', 'Chat interface not ready.')); | ||
return; | ||
} | ||
|
||
// Check for active confirmations in the chat responses | ||
let firstConfirmationElement: HTMLElement | undefined; | ||
|
||
const lastResponse = viewModel.getItems()[viewModel.getItems().length - 1]; | ||
if (isResponseVM(lastResponse)) { | ||
const confirmationWidgets = lastFocusedWidget.domNode.querySelectorAll('.chat-confirmation-widget-container'); | ||
if (confirmationWidgets.length > 0) { | ||
firstConfirmationElement = confirmationWidgets[0] as HTMLElement; | ||
} | ||
} | ||
|
||
if (firstConfirmationElement) { | ||
firstConfirmationElement.focus(); | ||
} else { | ||
alert(localize('noConfirmationRequired', 'No chat confirmation required')); | ||
} | ||
} | ||
} | ||
|
||
export function registerChatAccessibilityActions(): void { | ||
registerAction2(AnnounceChatConfirmationAction); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think message is being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is being used - it gets passed to the base chat confirmation widget to be used in the aria label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationWidget.ts
Line 368 in 5ed82ab