task & reconnectionOwner -> reconnectionProperties (#156926)

This commit is contained in:
Megan Rogge
2022-08-03 15:58:10 -07:00
committed by GitHub
parent 43d0df37af
commit 1c02bdda63
9 changed files with 35 additions and 39 deletions

View File

@@ -168,14 +168,20 @@ export interface IPtyHostAttachTarget {
icon: TerminalIcon | undefined;
fixedDimensions: IFixedTerminalDimensions | undefined;
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
reconnectionOwner?: string;
task?: { label: string; id: string; lastTask: string; group?: string };
reconnectionProperties?: IReconnectionProperties;
waitOnExit?: WaitOnExitValue;
hideFromUser?: boolean;
isFeatureTerminal?: boolean;
type?: TerminalType;
}
export interface IReconnectionProperties {
ownerId: string;
data?: unknown;
}
export interface IReconnectionTaskData { label: string; id: string; lastTask: string; group?: string }
export type TerminalType = 'Task' | 'Local' | undefined;
export enum TitleEventSource {
@@ -448,9 +454,9 @@ export interface IShellLaunchConfig {
ignoreConfigurationCwd?: boolean;
/**
* The owner of this terminal for reconnection.
* The reconnection properties for this terminal
*/
reconnectionOwner?: string;
reconnectionProperties?: IReconnectionProperties;
/** Whether to wait for a key press before closing the terminal. */
waitOnExit?: WaitOnExitValue;
@@ -477,7 +483,7 @@ export interface IShellLaunchConfig {
* This is a terminal that attaches to an already running terminal.
*/
attachPersistentProcess?: {
id: number; findRevivedId?: boolean; pid: number; title: string; titleSource: TitleEventSource; cwd: string; icon?: TerminalIcon; color?: string; hasChildProcesses?: boolean; fixedDimensions?: IFixedTerminalDimensions; environmentVariableCollections?: ISerializableEnvironmentVariableCollections; reconnectionOwner?: string; task?: { label: string; id: string; lastTask: string; group?: string }; type?: TerminalType; waitOnExit?: WaitOnExitValue; hideFromUser?: boolean; isFeatureTerminal?: boolean;
id: number; findRevivedId?: boolean; pid: number; title: string; titleSource: TitleEventSource; cwd: string; icon?: TerminalIcon; color?: string; hasChildProcesses?: boolean; fixedDimensions?: IFixedTerminalDimensions; environmentVariableCollections?: ISerializableEnvironmentVariableCollections; reconnectionProperties?: IReconnectionProperties; type?: TerminalType; waitOnExit?: WaitOnExitValue; hideFromUser?: boolean; isFeatureTerminal?: boolean;
};
/**
@@ -549,11 +555,6 @@ export interface IShellLaunchConfig {
* Create a terminal without shell integration even when it's enabled
*/
ignoreShellIntegration?: boolean;
/**
* The task associated with this terminal
*/
task?: { label: string; id: string; lastTask: string; group?: string };
}
export type WaitOnExitValue = boolean | string | ((exitCode: number) => string);

View File

@@ -5,7 +5,7 @@
import { UriComponents } from 'vs/base/common/uri';
import { ISerializableEnvironmentVariableCollection, ISerializableEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariable';
import { IFixedTerminalDimensions, IRawTerminalTabLayoutInfo, ITerminalEnvironment, ITerminalTabLayoutInfoById, TerminalIcon, TerminalType, TitleEventSource, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
import { IFixedTerminalDimensions, IRawTerminalTabLayoutInfo, IReconnectionProperties, ITerminalEnvironment, ITerminalTabLayoutInfoById, TerminalIcon, TerminalType, TitleEventSource, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
export interface ISingleTerminalConfiguration<T> {
userValue: T | undefined;
@@ -60,8 +60,7 @@ export interface IProcessDetails {
color: string | undefined;
fixedDimensions: IFixedTerminalDimensions | undefined;
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
reconnectionOwner?: string;
task?: { label: string; id: string; lastTask: string; group?: string };
reconnectionProperties?: IReconnectionProperties;
waitOnExit?: WaitOnExitValue;
hideFromUser?: boolean;
isFeatureTerminal?: boolean;

View File

@@ -410,8 +410,7 @@ export class PtyService extends Disposable implements IPtyService {
color: persistentProcess.color,
fixedDimensions: persistentProcess.fixedDimensions,
environmentVariableCollections: persistentProcess.processLaunchOptions.options.environmentVariableCollections,
reconnectionOwner: persistentProcess.shellLaunchConfig.reconnectionOwner,
task: persistentProcess.shellLaunchConfig.task,
reconnectionProperties: persistentProcess.shellLaunchConfig.reconnectionProperties,
waitOnExit: persistentProcess.shellLaunchConfig.waitOnExit,
hideFromUser: persistentProcess.shellLaunchConfig.hideFromUser,
isFeatureTerminal: persistentProcess.shellLaunchConfig.isFeatureTerminal,

View File

@@ -30,7 +30,7 @@ import { URI } from 'vs/base/common/uri';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IShellLaunchConfig, TerminalLocation, TerminalSettingId, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
import { IReconnectionTaskData, IShellLaunchConfig, TerminalLocation, TerminalSettingId, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { IViewDescriptorService, IViewsService, ViewContainerLocation } from 'vs/workbench/common/views';
@@ -1271,7 +1271,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
private async _reconnectToTerminal(task: Task): Promise<ITerminalInstance | undefined> {
for (let i = 0; i < this._reconnectTerminals.length; i++) {
const terminal = this._reconnectTerminals[i];
const taskForTerminal = terminal.shellLaunchConfig.attachPersistentProcess?.task;
const taskForTerminal = terminal.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties?.data as IReconnectionTaskData;
if (taskForTerminal?.id && task.getRecentlyUsedKey() === taskForTerminal.lastTask) {
this._reconnectTerminals.splice(i, 1);
return terminal;
@@ -1318,7 +1318,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
return;
}
for (const terminal of terminals) {
const task = terminal.shellLaunchConfig.attachPersistentProcess?.task;
const task = terminal.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties?.data as IReconnectionTaskData;
if (!task) {
continue;
}
@@ -1428,8 +1428,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
this._terminalCreationQueue = this._terminalCreationQueue.then(() => this._doCreateTerminal(task, group, launchConfigs!));
const terminal: ITerminalInstance = (await this._terminalCreationQueue)!;
terminal.shellLaunchConfig.task = { lastTask: task.getRecentlyUsedKey()!, group, label: task._label, id: task._id };
terminal.shellLaunchConfig.reconnectionOwner = ReconnectionType;
terminal.shellLaunchConfig.reconnectionProperties = { ownerId: ReconnectionType, data: { lastTask: taskKey, group, label: task._label, id: task._id } };
const terminalKey = terminal.instanceId.toString();
const terminalData = { terminal: terminal, lastTask: taskKey, group };
terminal.onDisposed(() => this._deleteTaskAndTerminal(terminal, terminalData));

View File

@@ -11,7 +11,7 @@ import { FindReplaceState } from 'vs/editor/contrib/find/browser/findState';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IKeyMods } from 'vs/platform/quickinput/common/quickInput';
import { ITerminalCapabilityStore, ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
import { IExtensionTerminalProfile, IProcessPropertyMap, IShellIntegration, IShellLaunchConfig, ITerminalDimensions, ITerminalLaunchError, ITerminalProfile, ITerminalTabLayoutInfoById, ProcessPropertyType, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalShellType, TerminalType, TitleEventSource, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
import { IExtensionTerminalProfile, IProcessPropertyMap, IReconnectionProperties, IShellIntegration, IShellLaunchConfig, ITerminalDimensions, ITerminalLaunchError, ITerminalProfile, ITerminalTabLayoutInfoById, ProcessPropertyType, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalShellType, TerminalType, TitleEventSource, WaitOnExitValue } from 'vs/platform/terminal/common/terminal';
import { IGenericMarkProperties } from 'vs/platform/terminal/common/terminalProcess';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
@@ -257,11 +257,10 @@ interface ITerminalEditorInputObject {
readonly icon: TerminalIcon | undefined;
readonly color: string | undefined;
readonly hasChildProcesses?: boolean;
readonly task?: { label: string; id: string; lastTask: string; group?: string; waitOnExit?: WaitOnExitValue };
readonly type?: TerminalType;
readonly isFeatureTerminal?: boolean;
readonly hideFromUser?: boolean;
readonly reconnectionOwner?: string;
readonly reconnectionProperties?: IReconnectionProperties;
}
export interface ISerializedTerminalEditorInput extends ITerminalEditorInputObject {
@@ -450,7 +449,7 @@ export interface ITerminalInstance {
readonly fixedRows?: number;
readonly icon?: TerminalIcon;
readonly color?: string;
readonly reconnectionOwner?: string;
readonly reconnectionProperties?: IReconnectionProperties;
readonly processName: string;
readonly sequence?: string;
readonly staticTitle?: string;

View File

@@ -44,10 +44,9 @@ export class TerminalInputSerializer implements IEditorSerializer {
color: instance.color,
resource: instance.resource.toString(),
hasChildProcesses: instance.hasChildProcesses,
task: instance.shellLaunchConfig.task,
type: instance.shellLaunchConfig.type,
isFeatureTerminal: instance.shellLaunchConfig.isFeatureTerminal,
hideFromUser: instance.shellLaunchConfig.hideFromUser,
reconnectionProperties: instance.shellLaunchConfig.reconnectionProperties
};
}
}

View File

@@ -46,7 +46,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ITerminalCommand, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import { TerminalCapabilityStoreMultiplexer } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
import { IProcessDataEvent, IProcessPropertyMap, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, PosixShellType, ProcessPropertyType, ShellIntegrationStatus, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalSettingId, TerminalShellType, TitleEventSource, WindowsShellType } from 'vs/platform/terminal/common/terminal';
import { IProcessDataEvent, IProcessPropertyMap, IReconnectionProperties, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, PosixShellType, ProcessPropertyType, ShellIntegrationStatus, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalSettingId, TerminalShellType, TitleEventSource, WindowsShellType } from 'vs/platform/terminal/common/terminal';
import { escapeNonWindowsPath, collapseTildePath } from 'vs/platform/terminal/common/terminalEnvironment';
import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground } from 'vs/platform/theme/common/colorRegistry';
import { IColorTheme, ICssStyleCollector, IThemeService, registerThemingParticipant, ThemeIcon } from 'vs/platform/theme/common/themeService';
@@ -282,7 +282,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// TODO: Should this be an event as it can fire twice?
get processReady(): Promise<void> { return this._processManager.ptyProcessReady; }
get hasChildProcesses(): boolean { return this.shellLaunchConfig.attachPersistentProcess?.hasChildProcesses || this._processManager.hasChildProcesses; }
get reconnectionOwner(): string | undefined { return this.shellLaunchConfig.attachPersistentProcess?.reconnectionOwner || this.shellLaunchConfig.reconnectionOwner; }
get reconnectionProperties(): IReconnectionProperties | undefined { return this.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties || this.shellLaunchConfig.reconnectionProperties; }
get areLinksReady(): boolean { return this._areLinksReady; }
get initialDataEvents(): string[] | undefined { return this._initialDataEvents; }
get exitCode(): number | undefined { return this._exitCode; }
@@ -696,7 +696,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._shutdownPersistentProcessId = shutdownPersistentProcessId;
}
get persistentProcessId(): number | undefined { return this._processManager.persistentProcessId ?? this._shutdownPersistentProcessId; }
get shouldPersist(): boolean { return (this._processManager.shouldPersist || this._shutdownPersistentProcessId !== undefined) && !this.shellLaunchConfig.isTransient && (!this.reconnectionOwner || this._configurationService.getValue(TaskSettingId.Reconnection) === true); }
get shouldPersist(): boolean { return (this._processManager.shouldPersist || this._shutdownPersistentProcessId !== undefined) && !this.shellLaunchConfig.isTransient && (!this.reconnectionProperties || this._configurationService.getValue(TaskSettingId.Reconnection) === true); }
/**
* Create xterm.js instance and attach data listeners.
@@ -2392,7 +2392,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
info.requiresAction &&
this._configHelper.config.environmentChangesRelaunch &&
!this._processManager.hasWrittenData &&
(!this._shellLaunchConfig.isFeatureTerminal || (this.reconnectionOwner && this._configurationService.getValue(TaskSettingId.Reconnection) === true)) &&
(!this._shellLaunchConfig.isFeatureTerminal || (this.reconnectionProperties && this._configurationService.getValue(TaskSettingId.Reconnection) === true)) &&
!this._shellLaunchConfig.customPtyImplementation
&& !this._shellLaunchConfig.isExtensionOwnedTerminal &&
!this._shellLaunchConfig.attachPersistentProcess

View File

@@ -20,7 +20,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import { NaiveCwdDetectionCapability } from 'vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability';
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
import { FlowControlConstants, IProcessDataEvent, IProcessProperty, IProcessPropertyMap, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalEnvironment, ITerminalLaunchError, ITerminalProcessOptions, ProcessPropertyType, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { FlowControlConstants, IProcessDataEvent, IProcessProperty, IProcessPropertyMap, IProcessReadyEvent, IReconnectionProperties, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalEnvironment, ITerminalLaunchError, ITerminalProcessOptions, ProcessPropertyType, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/terminalProcess';
import { TerminalRecorder } from 'vs/platform/terminal/common/terminalRecorder';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
@@ -114,10 +114,10 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
readonly onRestoreCommands = this._onRestoreCommands.event;
get persistentProcessId(): number | undefined { return this._process?.id; }
get shouldPersist(): boolean { return !!this.reconnectionOwner || (this._process ? this._process.shouldPersist : false); }
get shouldPersist(): boolean { return !!this.reconnectionProperties || (this._process ? this._process.shouldPersist : false); }
get hasWrittenData(): boolean { return this._hasWrittenData; }
get hasChildProcesses(): boolean { return this._hasChildProcesses; }
get reconnectionOwner(): string | undefined { return this._shellLaunchConfig?.attachPersistentProcess?.reconnectionOwner || this._shellLaunchConfig?.reconnectionOwner || undefined; }
get reconnectionProperties(): IReconnectionProperties | undefined { return this._shellLaunchConfig?.attachPersistentProcess?.reconnectionProperties || this._shellLaunchConfig?.reconnectionProperties || undefined; }
constructor(
private readonly _instanceId: number,
@@ -246,7 +246,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
// this is a copy of what the merged environment collection is on the remote side
const env = await this._resolveEnvironment(backend, variableResolver, shellLaunchConfig);
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionOwner) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionProperties) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
if (shellLaunchConfig.attachPersistentProcess) {
const result = await backend.attachToProcess(shellLaunchConfig.attachPersistentProcess.id);
if (result) {
@@ -460,7 +460,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled,
environmentVariableCollections: this._extEnvironmentVariableCollection ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined
};
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionOwner) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionProperties) || !shellLaunchConfig.isFeatureTerminal) && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
return await backend.createProcess(shellLaunchConfig, initialCwd, cols, rows, this._configHelper.config.unicodeVersion, env, options, shouldPersist);
}
@@ -493,7 +493,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
this._ptyResponsiveListener?.dispose();
this._ptyResponsiveListener = undefined;
if (this._shellLaunchConfig) {
if (this._shellLaunchConfig.isFeatureTerminal && !this.reconnectionOwner) {
if (this._shellLaunchConfig.isFeatureTerminal && !this.reconnectionProperties) {
// Indicate the process is exited (and gone forever) only for feature terminals
// so they can react to the exit, this is particularly important for tasks so
// that it knows that the process is not still active. Note that this is not

View File

@@ -1049,12 +1049,12 @@ export class TerminalService implements ITerminalService {
}
private _addToReconnected(instance: ITerminalInstance): void {
if (instance.reconnectionOwner) {
const reconnectedTerminals = this._reconnectedTerminals.get(instance.reconnectionOwner);
if (instance.reconnectionProperties) {
const reconnectedTerminals = this._reconnectedTerminals.get(instance.reconnectionProperties.ownerId);
if (reconnectedTerminals) {
reconnectedTerminals.push(instance);
} else {
this._reconnectedTerminals.set(instance.reconnectionOwner, [instance]);
this._reconnectedTerminals.set(instance.reconnectionProperties.ownerId, [instance]);
}
}
}