Skip to content
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

alert when focus changes for chat responses/ notifications in the accessible view #189090

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { IListService, WorkbenchList } from 'vs/platform/list/browser/listServic
import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';
import { IAccessibleViewService, AccessibleViewService, IAccessibleContentProvider, IAccessibleViewOptions, AccessibleViewType, accessibleViewIsShown } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { alert } from 'vs/base/browser/ui/aria/aria';

registerAccessibilityConfiguration();
registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed);
Expand Down Expand Up @@ -173,13 +174,16 @@ class NotificationAccessibleViewContribution extends Disposable {
}
commandService.executeCommand('notifications.showList');
let notificationIndex: number | undefined;
let length: number | undefined;
const list = listService.lastFocusedList;
if (list instanceof WorkbenchList) {
notificationIndex = list.indexOf(notification);
length = list.length;
}
if (notificationIndex === undefined) {
return false;
}

function focusList(): void {
commandService.executeCommand('notifications.showList');
if (list && notificationIndex !== undefined) {
Expand All @@ -206,6 +210,7 @@ class NotificationAccessibleViewContribution extends Disposable {
}
focusList();
list.focusNext();
alertFocusChange(notificationIndex, length, 'next');
renderAccessibleView();
},
previous(): void {
Expand All @@ -214,6 +219,7 @@ class NotificationAccessibleViewContribution extends Disposable {
}
focusList();
list.focusPrevious();
alertFocusChange(notificationIndex, length, 'previous');
renderAccessibleView();
},
verbositySettingKey: AccessibilityVerbositySettingId.Notification,
Expand Down Expand Up @@ -249,3 +255,17 @@ class AccessibleViewNavigatorContribution extends Disposable {
}

workbenchContributionsRegistry.registerWorkbenchContribution(AccessibleViewNavigatorContribution, LifecyclePhase.Eventually);

export function alertFocusChange(index: number | undefined, length: number | undefined, type: 'next' | 'previous'): void {
if (index === undefined || length === undefined) {
return;
}
const number = index + 1;

if (type === 'next' && number + 1 <= length) {
alert(`Focused ${number + 1} of ${length}`);
} else if (type === 'previous' && number - 1 > 0) {
alert(`Focused ${number - 1} of ${length}`);
}
return;
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export class AccessibleViewService extends Disposable implements IAccessibleView
this._accessibleView = this._register(this._instantiationService.createInstance(AccessibleView));
}
this._accessibleView.show(provider);

}
next(): void {
this._accessibleView?.next();
Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/contrib/chat/browser/chat.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { CONTEXT_IN_CHAT_SESSION } from 'vs/workbench/contrib/chat/common/chatCo
import { ChatAccessibilityService } from 'vs/workbench/contrib/chat/browser/chatAccessibilityService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { QuickQuestionMode } from 'vs/workbench/contrib/chat/browser/actions/quickQuestionActions/quickQuestionAction';
import { alertFocusChange } from 'vs/workbench/contrib/accessibility/browser/accessibility.contribution';

// Register configuration
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
Expand Down Expand Up @@ -175,6 +176,9 @@ class ChatAccessibleViewContribution extends Disposable {
if (!responseContent) {
return false;
}
const responses = verifiedWidget.viewModel?.getItems().filter(i => isResponseVM(i));
const length = responses?.length;
const responseIndex = responses?.findIndex(i => i === focusedItem);

accessibleViewService.show({
verbositySettingKey: AccessibilityVerbositySettingId.Chat,
Expand All @@ -189,10 +193,12 @@ class ChatAccessibleViewContribution extends Disposable {
},
next() {
verifiedWidget.moveFocus(focusedItem, 'next');
alertFocusChange(responseIndex, length, 'next');
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
},
previous() {
verifiedWidget.moveFocus(focusedItem, 'previous');
alertFocusChange(responseIndex, length, 'previous');
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
},
options: { ariaLabel: nls.localize('chatAccessibleView', "Chat Accessible View"), type: AccessibleViewType.View }
Expand Down