Visual Studio Code, rebuilt in Rust
Accessibility
How the port talks to assistive technology and to a keyboard-only user: the roles, labels and state a view gives the OS accessibility tree, screen reader mode, the live region, the accessible view and accessibility help, the signals, focus and Tab rules, and High Contrast themes. The code is app/src/workbench/accessibility.rs, app/src/workbench/accessible_view.rs, app/src/accessibility_signals.rs and the role calls in the views. This file goes one level under ARCHITECTURE.md. Upstream is src/vs/platform/accessibility, src/vs/workbench/contrib/accessibility, src/vs/platform/accessibilitySignal and src/vs/base/browser/ui/aria.
Accessibility is never cut for size or speed. The section "What a new view provides" is the rule for every new row, button and view.
What lives where
app/src/workbench/accessibility.rs: upstream'sIAccessibilityServicefor the window. Screen reader detection,is_screen_reader_optimized,is_motion_reduced, the status entry and prompt, the live region, the editor's text node, and when a signal plays.app/src/workbench/accessible_view.rs: the accessible view and accessibility help (accessibleView.ts, accessibleViewActions.ts): one read-only text widget, its providers, its toolbar and its own keys.app/src/accessibility_signals.rs: 38 of the 39 signals of accessibilitySignalService.ts as data (SIGNALS;dictationDisconnectedis missing),is_enabled(upstream'scheckEnabledState) andSoundPlayer. No workbench state.app/src/workbench/inlay_hints_accessibility.rs: Read Line with Inlay Hints.app/src/terminal/accessible_buffer.rs: the terminal buffer as lines for the accessible view.app/src/workbench/action_bar.rs: keyboard navigation of every action bar (actionbar.ts).app/src/workbench/part_navigation.rs: F6 and Shift+F6 between parts (navigationActions.ts).app/src/workbench/themes.rs::host_color_schemeandapp/src/theme.rs::ThemeKind: High Contrast.
The accessibility tree
GPUI builds an AccessKit tree from the elements of each frame and hands it to the platform adapter. The guide is the module header of native/vendor/gpui-fast/crates/gpui/src/_accessibility.rs.
Invariant: an element is a node of the tree only when it has an id and a role: div().id(..).role(Role::Button). An element with one of the two missing does not exist for VoiceOver, however it looks.
Invariant: the id of a node stays the same across frames while it stands for the same thing. A screen reader takes a new id for a removed node plus an added one and announces it. Key a row by what it shows when the list reorders, and keep ids unique within a frame.
Label and state go on the same element with the aria_* builders: aria_label, aria_description, aria_level, aria_selected, aria_expanded, aria_toggled, the numeric value builders. The Explorer row in app/src/workbench.rs (search Role::TreeItem) is the model for a tree row, the welcome page (app/src/workbench/welcome_page.rs) for buttons, check boxes, links and a progress bar.
Lists and trees follow listWidget.ts: the container keeps the keyboard focus and the focused row carries aria_active_descendant. A row does not take the GPUI focus.
An on_click handler also answers the AccessKit Click action. A handler on on_mouse_down does not: such an element adds on_a11y_action(Action::Click, ..) beside it, as the Manage button in app/src/workbench.rs does, and handles ClickEvent::is_keyboard for Enter and Space.
Trap: Role::GenericContainer is filtered out of the tree. Use Role::Group for a container that must be a node, as aria_live_region does.
Text has no element per line. app/src/workbench/accessibility.rs::editor_accessibility makes the editor one MultilineTextInput with the label of textAreaEditContext.ts and gives it synthetic children: screen_reader_page picks the page of lines around the selection (screenReaderUtils.ts SimplePagedScreenReaderStrategy, editor.accessibilityPageSize) and ScreenReaderPage writes one TextRun per line plus the selection. The accessible view reuses both.
Invariant: a text run states its character lengths in UTF-8 bytes, and the parent carries the whole page as its value. accesskit derives the value from the runs only for single-line inputs, so a text area without it reads as empty.
Invariant: work that only the tree can observe is gated on Window::is_a11y_active, as editor_accessibility gates the page. The page copies up to two pages of lines per frame; without the gate every frame of every user pays for it (performance.md). GPUI redraws when a client activates the tree.
Screen reader mode
screen_reader_running is Electron's app.isAccessibilitySupportEnabled, not is_a11y_active: on macOS VoiceOver is on, or an assistive app set AXManualAccessibility or AXEnhancedUserInterface on the application; on Linux AT-SPI's ScreenReaderEnabled. watch_assistive_apps runs once from app/src/main.rs, and on macOS adds two methods to GPUI's application class (memory-safety.md has the row). A client that only reads the tree does not switch the mode.
is_screen_reader_optimized is the one answer to "is a screen reader in use": editor.accessibilitySupport on, or auto with screen_reader_running. It feeds the accessibilityModeEnabled context key, auto values of the signals, the Explorer's compact folders (app/src/explorer.rs::FileTree field screen_reader_optimized), the debug and file dialog settings that have an auto. Read it; do not call screen_reader_running from a view. Its only callers are accessibility_frame and the diagnostics that report the raw state (app/src/launch.rs, app/src/workbench/perf_view.rs).
accessibility_frame runs on every render of the workbench. It notices the mode change (status entry "Screen Reader Optimized", the prompt once per window, accessibilityStatus.ts) and runs line_signals. It is a hot path: line_signals compares the cursor and the model version, and while a line or position signal is enabled it also reads the watched properties (markers, folds, breakpoints) at the cursor on every frame. Add no other work to it.
Trap: the GUI tools drive the app with cua-driver, which sets AXManualAccessibility or AXEnhancedUserInterface (port/notes.md), so the port and the reference both detect a screen reader under them. port/tools/ui-pair writes editor.accessibilitySupport: off unless SETTINGS sets it. A frame that differs only under a tool is this.
Announcements and signals
aria_alert (assertive) and aria_status (polite) are aria.ts alert and status. They store the message with a counter; aria_live_region, one element in the root that Workbench renders (an editor window drawn by app/src/workbench/auxiliary_windows.rs has none), turns each into a synthetic Status node whose id comes from the counter, so the same message twice is read twice. Any code with a Workbench announces through these two functions. A second live region would compete with the first.
play_signal is playSignal: the announcement through aria_alert, the sound through SoundPlayer, each when is_enabled says so for its modality. The editor's line and position signals (editorTextPropertySignalsContribution.ts) are the table TEXT_PROPERTIES; a new text property is a row there, not a new caller.
GPUI has no focusable synthetic node, so a feature that upstream implements by focusing a hidden aria element announces through the live region instead (app/src/workbench/inlay_hints_accessibility.rs, listed with the accepted differences in port/notes.md).
Accessible view and accessibility help
One widget serves both: Alt+F1 shows help, Alt+F2 shows content. Provider in app/src/workbench/accessible_view.rs lists the providers and Provider::id gives upstream's AccessibleViewProviderId; accessible_view_content holds the one match that produces each provider's text, and the command handlers in register_accessible_view_actions check the providers' conditions in a fixed order and take the first that holds. Upstream orders its MultiCommand implementations by priority; the port's order differs from it (hover help before terminal help, notification and terminal before the hover view). A new provider is a variant, an arm in that match, an arm in Provider::id and verbosity_key, and a place in that order.
Help text names keys as <keybinding:command.id>. resolve_keybindings replaces each with the aria label of the current binding (app/src/keybindings.rs::aria_label) or lists the command as unassigned. Write the command id, never a key name, so a user's rebinding is read correctly.
Invariant: accessible_view_key runs before the keybindings (app/src/workbench/keyboard.rs::dispatch_key), as the view's editor gets onKeyDown before the window listener upstream. A key it returns false for reaches the keybindings; the context keys of accessible_view_context gate those.
The view keeps its own cursor and selection and is drawn by accessible_view_widget. With accessibility.hideAccessibleView it is moved off screen, not removed, so the screen reader still reads it.
Keyboard and focus
Everything a mouse can do, a key can do. The general rules are in ARCHITECTURE.md ("Focus") and workbench.md ("Keys, commands, context keys, menus"). The accessibility part:
- Each part is reachable with F6 (
app/src/workbench/part_navigation.rs::FocusPart) and with Tab in upstream's DOM order. - An action bar is one tab stop (roving tabindex). Its container goes through
app/src/workbench/action_bar.rs::action_bar, which handles the arrow, Home and End keys, and its items throughaction_bar_item, which gives the item its focus handle and the 1pxfocusBorderoutline. Enter and Space reach the focused item's ownon_click. A hand-made row of icon buttons has none of these. - A focused element shows it: the
focusBordercolor, as upstream's CSS for that widget. - Tab types a tab in the editor and the terminal until Toggle Tab Key Moves Focus (
editor.tabFocusMode, theeditorTabMovesFocuscontext key). A new text surface that captures Tab honorsapp/src/workbench/editor_status.rs::tab_focus_mode. - A popup (menu, dialog, hover, accessible view) returns the focus to where it came from when it closes, as
hide_accessible_viewdoes per provider. - An animation checks
is_motion_reduced(workbench.reduceMotion, the OS setting onauto).
High Contrast
app/src/theme.rs::ThemeKind has HighContrastDark and HighContrastLight; is_high_contrast stands for upstream's .hc-black and .hc-light CSS rules. The color registry in app/src/theme.rs holds a default per kind, and in High Contrast most borders come from contrastBorder and contrastActiveBorder, which the other kinds leave unset.
Invariant: a view draws a border, outline or background by registry key and draws nothing when the key is unset. A hard-coded color, or a fallback for an unset key, breaks High Contrast in one of two ways: the outline is missing, or a fill hides the text. Rules that upstream writes only for .hc-black are an is_high_contrast branch, as high_contrast_list_outline in app/src/workbench.rs.
host_color_scheme reads the system's dark appearance and Increase Contrast; color_theme_setting_id picks the preferred High Contrast theme setting when window.autoDetectHighContrast is on (themeConfiguration.ts). Only the macOS variant reads the contrast setting. Dotted borders draw dashed (accepted GPUI limit, port/notes.md).
What a new view provides
- Every interactive element has an id, a role and an
aria_labelthat matches upstream'saria-labelor the visible text. An icon-only button has no visible text: its label is its title. - State is on the node: selected, expanded, checked, level, value, where upstream sets the
aria-*attribute. - A list or tree: the container has
Role::ListorRole::Treeand a label, rowsListItemorTreeItem, the focused rowaria_active_descendant. - Each action works from the keyboard, the element is a tab stop or part of a roving one, and its focus is visible.
- A change the user cannot see from where the focus is (a result count, a completed step, an error) goes to
aria_alertoraria_statuswhere upstream callsalertorstatus. - Colors come from registry keys and the view is checked in a High Contrast theme.
- A view with upstream accessibility help or an accessible view gets a
Provider.
Check a change
port/tools/cargo-test -p app accessible_view: Alt+F1 and Alt+F2 providers, keys, keybinding resolution.port/tools/cargo-test -p app accessibility: the screen reader page, line and position signals,is_enabled, the sound files, inlay hint reading.port/tools/cargo-test -p app accessible_buffer: the terminal's lines.port/tools/cargo-test -p app part_navigationandport/tools/cargo-test -p app in_tab_focus_mode: F6, Tab order, Tab leaving the editor and the terminal.port/tools/cargo-test -p app the_host_color_scheme_picks_the_preferred_theme_setting: High Contrast detection.port/tools/studio --lane 'port/tools/a11y-check': what VoiceOver reads. It dumps the window's AX tree after each step and fails when the Explorer tree, its rows, the editor text area or the help text are missing. Run it withREF_APP=1to see the reference's tree: that run skips the help step and asserts nothing. A new view with roles gets its assertion here.port/tools/ui-pairwithport/fixtures/ui-steps/screen-reader-detection.jsonandSETTINGS='{"editor.accessibilitySupport":"auto"}': the detection prompt and status entry beside the reference.THEMES="hc hclight" port/tools/pixel-checkfor a change to a border or focus outline.