Skip to content

Make Console error actions usable from the keyboard - #19741

Merged
gtritchie merged 12 commits into
mainfrom
bugfix/console-error-keyboard-access
Nov 19, 2026
Merged

gtritchie merged 12 commits into
mainfrom
bugfix/console-error-keyboard-access

Conversation

@gtritchie

@gtritchie gtritchie commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #19637.

On a Console error, "Show Traceback" and "Rerun with Debug", and the source file links in an expanded traceback, could only be used with the mouse. They were Anchors with no href, and the Console output sent nearly every keystroke to the Console input.

Changes

  • Buttons. Show Traceback, Rerun with Debug, and the traceback's source links are now <button>s, styled to look the same as before. Show Traceback sets aria-expanded. A frame with no source file no longer renders an empty link.
  • Focus Last Console Error (Help > Accessibility > Focus, and the Command Palette). Ctrl+Option+7 on macOS, Alt+Shift+7 on Windows and Linux. It moves focus to the most recent error's Show Traceback button.
    • If the Console is hidden (zoomed out or minimized), the command restores it first. It then waits until any pane animation has ended and the Console is no longer inert, because the end of an animation can move focus to the Console input.
    • If the error can already take focus, the command focuses it directly, so focus never passes through the input.
    • It announces when there is no error to focus, including when trimming old output has removed the error's buttons, and when focus could not be moved.
    • An error raised while the debugger is active is written without an error box. After one, the command announces "The most recent Console error has no actions" rather than focusing an older box. This lasts until a newer error gets a box or the Console is cleared. With On Error set to "Message only" or "Break in Code", errors send no event to the client, so the command can still reach an older box.
  • Keys on an output button. Enter, Space, Tab, and Shift+Tab now act on the button. Escape returns to the Console input without clearing what's typed there. Other keys still go to the input. A mouse click still returns focus to the input; a keyboard activation leaves focus on the button.
  • Focus ring. The buttons go to full opacity and show the app-wide outline on :focus, not just :focus-visible. When the command is chosen from a menu with the mouse, the browser doesn't count the focus that follows as :focus-visible.
  • Tooltip. The buttons' tooltip, which screen readers also read as the description, names the shortcut. It is left out if the command has no shortcut.
  • DualWindowLayoutPanel.isAnimating() exposes the rstudio-animating body class that AnimationHelper already sets. The class name is now a shared constant.

Shortcut choice

The shortcut follows the Ctrl+Option / Alt+Shift pair used by the other accessibility focus commands, such as Focus Console Output (Ctrl+Option+2 / Alt+Shift+2). Every free letter in that pair conflicts with a VoiceOver command (Ctrl+Option is VoiceOver's modifier), for example VO-W reads the current word. 7 conflicts only with VoiceOver hot spot 7, which a user has to set up first. Focus Console Output's 2 has the same hot-spot conflict. Every Cmd/Ctrl+Shift letter not already used by RStudio conflicts with a browser or OS shortcut.

Tests

Playwright, in e2e/rstudio/tests/panes/console/console_pane.test.ts:

  • Keyboard path: shortcut, Escape (the input keeps its text), shortcut, Enter (expands the traceback without running the input), Tab to Rerun, Tab to a source link, Enter (opens the file).
  • A visible error is focused without focus passing through the input.
  • After a mouse click, running the command still shows full opacity and an outline.
  • An error raised at a browser() prompt makes the command announce that the newest error has no actions, instead of focusing the older box.
  • The no-error announcement, and the announcement after trimming removed the error's buttons.
  • Bringing a hidden Console forward: zoomed out, minimized, and minimized while alone in its pane, each with animations on and off. Each case checks that focus stays on the button for 1s afterwards.

Ran tests/panes/console/ and tests/panes/layout/tabs.test.ts on a macOS desktop dev build: 115 passed.

Not tested:

  • Alt+Shift+7 on Windows and Linux.
  • Rerun with Debug and Space activation from the keyboard. They go through the same native button click as Enter.
  • Notebook chunk errors. They use the same widget, so they get the buttons, but the command only targets the Console.
  • The two give-up announcements (the error disappears during the retry, or the 2s retry times out). The e2e tests have no way to force either.

Show Traceback, Rerun with Debug, and the traceback's source file links
are now buttons, and Show Traceback reports aria-expanded. The new Focus
Last Console Error command (Ctrl+Option+7 on macOS, Alt+Shift+7
elsewhere) moves focus to the most recent error's Show Traceback button,
showing the Console first if it is hidden, and announces when there is
no error. The shortcut appears in the buttons' tooltip.

The Console output used to send every key to the input. On a button in
the output, Enter, Space, and Tab now act on the button, and Escape
returns to the input without clearing it.

Addresses #19637.
Focus Last Console Error focused the error once, on the next event loop
turn. When the Console was hidden by a column zoom and animations were
on, its column was still inert then, so focus never reached the error.
It now retries until the error can take focus, for up to 2 seconds.

The hidden-Console test now runs with animations on and off, for both a
zoomed-out and a minimized Console, and checks that focus stays put
after the restore.

Addresses #19637.
Trimming old Console output can remove an error's buttons while leaving
part of its message. The command then tried to focus a removed button
and did nothing. It now treats such an error as gone and announces
that there is no error to focus.

Addresses #19637.
When the Console is alone in its pane (no Terminal or Background Jobs
tab), restoring it from minimized ends with the animation focusing the
Console input. Focus Last Console Error could focus the error before
that and lose it about 200ms later. It now also waits until no pane is
animating, using a new DualWindowLayoutPanel.isAnimating() check. That
check reads the same body class AnimationHelper sets, now shared as a
constant.

The hidden-Console tests gain the Console-alone case, with animations on
and off, closing the neighboring tabs and restoring them afterwards.

Addresses #19637.
The Console-alone focus tests closed the Terminal and Background Jobs
tabs before their try block, so a failure in the setup that followed
skipped the restore and left later specs without those tabs. The setup
now runs inside the try.

Also wraps lines this branch added over 100 characters in the Console
spec and ConsoleError.ui.xml.

Addresses #19637.
Focus Last Console Error always activated the Console first, which
focuses its input and scrolls the output to the bottom; the error took
focus 50ms later and the output scrolled back. A screen reader could
start reading the input in between. When the error can already take
focus, the command now focuses it directly, and activates the Console
only when it has to.

The hidden-Console tests now wait for a zoomed-out column to finish
collapsing before pressing the shortcut. Until then the error is still
focusable, and the command takes the direct path.

Addresses #19637.
When the Console was hidden, the command activated it and retried
focusing the error, but stopped silently if the error disappeared
during the retry or could not take focus within 2 seconds. Focus was
left in the Console input with no indication that the command failed.
It now announces "No Console error to focus" or "Could not move focus
to the Console error".

Addresses #19637.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three findings: one correctness, one accessibility (plausible, not checked in a browser), one reuse.

.focusLastConsoleError().getShortcutPrettyHtml();
if (!StringUtil.isNullOrEmpty(shortcut))
errorWidget.setFocusShortcutHint(DomUtils.htmlToText(shortcut));
lastError_ = errorWidget;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastError_ is only set for errors that get an error box, so when the newest error has none, Focus Last Console Error goes to an older box.

Shell.onUnhandledError skips consoleWriteExtendedError while debugging_ is true (Shell.java:451), so an error raised while stopped at browser() stays plain text. For example: run f() so it errors with a box, then hit an error in the debugger. The command focuses f()'s box, and Rerun with Debug there reruns the old command. The same happens after switching On Error to "Message only" mid-session.

One option: clear lastError_ in consoleWriteError when the error isn't later upgraded to a box. Another: announce that the most recent error has no actions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7b6789 and c6798aa. Clearing lastError_ in consoleWriteError would also catch message() and warning(), since that path handles all stderr. Instead, Shell.onUnhandledError marks the newest error as having no box when it skips one because debugging_ is set. The command then announces "The most recent Console error has no actions" instead of focusing the older box. "Message only" and "Break in Code" errors send no event, so they aren't covered. The box that is reached is still a real error, and its Rerun with Debug reruns that error's own command.


.errorCommandText:hover {
.errorCommandText:hover,
.errorCommandText:focus-visible {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only :focus-visible brings the button to full opacity, and nothing in RStudio's CSS styles button focus otherwise. When the command is run with the mouse (Server: Help > Accessibility > Focus > Focus Last Console Error), Chrome's heuristic may not match :focus-visible for the script focus that follows a click. The focused button would then stay at 50% opacity with no outline (WCAG 2.4.7).

I haven't checked this in a browser. If it reproduces, using :focus for the opacity rule (or adding an outline under :focus) would cover it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed in a browser and fixed in 7354ba0. Opacity and the app-wide outline now apply on :focus. By default a mouse click on these buttons returns focus to the input immediately, so the ring doesn't show then. With "Double click to select in the Console" on, it can show for up to 400ms. A new e2e test runs the command after a mouse click and checks opacity and outline.

return container.isOrHasChild(showTracebackText.getElement());
}

private static native boolean isInert(Element el) /*-{

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates A11y.isInert() (core/client/a11y/A11y.java:154), which has the same closest("[inert]") body. Suggest calling A11y.isInert(button) and deleting this method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in de3dfc4: now calls A11y.isInert.

ConsoleError had its own copy of the same closest("[inert]") check.

Addresses #19637.
The error box's buttons showed full opacity and the app-wide outline
only under :focus-visible. When Focus Last Console Error was chosen
with the mouse (e.g. from the Help menu on Server), the browser didn't
count the resulting focus as :focus-visible, so the focused button
stayed at 50% opacity with no outline. Both now apply under :focus.

A mouse click on these buttons returns focus to the Console input
straight away, so the ring doesn't flash there.

Addresses #19637.
An error raised while the debugger is active is written as plain text
with no error box. Focus Last Console Error still focused the previous
box, so a screen reader user could act on an older error believing it
was the latest. The Console now records that the newest error has no
box. The command announces "The most recent Console error has no
actions" until a newer error gets a box or the Console is cleared.

Errors written with On Error set to "Message only" or "Break in Code"
send no event to the client, so they aren't covered.

Addresses #19637.
When the Console had to be shown first, an error box that disappeared
during the retry was always announced as "No Console error to focus",
even when the newest error was a debugger error with no box. Both
paths now choose the announcement the same way.

Addresses #19637.
@gtritchie

Copy link
Copy Markdown
Member Author

Re-review of the five new commits: all three findings are addressed.

  • Older error box: an error raised in the debugger now clears the remembered error box, and the command announces that the most recent error has no actions. Clearing the Console resets it too, and the new e2e test covers the debugger case. Not covered: switching On Error to "Message only" or "Break in Code" mid-session sends no error report, so an older box can still be focused. That's rare and minor, so fine to leave.
  • Focus ring: the opacity and outline now apply on any :focus, matching the outline in focus-visible.css. The test checks the case where focus isn't :focus-visible.
  • isInert: now uses A11y.isInert.

Reviewed by reading the code; not built or run.

@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
5795 1 265 2
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1453 0 49 0
❌ desktop-macos 1448 1 54 0
✅ desktop-windows 1447 0 60 1
✅ server-linux 1395 0 54 1
✅ setup 48 0 32 0

View report online


All platforms - commit c6798aa8b73b5aba349a79190d0ee10821cd8af5 - Run #2401

@gtritchie
gtritchie merged commit 64de77b into main Nov 19, 2026
50 of 51 checks passed
@gtritchie
gtritchie deleted the bugfix/console-error-keyboard-access branch November 19, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console error "Show Traceback" and "Rerun with Debug" links can't be used from the keyboard

1 participant