Skip to content

Commit ed59e75

Browse files
committed
Add IPtyHostService
This is a new service which extends IPtyService and provides additional methods on the process that manages the connection to the pty host: - IPtyService: Talk to the pty host, this may be direct via a message port of via the main/server procs. - IPtyHostService: Talk to the pty host management interfaces on the main/server procs. These are no longer available as optional methods on IPtyService to be clear about where they happen (eg. getProfiles). Fixes microsoft#186935
1 parent 440bade commit ed59e75

File tree

6 files changed

+86
-88
lines changed

6 files changed

+86
-88
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ export enum TerminalIpcChannels {
221221
Heartbeat = 'heartbeat'
222222
}
223223

224-
export const IPtyService = createDecorator<IPtyService>('ptyService');
225-
226224
export const enum ProcessPropertyType {
227225
Cwd = 'cwd',
228226
InitialCwd = 'initialCwd',
@@ -266,18 +264,8 @@ export interface IFixedTerminalDimensions {
266264
rows?: number;
267265
}
268266

269-
export interface IPtyHostController {
270-
readonly onPtyHostExit?: Event<number>;
271-
readonly onPtyHostStart?: Event<void>;
272-
readonly onPtyHostUnresponsive?: Event<void>;
273-
readonly onPtyHostResponsive?: Event<void>;
274-
readonly onPtyHostRequestResolveVariables?: Event<IRequestResolveVariablesEvent>;
275-
276-
restartPtyHost?(): void;
277-
acceptPtyHostResolvedVariables?(requestId: number, resolved: string[]): Promise<void>;
278-
}
279-
280-
export interface IPtyService extends IPtyHostController {
267+
export const IPtyService = createDecorator<IPtyService>('ptyService');
268+
export interface IPtyService {
281269
readonly _serviceBrand: undefined;
282270

283271
readonly onProcessData: Event<{ id: number; event: IProcessDataEvent | string }>;
@@ -288,10 +276,6 @@ export interface IPtyService extends IPtyHostController {
288276
readonly onDidChangeProperty: Event<{ id: number; property: IProcessProperty<any> }>;
289277
readonly onProcessExit: Event<{ id: number; event: number | undefined }>;
290278

291-
restartPtyHost?(): Promise<void>;
292-
shutdownAll?(): Promise<void>;
293-
acceptPtyHostResolvedVariables?(requestId: number, resolved: string[]): Promise<void>;
294-
295279
createProcess(
296280
shellLaunchConfig: IShellLaunchConfig,
297281
cwd: string,
@@ -307,6 +291,7 @@ export interface IPtyService extends IPtyHostController {
307291
): Promise<number>;
308292
attachToProcess(id: number): Promise<void>;
309293
detachFromProcess(id: number, forcePersist?: boolean): Promise<void>;
294+
shutdownAll(): Promise<void>;
310295

311296
/**
312297
* Lists all orphaned processes, ie. those without a connected frontend.
@@ -334,7 +319,6 @@ export interface IPtyService extends IPtyHostController {
334319
uninstallAllAutoReplies(): Promise<void>;
335320
uninstallAutoReply(match: string): Promise<void>;
336321
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string>;
337-
getProfiles?(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
338322
getEnvironment(): Promise<IProcessEnvironment>;
339323
getWslPath(original: string, direction: 'unix-to-win' | 'win-to-unix'): Promise<string>;
340324
getRevivedPtyNewId(workspaceId: string, id: number): Promise<number | undefined>;
@@ -343,7 +327,7 @@ export interface IPtyService extends IPtyHostController {
343327
reduceConnectionGraceTime(): Promise<void>;
344328
requestDetachInstance(workspaceId: string, instanceId: number): Promise<IProcessDetails | undefined>;
345329
acceptDetachInstanceReply(requestId: number, persistentProcessId?: number): Promise<void>;
346-
freePortKillProcess?(port: string): Promise<{ port: string; processId: string }>;
330+
freePortKillProcess(port: string): Promise<{ port: string; processId: string }>;
347331
/**
348332
* Serializes and returns terminal state.
349333
* @param ids The persistent terminal IDs to serialize.
@@ -357,9 +341,26 @@ export interface IPtyService extends IPtyHostController {
357341
refreshProperty<T extends ProcessPropertyType>(id: number, property: T): Promise<IProcessPropertyMap[T]>;
358342
updateProperty<T extends ProcessPropertyType>(id: number, property: T, value: IProcessPropertyMap[T]): Promise<void>;
359343

344+
// TODO: Make mandatory and remove impl from pty host service
360345
refreshIgnoreProcessNames?(names: string[]): Promise<void>;
361346
}
362347

348+
export interface IPtyHostController {
349+
readonly onPtyHostExit: Event<number>;
350+
readonly onPtyHostStart: Event<void>;
351+
readonly onPtyHostUnresponsive: Event<void>;
352+
readonly onPtyHostResponsive: Event<void>;
353+
readonly onPtyHostRequestResolveVariables: Event<IRequestResolveVariablesEvent>;
354+
355+
restartPtyHost(): Promise<void>;
356+
acceptPtyHostResolvedVariables(requestId: number, resolved: string[]): Promise<void>;
357+
getProfiles(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
358+
}
359+
360+
export const IPtyHostService = createDecorator<IPtyHostService>('ptyHostService');
361+
export interface IPtyHostService extends IPtyService, IPtyHostController {
362+
}
363+
363364
/**
364365
* Serialized terminal state matching the interface that can be used across versions, the version
365366
* should be verified before using the state payload.
@@ -1066,7 +1067,7 @@ export const ILocalPtyService = createDecorator<ILocalPtyService>('localPtyServi
10661067
*
10671068
* **This service should only be used within the terminal component.**
10681069
*/
1069-
export interface ILocalPtyService extends IPtyService { }
1070+
export interface ILocalPtyService extends IPtyHostService { }
10701071

10711072
export const ITerminalLogService = createDecorator<ITerminalLogService>('terminalLogService');
10721073
export interface ITerminalLogService extends ILogService {

src/vs/platform/terminal/node/ptyHostService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { RemoteLoggerChannelClient } from 'vs/platform/log/common/logIpc';
1313
import { getResolvedShellEnv } from 'vs/platform/shell/node/shellEnv';
1414
import { IPtyHostProcessReplayEvent } from 'vs/platform/terminal/common/capabilities/capabilities';
1515
import { RequestStore } from 'vs/platform/terminal/common/requestStore';
16-
import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IProcessProperty, IProcessPropertyMap, IProcessReadyEvent, IPtyService, IRequestResolveVariablesEvent, ISerializedTerminalState, IShellLaunchConfig, ITerminalLaunchError, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ProcessPropertyType, TerminalIcon, TerminalIpcChannels, TerminalSettingId, TitleEventSource } from 'vs/platform/terminal/common/terminal';
16+
import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IProcessProperty, IProcessPropertyMap, IProcessReadyEvent, IPtyHostService, IPtyService, IRequestResolveVariablesEvent, ISerializedTerminalState, IShellLaunchConfig, ITerminalLaunchError, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ProcessPropertyType, TerminalIcon, TerminalIpcChannels, TerminalSettingId, TitleEventSource } from 'vs/platform/terminal/common/terminal';
1717
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
1818
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
1919
import { IPtyHostConnection, IPtyHostStarter } from 'vs/platform/terminal/node/ptyHost';
@@ -29,7 +29,7 @@ enum Constants {
2929
* This service implements IPtyService by launching a pty host process, forwarding messages to and
3030
* from the pty host process and manages the connection.
3131
*/
32-
export class PtyHostService extends Disposable implements IPtyService {
32+
export class PtyHostService extends Disposable implements IPtyHostService {
3333
declare readonly _serviceBrand: undefined;
3434

3535
private __connection?: IPtyHostConnection;
@@ -230,6 +230,9 @@ export class PtyHostService extends Disposable implements IPtyService {
230230
detachFromProcess(id: number, forcePersist?: boolean): Promise<void> {
231231
return this._proxy.detachFromProcess(id, forcePersist);
232232
}
233+
shutdownAll(): Promise<void> {
234+
return this._proxy.shutdownAll();
235+
}
233236
listProcesses(): Promise<IProcessDetails[]> {
234237
return this._proxy.listProcesses();
235238
}
@@ -354,7 +357,7 @@ export class PtyHostService extends Disposable implements IPtyService {
354357
}
355358

356359
private _disposePtyHost(): void {
357-
this._proxy.shutdownAll?.();
360+
this._proxy.shutdownAll();
358361
this._connection.store.dispose();
359362
}
360363

src/vs/platform/terminal/node/ptyService.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { URI } from 'vs/base/common/uri';
1212
import { getSystemShell } from 'vs/base/node/shell';
1313
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
1414
import { RequestStore } from 'vs/platform/terminal/common/requestStore';
15-
import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TitleEventSource, ProcessPropertyType, IProcessPropertyMap, IFixedTerminalDimensions, IPersistentTerminalProcessLaunchConfig, ICrossVersionSerializedTerminalState, ISerializedTerminalState, ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal';
15+
import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IShellLaunchConfig, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TitleEventSource, ProcessPropertyType, IProcessPropertyMap, IFixedTerminalDimensions, IPersistentTerminalProcessLaunchConfig, ICrossVersionSerializedTerminalState, ISerializedTerminalState, ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal';
1616
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
1717
import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment';
1818
import { Terminal as XtermTerminal } from 'xterm-headless';
@@ -136,12 +136,6 @@ export class PtyService extends Disposable implements IPtyService {
136136
ignoreProcessNames.push(...names);
137137
}
138138

139-
onPtyHostExit?: Event<number> | undefined;
140-
onPtyHostStart?: Event<void> | undefined;
141-
onPtyHostUnresponsive?: Event<void> | undefined;
142-
onPtyHostResponsive?: Event<void> | undefined;
143-
onPtyHostRequestResolveVariables?: Event<IRequestResolveVariablesEvent> | undefined;
144-
145139
@traceRpc
146140
async requestDetachInstance(workspaceId: string, instanceId: number): Promise<IProcessDetails | undefined> {
147141
return this._detachInstanceRequestStore.createRequest({ workspaceId, instanceId });

0 commit comments

Comments
 (0)