Skip to content

Commit

Permalink
Try to start on shell type API
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed Jan 10, 2025
1 parent 77027e7 commit 1affd37
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/vs/workbench/api/browser/mainThreadTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._store.add(_terminalService.onAnyInstanceTitleChange(instance => instance && this._onTitleChanged(instance.instanceId, instance.title)));
this._store.add(_terminalService.onAnyInstanceDataInput(instance => this._proxy.$acceptTerminalInteraction(instance.instanceId)));
this._store.add(_terminalService.onAnyInstanceSelectionChange(instance => this._proxy.$acceptTerminalSelection(instance.instanceId, instance.selection)));
this._store.add(_terminalService.onAnyInstanceShellTypeChange(instance => this._proxy.$acceptTerminalShellType(instance.instanceId, instance.shellType)));

// Set initial ext host state
for (const instance of this._terminalService.instances) {
Expand Down Expand Up @@ -353,6 +354,13 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._proxy.$acceptTerminalTitleChange(terminalId, name);
}

private _onShellTypeChanged(terminalId: number, shellType: string): void {
const terminalInstance = this._terminalService.getInstanceFromId(terminalId)?.shellType;
if (terminalInstance) {
this._proxy.$provideTerminalShellType(terminalId, shellType);
}
}

private _onTerminalDisposed(terminalInstance: ITerminalInstance): void {
this._proxy.$acceptTerminalClosed(terminalInstance.instanceId, terminalInstance.exitCode, terminalInstance.exitReason ?? TerminalExitReason.Unknown);
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { AuthInfo, Credentials } from '../../../platform/request/common/request.
import { ClassifiedEvent, IGDPRProperty, OmitMetadata, StrictPropertyCheck } from '../../../platform/telemetry/common/gdprTypings.js';
import { TelemetryLevel } from '../../../platform/telemetry/common/telemetry.js';
import { ISerializableEnvironmentDescriptionMap, ISerializableEnvironmentVariableCollection } from '../../../platform/terminal/common/environmentVariable.js';
import { ICreateContributedTerminalProfileOptions, IProcessProperty, IProcessReadyWindowsPty, IShellLaunchConfigDto, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, TerminalExitReason, TerminalLocation } from '../../../platform/terminal/common/terminal.js';
import { ICreateContributedTerminalProfileOptions, IProcessProperty, IProcessReadyWindowsPty, IShellLaunchConfigDto, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, TerminalExitReason, TerminalLocation, TerminalShellType } from '../../../platform/terminal/common/terminal.js';
import { ProvidedPortAttributes, TunnelCreationOptions, TunnelOptions, TunnelPrivacyId, TunnelProviderFeatures } from '../../../platform/tunnel/common/tunnel.js';
import { EditSessionIdentityMatch } from '../../../platform/workspace/common/editSessions.js';
import { WorkspaceTrustRequestOptions } from '../../../platform/workspace/common/workspaceTrust.js';
Expand Down Expand Up @@ -2417,6 +2417,7 @@ export interface ExtHostTerminalServiceShape {
$acceptTerminalMaximumDimensions(id: number, cols: number, rows: number): void;
$acceptTerminalInteraction(id: number): void;
$acceptTerminalSelection(id: number, selection: string | undefined): void;
$acceptTerminalShellType(id: number, shellType: string): Promise<TerminalShellType>;
$startExtensionTerminal(id: number, initialDimensions: ITerminalDimensionsDto | undefined): Promise<ITerminalLaunchError | undefined>;
$acceptProcessAckDataEvent(id: number, charCount: number): void;
$acceptProcessInput(id: number, data: string): void;
Expand Down
7 changes: 6 additions & 1 deletion src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { serializeEnvironmentDescriptionMap, serializeEnvironmentVariableCollect
import { CancellationTokenSource } from '../../../base/common/cancellation.js';
import { generateUuid } from '../../../base/common/uuid.js';
import { IEnvironmentVariableCollectionDescription, IEnvironmentVariableMutator, ISerializableEnvironmentVariableCollection } from '../../../platform/terminal/common/environmentVariable.js';
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, ProcessPropertyType, IProcessPropertyMap } from '../../../platform/terminal/common/terminal.js';
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, ProcessPropertyType, IProcessPropertyMap, TerminalShellType, GeneralShellType } from '../../../platform/terminal/common/terminal.js';
import { TerminalDataBufferer } from '../../../platform/terminal/common/terminalDataBuffering.js';
import { ThemeColor } from '../../../base/common/themables.js';
import { Promises } from '../../../base/common/async.js';
Expand Down Expand Up @@ -764,6 +764,11 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I

return completions;
}
// Take in shellType as a string and return VSCode Terminal Shell Type?
public async $acceptTerminalShellType(id: number, shellType: string): Promise<TerminalShellType> {
// TODO: Implement
return GeneralShellType.Python;
}

public registerTerminalQuickFixProvider(id: string, extensionId: string, provider: vscode.TerminalQuickFixProvider): vscode.Disposable {
if (this._quickFixProviders.has(id)) {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export interface ITerminalService extends ITerminalInstanceHost {
readonly onDidRequestStartExtensionTerminal: Event<IStartExtensionTerminalRequest>;
readonly onDidRegisterProcessSupport: Event<void>;
readonly onDidChangeConnectionState: Event<void>;

readonly onAnyInstanceShellTypeChanged: Event<ITerminalInstance>; // Here or on proposed api? - also there is onDidChangeShellType that already exists..
// Group events
readonly onDidChangeActiveGroup: Event<ITerminalGroup | undefined>;

Expand Down Expand Up @@ -705,7 +705,7 @@ export interface ITerminalInstance extends IBaseTerminalInstance {
onDidExecuteText: Event<void>;
onDidChangeTarget: Event<TerminalLocation | undefined>;
onDidSendText: Event<string>;
onDidChangeShellType: Event<TerminalShellType>;
onDidChangeShellType: Event<TerminalShellType>; // how should this be used in correlation to my api which should expose shell type
onDidChangeVisibility: Event<boolean>;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._shellType = shellType;
this._terminalShellTypeContextKey.set(shellType?.toString());
this._onDidChangeShellType.fire(shellType);
// Can I fire here to let my new API know? but how should I do that

}
}

Expand Down

0 comments on commit 1affd37

Please sign in to comment.