Skip to content

Commit 364247d

Browse files
authored
disable task reconnection by default (microsoft#156217)
1 parent fbdc848 commit 364247d

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
340340
processContext.set(process && !isVirtual);
341341
}
342342
this._onDidRegisterSupportedExecutions.fire();
343-
if (this._jsonTasksSupported && !this._tasksReconnected) {
343+
if (this._configurationService.getValue(TaskSettingId.Reconnection) === true && this._jsonTasksSupported && !this._tasksReconnected) {
344344
this._reconnectTasks();
345345
}
346346
}

src/vs/workbench/contrib/tasks/browser/task.contribution.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,12 @@ configurationRegistry.registerConfiguration({
513513
description: nls.localize('task.showDecorations', "Shows decorations at points of interest in the terminal buffer such as the first problem found via a watch task. Note that this will only take effect for future tasks."),
514514
default: true
515515
},
516+
[TaskSettingId.Reconnection]: {
517+
type: 'boolean',
518+
description: nls.localize('task.experimental.reconnection', "On window reload, reconnect to running watch/background tasks. Note that this is experimental, so you could encounter issues."),
519+
default: false,
520+
tags: ['experimental']
521+
},
516522
[TaskSettingId.SaveBeforeRun]: {
517523
markdownDescription: nls.localize(
518524
'task.saveBeforeRun',

src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,6 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
959959
this._fireTaskEvent(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!));
960960
processStartedSignaled = true;
961961
}
962-
963962
this._fireTaskEvent(TaskEvent.create(TaskEventKind.ProcessEnded, task, exitCode ?? undefined));
964963

965964
for (let i = 0; i < eventCounter; i++) {

src/vs/workbench/contrib/tasks/common/tasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,8 @@ export const enum TaskSettingId {
12011201
QuickOpenDetail = 'task.quickOpen.detail',
12021202
QuickOpenSkip = 'task.quickOpen.skip',
12031203
QuickOpenShowAll = 'task.quickOpen.showAll',
1204-
AllowAutomaticTasks = 'task.allowAutomaticTasks'
1204+
AllowAutomaticTasks = 'task.allowAutomaticTasks',
1205+
Reconnection = 'task.experimental.reconnection'
12051206
}
12061207

12071208
export const enum TasksSchemaProperties {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
8787
import { IGenericMarkProperties } from 'vs/platform/terminal/common/terminalProcess';
8888
import { ICommandService } from 'vs/platform/commands/common/commands';
8989
import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry';
90+
import { TaskSettingId } from 'vs/workbench/contrib/tasks/common/tasks';
9091

9192
const enum Constants {
9293
/**
@@ -695,7 +696,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
695696
this._shutdownPersistentProcessId = shutdownPersistentProcessId;
696697
}
697698
get persistentProcessId(): number | undefined { return this._processManager.persistentProcessId ?? this._shutdownPersistentProcessId; }
698-
get shouldPersist(): boolean { return (this._processManager.shouldPersist || this._shutdownPersistentProcessId !== undefined) && !this.shellLaunchConfig.isTransient; }
699+
get shouldPersist(): boolean { return (this._processManager.shouldPersist || this._shutdownPersistentProcessId !== undefined) && !this.shellLaunchConfig.isTransient && (!this.reconnectionOwner || this._configurationService.getValue(TaskSettingId.Reconnection) === true); }
699700

700701
/**
701702
* Create xterm.js instance and attach data listeners.
@@ -2386,12 +2387,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
23862387
}
23872388

23882389
// Recreate the process if the terminal has not yet been interacted with and it's not a
2389-
// special terminal (eg. task, extension terminal)
2390+
// special terminal (eg. extension terminal)
23902391
if (
23912392
info.requiresAction &&
23922393
this._configHelper.config.environmentChangesRelaunch &&
23932394
!this._processManager.hasWrittenData &&
2394-
(this.reconnectionOwner || !this._shellLaunchConfig.isFeatureTerminal) &&
2395+
(!this._shellLaunchConfig.isFeatureTerminal || (this.reconnectionOwner && this._configurationService.getValue(TaskSettingId.Reconnection) === true)) &&
23952396
!this._shellLaunchConfig.customPtyImplementation
23962397
&& !this._shellLaunchConfig.isExtensionOwnedTerminal &&
23972398
!this._shellLaunchConfig.attachPersistentProcess

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
3636
import { IHistoryService } from 'vs/workbench/services/history/common/history';
3737
import { IPathService } from 'vs/workbench/services/path/common/pathService';
3838
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
39+
import { TaskSettingId } from 'vs/workbench/contrib/tasks/common/tasks';
3940

4041
/** The amount of time to consider terminal errors to be related to the launch */
4142
const LAUNCHING_DURATION = 500;
@@ -245,8 +246,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
245246

246247
// this is a copy of what the merged environment collection is on the remote side
247248
const env = await this._resolveEnvironment(backend, variableResolver, shellLaunchConfig);
248-
249-
const shouldPersist = (!!shellLaunchConfig.reconnectionOwner || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
249+
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionOwner) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
250250
if (shellLaunchConfig.attachPersistentProcess) {
251251
const result = await backend.attachToProcess(shellLaunchConfig.attachPersistentProcess.id);
252252
if (result) {
@@ -318,7 +318,6 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
318318
}
319319

320320
this._process = newProcess;
321-
322321
this._setProcessState(ProcessState.Launching);
323322

324323
// Add any capabilities inherit to the backend
@@ -461,7 +460,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
461460
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled,
462461
environmentVariableCollections: this._extEnvironmentVariableCollection ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined
463462
};
464-
const shouldPersist = this._configHelper.config.enablePersistentSessions && (!!this.reconnectionOwner || !shellLaunchConfig.isFeatureTerminal);
463+
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionOwner) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
465464
return await backend.createProcess(shellLaunchConfig, initialCwd, cols, rows, this._configHelper.config.unicodeVersion, env, options, shouldPersist);
466465
}
467466

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export class TerminalService implements ITerminalService {
175175
// we update detected profiles when an instance is created so that,
176176
// for example, we detect if you've installed a pwsh
177177
this.onDidCreateInstance(() => this._terminalProfileService.refreshAvailableProfiles());
178-
179178
this._forwardInstanceHostEvents(this._terminalGroupService);
180179
this._forwardInstanceHostEvents(this._terminalEditorService);
181180
this._terminalGroupService.onDidChangeActiveGroup(this._onDidChangeActiveGroup.fire, this._onDidChangeActiveGroup);

0 commit comments

Comments
 (0)