mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Merge pull request #276272 from microsoft/tyriar/274723_platform_terminal__server
Remove any from terminal in server
This commit is contained in:
@@ -837,7 +837,6 @@ export default tseslint.config(
|
|||||||
'src/vs/workbench/contrib/tasks/common/taskConfiguration.ts',
|
'src/vs/workbench/contrib/tasks/common/taskConfiguration.ts',
|
||||||
'src/vs/workbench/contrib/tasks/common/taskSystem.ts',
|
'src/vs/workbench/contrib/tasks/common/taskSystem.ts',
|
||||||
'src/vs/workbench/contrib/tasks/common/tasks.ts',
|
'src/vs/workbench/contrib/tasks/common/tasks.ts',
|
||||||
'src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts',
|
|
||||||
'src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts',
|
'src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts',
|
||||||
'src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts',
|
'src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts',
|
||||||
'src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts',
|
'src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts',
|
||||||
@@ -846,7 +845,6 @@ export default tseslint.config(
|
|||||||
'src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts',
|
'src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts',
|
||||||
'src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts',
|
'src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts',
|
||||||
'src/vs/workbench/contrib/terminal/common/basePty.ts',
|
'src/vs/workbench/contrib/terminal/common/basePty.ts',
|
||||||
'src/vs/workbench/contrib/terminal/common/remote/remoteTerminalChannel.ts',
|
|
||||||
'src/vs/workbench/contrib/terminal/common/terminal.ts',
|
'src/vs/workbench/contrib/terminal/common/terminal.ts',
|
||||||
'src/vs/workbench/contrib/terminalContrib/links/browser/links.ts',
|
'src/vs/workbench/contrib/terminalContrib/links/browser/links.ts',
|
||||||
'src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts',
|
'src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts',
|
||||||
@@ -917,7 +915,6 @@ export default tseslint.config(
|
|||||||
'src/vs/server/node/remoteAgentEnvironmentImpl.ts',
|
'src/vs/server/node/remoteAgentEnvironmentImpl.ts',
|
||||||
'src/vs/server/node/remoteExtensionHostAgentServer.ts',
|
'src/vs/server/node/remoteExtensionHostAgentServer.ts',
|
||||||
'src/vs/server/node/remoteExtensionsScanner.ts',
|
'src/vs/server/node/remoteExtensionsScanner.ts',
|
||||||
'src/vs/server/node/remoteTerminalChannel.ts',
|
|
||||||
// Tests
|
// Tests
|
||||||
'**/*.test.ts',
|
'**/*.test.ts',
|
||||||
'**/*.integrationTest.ts'
|
'**/*.integrationTest.ts'
|
||||||
|
|||||||
@@ -90,12 +90,12 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
|
|
||||||
private _lastReqId = 0;
|
private _lastReqId = 0;
|
||||||
private readonly _pendingCommands = new Map<number, {
|
private readonly _pendingCommands = new Map<number, {
|
||||||
resolve: (data: any) => void;
|
resolve: (value: unknown) => void;
|
||||||
reject: (err: any) => void;
|
reject: (err?: unknown) => void;
|
||||||
uriTransformer: IURITransformer;
|
uriTransformer: IURITransformer;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: any[] }>());
|
private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: unknown[] }>());
|
||||||
readonly onExecuteCommand = this._onExecuteCommand.event;
|
readonly onExecuteCommand = this._onExecuteCommand.event;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -109,6 +109,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
async call(ctx: RemoteAgentConnectionContext, command: RemoteTerminalChannelRequest, args?: any): Promise<any> {
|
async call(ctx: RemoteAgentConnectionContext, command: RemoteTerminalChannelRequest, args?: any): Promise<any> {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case RemoteTerminalChannelRequest.RestartPtyHost: return this._ptyHostService.restartPtyHost.apply(this._ptyHostService, args);
|
case RemoteTerminalChannelRequest.RestartPtyHost: return this._ptyHostService.restartPtyHost.apply(this._ptyHostService, args);
|
||||||
@@ -167,21 +168,21 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
throw new Error(`IPC Command ${command} not found`);
|
throw new Error(`IPC Command ${command} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
listen(_: any, event: RemoteTerminalChannelEvent, arg: any): Event<any> {
|
listen<T>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case RemoteTerminalChannelEvent.OnPtyHostExitEvent: return this._ptyHostService.onPtyHostExit || Event.None;
|
case RemoteTerminalChannelEvent.OnPtyHostExitEvent: return (this._ptyHostService.onPtyHostExit || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnPtyHostStartEvent: return this._ptyHostService.onPtyHostStart || Event.None;
|
case RemoteTerminalChannelEvent.OnPtyHostStartEvent: return (this._ptyHostService.onPtyHostStart || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnPtyHostUnresponsiveEvent: return this._ptyHostService.onPtyHostUnresponsive || Event.None;
|
case RemoteTerminalChannelEvent.OnPtyHostUnresponsiveEvent: return (this._ptyHostService.onPtyHostUnresponsive || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnPtyHostResponsiveEvent: return this._ptyHostService.onPtyHostResponsive || Event.None;
|
case RemoteTerminalChannelEvent.OnPtyHostResponsiveEvent: return (this._ptyHostService.onPtyHostResponsive || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnPtyHostRequestResolveVariablesEvent: return this._ptyHostService.onPtyHostRequestResolveVariables || Event.None;
|
case RemoteTerminalChannelEvent.OnPtyHostRequestResolveVariablesEvent: return (this._ptyHostService.onPtyHostRequestResolveVariables || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnProcessDataEvent: return this._ptyHostService.onProcessData;
|
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return this._ptyHostService.onProcessReady;
|
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnProcessExitEvent: return this._ptyHostService.onProcessExit;
|
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return this._ptyHostService.onProcessReplay;
|
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return this._ptyHostService.onProcessOrphanQuestion;
|
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnExecuteCommand: return this.onExecuteCommand;
|
case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnDidRequestDetach: return this._ptyHostService.onDidRequestDetach || Event.None;
|
case RemoteTerminalChannelEvent.OnDidRequestDetach: return (this._ptyHostService.onDidRequestDetach || Event.None) as Event<T>;
|
||||||
case RemoteTerminalChannelEvent.OnDidChangeProperty: return this._ptyHostService.onDidChangeProperty;
|
case RemoteTerminalChannelEvent.OnDidChangeProperty: return (this._ptyHostService.onDidChangeProperty) as Event<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error Assert event is the `never` type to ensure all messages are handled
|
// @ts-expect-error Assert event is the `never` type to ensure all messages are handled
|
||||||
@@ -263,7 +264,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
|
|
||||||
const persistentProcessId = await this._ptyHostService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
|
const persistentProcessId = await this._ptyHostService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
|
||||||
const commandsExecuter: ICommandsExecuter = {
|
const commandsExecuter: ICommandsExecuter = {
|
||||||
executeCommand: <T>(id: string, ...args: any[]): Promise<T> => this._executeCommand(persistentProcessId, id, args, uriTransformer)
|
executeCommand: <T>(id: string, ...args: unknown[]): Promise<T> => this._executeCommand(persistentProcessId, id, args, uriTransformer)
|
||||||
};
|
};
|
||||||
const cliServer = new CLIServerBase(commandsExecuter, this._logService, ipcHandlePath);
|
const cliServer = new CLIServerBase(commandsExecuter, this._logService, ipcHandlePath);
|
||||||
this._ptyHostService.onProcessExit(e => e.id === persistentProcessId && cliServer.dispose());
|
this._ptyHostService.onProcessExit(e => e.id === persistentProcessId && cliServer.dispose());
|
||||||
@@ -274,11 +275,11 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _executeCommand<T>(persistentProcessId: number, commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
|
private _executeCommand<T>(persistentProcessId: number, commandId: string, commandArgs: unknown[], uriTransformer: IURITransformer): Promise<T> {
|
||||||
const { resolve, reject, promise } = promiseWithResolvers<T>();
|
const { resolve, reject, promise } = promiseWithResolvers<T>();
|
||||||
|
|
||||||
const reqId = ++this._lastReqId;
|
const reqId = ++this._lastReqId;
|
||||||
this._pendingCommands.set(reqId, { resolve, reject, uriTransformer });
|
this._pendingCommands.set(reqId, { resolve: resolve as (value: unknown) => void, reject, uriTransformer });
|
||||||
|
|
||||||
const serializedCommandArgs = cloneAndChange(commandArgs, (obj) => {
|
const serializedCommandArgs = cloneAndChange(commandArgs, (obj) => {
|
||||||
if (obj && obj.$mid === 1) {
|
if (obj && obj.$mid === 1) {
|
||||||
@@ -300,7 +301,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _sendCommandResult(reqId: number, isError: boolean, serializedPayload: any): void {
|
private _sendCommandResult(reqId: number, isError: boolean, serializedPayload: unknown): void {
|
||||||
const data = this._pendingCommands.get(reqId);
|
const data = this._pendingCommands.get(reqId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { Registry } from '../../../../platform/registry/common/platform.js';
|
|||||||
import { IRemoteAuthorityResolverService } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
|
import { IRemoteAuthorityResolverService } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
|
||||||
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
|
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
|
||||||
import { ISerializedTerminalCommand } from '../../../../platform/terminal/common/capabilities/capabilities.js';
|
import { ISerializedTerminalCommand } from '../../../../platform/terminal/common/capabilities/capabilities.js';
|
||||||
import { IPtyHostLatencyMeasurement, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalBackend, ITerminalBackendRegistry, ITerminalChildProcess, ITerminalEnvironment, ITerminalLogService, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, ProcessPropertyType, TerminalExtensions, TerminalIcon, TerminalSettingId, TitleEventSource } from '../../../../platform/terminal/common/terminal.js';
|
import { IPtyHostLatencyMeasurement, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalBackend, ITerminalBackendRegistry, ITerminalChildProcess, ITerminalEnvironment, ITerminalLogService, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, ProcessPropertyType, TerminalExtensions, TerminalIcon, TerminalSettingId, TitleEventSource, type IProcessPropertyMap } from '../../../../platform/terminal/common/terminal.js';
|
||||||
import { IProcessDetails } from '../../../../platform/terminal/common/terminalProcess.js';
|
import { IProcessDetails } from '../../../../platform/terminal/common/terminalProcess.js';
|
||||||
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
|
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
|
||||||
import { IWorkbenchContribution } from '../../../common/contributions.js';
|
import { IWorkbenchContribution } from '../../../common/contributions.js';
|
||||||
@@ -257,7 +257,7 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateProperty<T extends ProcessPropertyType>(id: number, property: T, value: any): Promise<void> {
|
async updateProperty<T extends ProcessPropertyType>(id: number, property: T, value: IProcessPropertyMap[T]): Promise<void> {
|
||||||
await this._remoteTerminalChannel.updateProperty(id, property, value);
|
await this._remoteTerminalChannel.updateProperty(id, property, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ export class RemoteTerminalChannelClient implements IPtyHostController {
|
|||||||
get onProcessOrphanQuestion(): Event<{ id: number }> {
|
get onProcessOrphanQuestion(): Event<{ id: number }> {
|
||||||
return this._channel.listen<{ id: number }>(RemoteTerminalChannelEvent.OnProcessOrphanQuestion);
|
return this._channel.listen<{ id: number }>(RemoteTerminalChannelEvent.OnProcessOrphanQuestion);
|
||||||
}
|
}
|
||||||
get onExecuteCommand(): Event<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: any[] }> {
|
get onExecuteCommand(): Event<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: unknown[] }> {
|
||||||
return this._channel.listen<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: any[] }>(RemoteTerminalChannelEvent.OnExecuteCommand);
|
return this._channel.listen<{ reqId: number; persistentProcessId: number; commandId: string; commandArgs: unknown[] }>(RemoteTerminalChannelEvent.OnExecuteCommand);
|
||||||
}
|
}
|
||||||
get onDidRequestDetach(): Event<{ requestId: number; workspaceId: string; instanceId: number }> {
|
get onDidRequestDetach(): Event<{ requestId: number; workspaceId: string; instanceId: number }> {
|
||||||
return this._channel.listen<{ requestId: number; workspaceId: string; instanceId: number }>(RemoteTerminalChannelEvent.OnDidRequestDetach);
|
return this._channel.listen<{ requestId: number; workspaceId: string; instanceId: number }>(RemoteTerminalChannelEvent.OnDidRequestDetach);
|
||||||
}
|
}
|
||||||
get onDidChangeProperty(): Event<{ id: number; property: IProcessProperty<any> }> {
|
get onDidChangeProperty(): Event<{ id: number; property: IProcessProperty }> {
|
||||||
return this._channel.listen<{ id: number; property: IProcessProperty<any> }>(RemoteTerminalChannelEvent.OnDidChangeProperty);
|
return this._channel.listen<{ id: number; property: IProcessProperty }>(RemoteTerminalChannelEvent.OnDidChangeProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -246,7 +246,7 @@ export class RemoteTerminalChannelClient implements IPtyHostController {
|
|||||||
orphanQuestionReply(id: number): Promise<void> {
|
orphanQuestionReply(id: number): Promise<void> {
|
||||||
return this._channel.call(RemoteTerminalChannelRequest.OrphanQuestionReply, [id]);
|
return this._channel.call(RemoteTerminalChannelRequest.OrphanQuestionReply, [id]);
|
||||||
}
|
}
|
||||||
sendCommandResult(reqId: number, isError: boolean, payload: any): Promise<void> {
|
sendCommandResult(reqId: number, isError: boolean, payload: unknown): Promise<void> {
|
||||||
return this._channel.call(RemoteTerminalChannelRequest.SendCommandResult, [reqId, isError, payload]);
|
return this._channel.call(RemoteTerminalChannelRequest.SendCommandResult, [reqId, isError, payload]);
|
||||||
}
|
}
|
||||||
freePortKillProcess(port: string): Promise<{ port: string; processId: string }> {
|
freePortKillProcess(port: string): Promise<{ port: string; processId: string }> {
|
||||||
|
|||||||
Reference in New Issue
Block a user