Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

When running in portable mode (VSCODE_PORTABLE env var set), the Windows protocol handler registration causes OAuth redirects to launch VS Code in non-portable mode, storing authentication tokens outside the portable directory.

Changes

  • Added isPortable property to IEnvironmentMainService: Checks VSCODE_PORTABLE environment variable
  • Modified ElectronURLListener: Skip app.setAsDefaultProtocolClient() on Windows when isPortable is true
  • Added unit tests: Verify isPortable detection behavior

Impact

Protocol handler-based OAuth flows will fail in portable mode. Users can use the fallback local server OAuth method instead.

Original prompt

This section details on the original issue you should resolve

<issue_title>Do not register a protocol handler in portable mode</issue_title>
<issue_description>

  • Does this issue occur when all extensions are disabled?: Yes
  • VS Code Version: 1.96.4
  • OS Version: x64 10.0.19045

Steps to Reproduce:

  1. Run VS Code in portable mode (set VSCODE_PORTABLE env var to a custom path).
  2. View Computer\HKEY_CLASSES_ROOT\vscode. Observe that the configured command in shell\open\command does not preserve portable mode.
  3. Alternatively, try authenticating with GitHub (or another service that uses OAuth with the protocol handler). Observe that after you authenticate in your browser, VS Code is launched in non-portable mode (so that auth token will not be stored in the portable config).

Possible solutions:

  1. Skip registering the protocol handler when portable mode is active. This means that authentication flows that rely on the protocol handler will fail (but the user can use the fallback oauth method by using a local server).
  2. Store arguments and environment variables used to configure the main VS Code instance somewhere and when invoking VS Code again through a protocol handler, restore them, so that portable mode works properly. It would be courteous toward the user to remove the protocol handler when VS Code exits, so that it does not leave random garbage on the machine when running in portable mode.

The handler is installed here during VS Code startup:

if (isWindows) {
const windowsParameters = environmentMainService.isBuilt ? [] : [`"${environmentMainService.appRoot}"`];
windowsParameters.push('--open-url', '--');
app.setAsDefaultProtocolClient(productService.urlProtocol, process.execPath, windowsParameters);
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix issue with protocol handler in portable mode Do not register protocol handler in portable mode Dec 9, 2025
Copilot AI requested a review from joaomoreno December 9, 2025 17:01
@joaomoreno joaomoreno added this to the January 2026 milestone Jan 8, 2026
@dmitrivMS dmitrivMS self-assigned this Jan 9, 2026
@dmitrivMS
Copy link
Contributor

Will use new PR here 287063

@dmitrivMS dmitrivMS closed this Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not register a protocol handler in portable mode

3 participants