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
This commit is contained in:
Anthony Kim
2025-11-20 10:55:04 -08:00
committed by GitHub
parent 5e820f14c2
commit a745d810f5

View File

@@ -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