Skip to content

Commit 62c69b3

Browse files
authored
Merge pull request #117972 from microsoft/tyriar/r_1_54_remote_reconnect
Fix remote terminal reconnect
2 parents e798986 + 564f391 commit 62c69b3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ export class RemoteTerminalProcess extends Disposable implements ITerminalChildP
104104

105105
private _startBarrier: Barrier;
106106
private _persistentTerminalId: number;
107+
public get id(): number { return this._persistentTerminalId; }
107108

108109
private _inReplay = false;
109110

110111
constructor(
111-
readonly id: number,
112+
private readonly _instanceId: number,
112113
readonly shouldPersist: boolean,
113114
private readonly _shellLaunchConfig: IShellLaunchConfig,
114115
private readonly _activeWorkspaceRootUri: URI | undefined,
@@ -151,7 +152,7 @@ export class RemoteTerminalProcess extends Disposable implements ITerminalChildP
151152
env: this._shellLaunchConfig.env
152153
};
153154

154-
this._logService.trace('Spawning remote agent process', { terminalId: this.id, shellLaunchConfigDto });
155+
this._logService.trace('Spawning remote agent process', { terminalId: this._instanceId, shellLaunchConfigDto });
155156

156157
const result = await this._remoteTerminalChannel.createTerminalProcess(
157158
shellLaunchConfigDto,

src/vs/workbench/contrib/terminal/browser/terminalService.ts

+3
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ export class TerminalService implements ITerminalService {
236236
this.onActiveTabChanged(() => isRemote ? this._updateRemoteState() : this._updateLocalState());
237237
this.onActiveInstanceChanged(() => isRemote ? this._updateRemoteState() : this._updateLocalState());
238238
this.onInstancesChanged(() => isRemote ? this._updateRemoteState() : this._updateLocalState());
239+
// The state must be updated when the terminal is relaunched, otherwise the persistent
240+
// terminal ID will be stale and the process will be leaked.
241+
this.onInstanceProcessIdReady(() => isRemote ? this._updateRemoteState() : this._updateLocalState());
239242
}
240243

241244
public setNativeWindowsDelegate(delegate: ITerminalNativeWindowsDelegate): void {

src/vs/workbench/contrib/terminal/browser/terminalTab.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class TerminalTab extends Disposable implements ITerminalTab {
307307
terminals: instances.map(t => {
308308
return {
309309
relativeSize: isHorizontal ? t.cols / totalSize : t.rows / totalSize,
310-
terminal: t.persistentTerminalId ? t.persistentTerminalId : t.id
310+
terminal: t.persistentTerminalId || 0
311311
};
312312
})
313313
};

0 commit comments

Comments
 (0)