Skip to content

Conversation

@eneufeld
Copy link
Contributor

@eneufeld eneufeld commented Jan 9, 2026

What it does

Adds workspace trust functionality:

  • Trust dialog on folder open (respecting startupPrompt preference)
  • Trusted folders list preference for global trust decisions
  • Per-workspace trust storage for 'once' mode
  • Restricted Mode banner when workspace is untrusted
  • "Manage Workspace Trust" command to toggle trust state
  • onDidChangeWorkspaceTrust event for plugins

Plugin API:

  • Add onDidChangeWorkspaceTrust: Event to workspace namespace
  • Update workspace.ts and workspace-main.ts for RPC event flow

Preferences added:

  • security.workspace.trust.trustedFolders (string array)

Closes #16653

How to test

Open a new workspace after enabling workspace trust checks.
See a dialog pop up. Test that trusted workspaces don't show dialog anymore. Untrusted workspaces show a message.

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

Adds workspace trust functionality:
- Trust dialog on folder open (respecting startupPrompt preference)
- Trusted folders list preference for global trust decisions
- Per-workspace trust storage for 'once' mode
- Restricted Mode banner when workspace is untrusted
- "Manage Workspace Trust" command to toggle trust state
- onDidChangeWorkspaceTrust event for plugins

Plugin API:
- Add onDidChangeWorkspaceTrust: Event<boolean> to workspace namespace
- Update workspace.ts and workspace-main.ts for RPC event flow

Preferences added:
- security.workspace.trust.trustedFolders (string array)

Closes #16653
@eneufeld eneufeld requested a review from ndoschek January 9, 2026 11:00
@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Jan 9, 2026
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Hi @eneufeld, thanks for this improvement!

Unfortunately it does not work as expected for me. If I trust new folders, the decision is not saved, i.e., I cannot see it in the settings and hence I get prompted on each reload.
If I add the path manually via the settings UI it works, however only after a manual reload, it seems the manual settings change does not trigger the update listener.

Could you have a look if it behaves the same on your machine?

Besides that, I added a few minor comments inline, would be great if you could have a look. TIA!

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Waiting on author in PR Backlog Jan 12, 2026
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Thanks for the update Eugen!
It works much better now, but I still found a few cases which are not working correctly, yet.

  1. After hitting Yes, I trust the authors in the dialog, I still get the restricted mode popup which is incocrrect, as the trusted path has been saved to the settings alrleady.
    Also the additional notification from before keeps showing after I trust the workspace. Not sure if we should keep this at all? wdyt? In either case we should clear this popup if we trusted the workspace.
Image
  1. If i cancel the trust dialog, the restriced mode popup shows as expected. But then the "Manage Workspace Trust" does not work if I try to select trust, this does not update the settings accordingly.

  2. The dialog does not show for an empty window if the setting is disabled:

Image

Overall it looks good to me, it also works fine with the remaining settings 👍
Would be great if you could have another look, TIA!

@eneufeld
Copy link
Contributor Author

@ndoschek about The dialog does not show for an empty window if the setting is disabled:
So my understanding is:
emptyWindow: true → empty window trusted
emptyWindow: false → empty window in restricted mode

If we have an empty window we don't have a workspace that we can trust or not trust.
I fixed the issue of the dialog not showing on folder switch though.

@ndoschek
Copy link
Member

Hi @eneufeld, thank you for the updates!

About the emptyWindow setting: Ah that totally makes sense, thanks!
However unfortunately I always get the restricted popup independent of the setting (and it also does not listen to the setting change), could you have another look there please?

And unfortunately, point 1. from my previous comment is still not resolved for me:

  • After hitting Yes, I trust the authors in the dialog, I still get the restricted mode popup which is incorrect, as the trusted path has been saved to the settings correctly.
  • About the additional popup, I am not sure if we should keep that, if i cancel the new dialog for example and then hit yes in the popup nothing happens. I would suggest to remove the additional popup and integrate the info in the new dialog, WDYT?

And as mentioned above, the restricted popup does not listen to any settings change, either for the emptyWindow above. Also in this case: dismiss the dialog, restricted popup appears, executing the command and trust the workspace => the trust setting was updated for this folder, but the restricted popup is still showing and has to be dismissed manually. I think we should clear the restricted popup when the settings change.

Would be great if you could have another look.
Thanks for you patience with this, but if we can get these things fixed we should be good to get this merged, thanks!

@eneufeld eneufeld requested a review from ndoschek January 21, 2026 11:51
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Thanks @eneufeld this is a great improvement, and I think we are very close now.
I added a few comments inline, but nothing major.

Besides that one of my previous comments is still unresolved.
The notification we are now still getting is the one shown below, I would still be in favour of removing it, wdyt?
Also, the actions do not work properly, e.g. if I dismiss the main dialog and then click on yes in this notification the workspace is not trusted.

Image

Besides that, as discussed offline, I will work on the theme update soon and then we can also make use of the different styles for status bar items (there is a prominent styling for status bar items, which we should the pick for this item).
But I can take care of that in a follow up.

const items: QuickPickItem[] = [
{
label: trust,
description: currentTrust ? nls.localize('theia/workspace/currentTrustState', '(current)') : undefined
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
description: currentTrust ? nls.localize('theia/workspace/currentTrustState', '(current)') : undefined
const currentSuffix = `(${nls.localizeByDefault('current')})`,
...
description: currentTrust ? currentSuffix : undefined

And also for the item below

Copy link
Member

Choose a reason for hiding this comment

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

The test file creates emitters but doesn't dispose of them after tests complete. While this may not cause issues in isolated tests, it's good practice to clean up.

priority: 5000,
tooltip: nls.localize('theia/workspace/restrictedModeTooltip',
'Running in Restricted Mode. Some features are disabled because this folder is not trusted. Click to manage trust settings.'),
command: 'workspace:manageTrust'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
command: 'workspace:manageTrust'
command: MANAGE_WORKSPACE_TRUST.id

Comment on lines 199 to 204
return trustedFolders.some(folder => {
// Strip trailing slash from folder string before creating URI
const normalizedFolder = folder.endsWith('/') ? folder.slice(0, -1) : folder;
const folderUri = new URI(normalizedFolder);
return workspaceUri.isEqual(folderUri, caseSensitive);
});
Copy link
Member

Choose a reason for hiding this comment

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

Could we use URI's built-in normalization?

Suggested change
return trustedFolders.some(folder => {
// Strip trailing slash from folder string before creating URI
const normalizedFolder = folder.endsWith('/') ? folder.slice(0, -1) : folder;
const folderUri = new URI(normalizedFolder);
return workspaceUri.isEqual(folderUri, caseSensitive);
});
return trustedFolders.some(folder => {
try {
const folderUri = new URI(folder).normalizePath();
return workspaceUri.normalizePath().isEqual(folderUri, caseSensitive);
} catch {
return false; // Invalid URI in preferences
}
});

// React to trust changes
this.onDidChangeWorkspaceTrust(trust => {
this.updateRestrictedModeIndicator(trust);
});
Copy link
Member

Choose a reason for hiding this comment

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

This subscription should be ideally stored in a disposable collection, as we never dispose it., probably also for the other subscriptions above.

@eneufeld eneufeld requested a review from ndoschek January 22, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting on author

Development

Successfully merging this pull request may close these issues.

Dialog prompt for workspace trust on folder open

3 participants