From a745d810f5e05702b62fe7ee7d33ff9020df87d7 Mon Sep 17 00:00:00 2001 From: Anthony Kim <62267334+anthonykim1@users.noreply.github.com> Date: Thu, 20 Nov 2025 10:55:04 -0800 Subject: [PATCH] Fix issue where local terminal failed to open in remote scenarios wsl (#277920) * try adding options.remoteAuthority field for profile * try explicit remoteAuthority undefined when local * Dont touch terminalProfileResolverService.ts * Better comments to explicitly get local default profile in remote * Try to handle mac -> linux scenario * see if caching is problem * Dont mix up profile and skip list when creating local terminal in remote * Just handle wsl in this PR to make life simpler * Logs for debugging * Allow local to get backend by checking from createTerminal in terminalService.ts * leave logs to debug, code doesnt work after prev commit * stringify for better logs. isLocalRemoteTerminal value is still false * more and more logs * Bug fixed) Use Schemas.file instead of Shemas.vscodeFileResource --- .../contrib/terminal/browser/terminalService.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 44ad6e6d2af..f741b47daa7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -975,9 +975,9 @@ export class TerminalService extends Disposable implements ITerminalService { // Await the initialization of available profiles as long as this is not a pty terminal or a // local terminal in a remote workspace as profile won't be used in those cases and these // terminals need to be launched before remote connections are established. + const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.file; if (this._terminalProfileService.availableProfiles.length === 0) { const isPtyTerminal = options?.config && hasKey(options.config, { customPtyImplementation: true }); - const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource; if (!isPtyTerminal && !isLocalInRemoteTerminal) { if (this._connectionState === TerminalConnectionState.Connecting) { mark(`code/terminal/willGetProfiles`); @@ -989,7 +989,18 @@ export class TerminalService extends Disposable implements ITerminalService { } } - const config = options?.config || this._terminalProfileService.getDefaultProfile(); + let config = options?.config; + if (!config && isLocalInRemoteTerminal) { + const backend = await this._terminalInstanceService.getBackend(undefined); + const executable = await backend?.getDefaultSystemShell(); + if (executable) { + config = { executable }; + } + } + + if (!config) { + config = this._terminalProfileService.getDefaultProfile(); + } const shellLaunchConfig = config && hasKey(config, { extensionIdentifier: true }) ? {} : this._terminalInstanceService.convertProfileToShellLaunchConfig(config || {}); // Get the contributed profile if it was provided