Repository navigation
Make the restricted-mode lock icon a keyboard-reachable button - #19808
Conversation
The lock was a div with a click handler: not a Tab or arrow-key stop in the main toolbar, and announced only by its title. It is now a native button named "Restricted Mode: review project trust", keeping the title as its description. The 0.7 opacity moves from the button to its SVG so the focus ring isn't dimmed. Addresses #19801.
Reopening the trust dialog from the lock icon used the trust request from session startup. After declining an undecided project, it still showed "Do you trust this project?" instead of "This project is restricted". A successful revoke now records the untrusted status, and deferred init refreshes the cached trust request after a restart. Addresses #19801.
Workbench already merges deferred-init data into SessionInfo, so the
setTrustRequest call in TrustPresenter.onDeferredInitCompleted did
nothing. That merge also replaced the recorded decline with the
server's startup status ("unknown"; revokeTrust doesn't update it)
when the user declined before deferred init arrived. The presenter
now keeps the decline itself and passes it to the dialog opened from
the lock icon. lastTrustStatus_ still tracks the server's status, so
a late deferred init doesn't reopen the dialog.
Addresses #19801.
|
Review findings I chose not to act on: From a Claude Code
From roborev:
Two other findings were fixed on this branch: reopening the dialog after a decline used the startup status (ae0d072), and a decline made before deferred init was overwritten by it (8bf7d9c). |
gtritchie
left a comment
There was a problem hiding this comment.
Four findings: two minor issues with the new trustDeclined_ flag, and two pre-existing issues. Nothing blocking. The button conversion, its accessible name, the 24px target, and toolbar arrow-key navigation look correct.
| @Override | ||
| public void onResponseReceived(VoidResponse response) | ||
| { | ||
| trustDeclined_ = true; |
There was a problem hiding this comment.
trustDeclined_ is set only when the revoke_trust response comes back, but by then the dialog has closed and focus is back on the lock. If the lock is activated before the response arrives (for example, Enter held down on "Don't trust": Enter clicks a native button and auto-repeats), the dialog reopens asking "Do you trust this project?". The window is short. Setting the flag when the decline is chosen, before calling revokeTrust, and clearing it in onError would close it.
There was a problem hiding this comment.
Fixed in 8bba893: trustDeclined_ is now set when the decline is chosen, before revokeTrust, and cleared in onError. Tested on a dev server by clicking the lock right after "No", before the response came back. The dialog showed "This project is restricted".
|
|
||
| // The server's trust request keeps the status this session started with, | ||
| // so a decline is remembered here for reopening the dialog from the lock. | ||
| private boolean trustDeclined_; |
There was a problem hiding this comment.
Nothing clears trustDeclined_, and Restart R (ApplicationQuit.onRestartR fires SuspendAndRestartEvent) doesn't reload the page, so the flag can outlive the state it describes.
To reproduce: decline from the startup dialog, run .rs.trust.reset(), then Restart R. The new session reports unknown, and trustStatusChanged is false, so no dialog opens on its own. Clicking the lock shows the restricted variant, whose "Keep restricted" records nothing (TrustRequestDialog.java:226 skips dontTrustOperation_). Before this change the lock would have asked the undecided question.
It takes an internal function to trigger, so it's minor. Clearing the flag in onDeferredInitCompleted when a trust_request arrives would handle it, or see the comment on line 145.
There was a problem hiding this comment.
Leaving this one. It needs the internal .rs.trust.reset() (or a trust change from another session) followed by Restart R. The symptom is the restricted wording instead of the undecided one, and both dialogs still offer "Trust this project". Clearing the flag in onDeferredInitCompleted would bring back the race fixed in 8bf7d9c: a decline made before the same session's deferred init would be overwritten by its stale "unknown".
| @@ -139,7 +145,10 @@ void onShowTrustRequestDialog() | |||
| session_.getSessionInfo().getTrustRequest(); | |||
There was a problem hiding this comment.
Pre-existing, but it's the root cause behind #19801: the lock reads the trust request captured at page load (session info is set only in Application.java at startup), while onDeferredInitCompleted receives fresh trust_request data after every Restart R and uses it only for the automatic dialog.
trustDeclined_ covers declines made in this dialog, but not others. For example: open an undecided project, run .rs.trust.revoke() in the console (or decline from another session on the same project), then Restart R. The automatic dialog correctly says "This project is restricted". After "Keep restricted", clicking the lock asks "Do you trust this project?" again, and its risky-files list is also the one from page load.
Keeping the latest deferred-init trust_request and reading it here would fix both paths and make trustDeclined_ unnecessary.
There was a problem hiding this comment.
Session info is updated after a restart too. Workbench.onDeferredInitCompleted calls session_.updateSessionInfo(event.getData()), which Object.assigns each deferred-init payload into session info, trust_request (and its risky files) included. So the lock reads the latest session's trust request. I checked your example on a dev server. I opened an undecided project and dismissed its dialog with Escape, so no decline was recorded. Then I ran .rs.trust.revoke(); .rs.api.restartSession(). The page didn't reload. The automatic dialog said "This project is restricted", and so did the lock afterwards.
The gap trustDeclined_ covers is narrower: revokeTrust doesn't update the session's in-memory status, so session info keeps "unknown" until the next session's deferred init. No change here.
There was a problem hiding this comment.
You're right, I missed updateSessionInfo: Workbench.onDeferredInitCompleted merges each deferred-init payload into session info, so the lock reads the current session's trust request. Withdrawn; no change needed.
| trustOperation_ = trustOperation; | ||
| dontTrustOperation_ = dontTrustOperation; | ||
| isUntrusted_ = "untrusted".equals(status); | ||
| isUntrusted_ = TrustRequestEvent.STATUS_UNTRUSTED.equals(status); |
There was a problem hiding this comment.
Pre-existing: status_ (assigned at line 52, declared at line 281) is never read; only isUntrusted_ is used. It could go while you're in here.
Holding Enter on "No" could reopen the dialog from the lock before revoke_trust responded, so it asked "Do you trust this project?" again. The decline is now recorded when chosen and undone on error. Also removes TrustRequestDialog's unused status_ field. Addresses #19801.
RStudio E2E - all platformsAll tests passed!
All platforms - commit |
Fixes #19801.
The Restricted Mode lock icon in the main toolbar was a
<div>with a click handler. It wasn't a Tab or arrow-key stop, and screen readers announced only its title.<button>named "Restricted Mode: review project trust". Its existing title ("startup files were not executed for this project") becomes the button's description. The SVG isaria-hidden.TrustPresenternow remembers the decline and shows "This project is restricted" when the dialog is reopened.Tested in a dev server: the main toolbar's arrow keys reach the lock, Enter and Space open the dialog, and focus returns to the lock after "Keep restricted". Declining "Do you trust this project?" and then reopening from the lock shows "This project is restricted".