connection state in another pr

This commit is contained in:
rebornix
2022-05-20 16:35:46 -07:00
parent 2796b3425d
commit 8d503ffaf4
14 changed files with 10 additions and 79 deletions
@@ -17,14 +17,12 @@ import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/no
import { INotebookCellExecution, INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { INotebookKernel, INotebookKernelChangeEvent, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier';
import { ExtHostContext, ExtHostNotebookKernelsShape, ICellExecuteUpdateDto, ICellExecutionCompleteDto, INotebookKernelDto2, MainContext, MainThreadNotebookKernelsShape, NotebookControllerState } from '../common/extHost.protocol';
import { ExtHostContext, ExtHostNotebookKernelsShape, ICellExecuteUpdateDto, ICellExecutionCompleteDto, INotebookKernelDto2, MainContext, MainThreadNotebookKernelsShape } from '../common/extHost.protocol';
abstract class MainThreadKernel implements INotebookKernel {
private readonly _onDidChange = new Emitter<INotebookKernelChangeEvent>();
private readonly preloads: { uri: URI; provides: string[] }[];
readonly onDidChange: Event<INotebookKernelChangeEvent> = this._onDidChange.event;
private readonly _onDispose = new Emitter<void>();
readonly onDispose = this._onDispose.event;
readonly id: string;
readonly viewType: string;
readonly extension: ExtensionIdentifier;
@@ -34,7 +32,6 @@ abstract class MainThreadKernel implements INotebookKernel {
description?: string;
detail?: string;
kind?: string;
state?: NotebookControllerState;
supportedLanguages: string[];
implementsExecutionOrder: boolean;
localResourceRoot: URI;
@@ -57,7 +54,6 @@ abstract class MainThreadKernel implements INotebookKernel {
this.description = data.description;
this.detail = data.detail;
this.kind = data.kind;
this.state = data.state;
this.supportedLanguages = isNonEmptyArray(data.supportedLanguages) ? data.supportedLanguages : _languageService.getRegisteredLanguageIds();
this.implementsExecutionOrder = data.supportsExecutionOrder ?? false;
this.localResourceRoot = URI.revive(data.extensionLocation);
@@ -84,10 +80,6 @@ abstract class MainThreadKernel implements INotebookKernel {
this.kind = data.kind;
event.kind = true;
}
if (data.state !== undefined) {
this.state = data.state;
event.state = true;
}
if (data.supportedLanguages !== undefined) {
this.supportedLanguages = isNonEmptyArray(data.supportedLanguages) ? data.supportedLanguages : this._languageService.getRegisteredLanguageIds();
event.supportedLanguages = true;
@@ -99,10 +91,6 @@ abstract class MainThreadKernel implements INotebookKernel {
this._onDidChange.fire(event);
}
dispose() {
this._onDispose.fire();
}
abstract executeNotebookCellsRequest(uri: URI, cellHandles: number[]): Promise<void>;
abstract cancelNotebookCellExecution(uri: URI, cellHandles: number[]): Promise<void>;
}
@@ -228,7 +216,7 @@ export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape
});
const registration = this._notebookKernelService.registerKernel(kernel);
this._kernels.set(handle, [kernel, combinedDisposable(kernel, listener, registration)]);
this._kernels.set(handle, [kernel, combinedDisposable(listener, registration)]);
}
$updateKernel(handle: number, data: Partial<INotebookKernelDto2>): void {
@@ -1315,7 +1315,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
NotebookCellOutputItem: extHostTypes.NotebookCellOutputItem,
NotebookCellStatusBarItem: extHostTypes.NotebookCellStatusBarItem,
NotebookControllerAffinity: extHostTypes.NotebookControllerAffinity,
NotebookControllerState: extHostTypes.NotebookControllerState,
NotebookEdit: extHostTypes.NotebookEdit,
PortAttributes: extHostTypes.PortAttributes,
LinkedEditingRanges: extHostTypes.LinkedEditingRanges,
@@ -970,11 +970,6 @@ export interface MainThreadNotebookDocumentsShape extends IDisposable {
$trySaveNotebook(uri: UriComponents): Promise<boolean>;
}
export enum NotebookControllerState {
Idle = 1,
Connecting = 2
}
export interface INotebookKernelDto2 {
id: string;
notebookType: string;
@@ -984,7 +979,6 @@ export interface INotebookKernelDto2 {
detail?: string;
description?: string;
kind?: string;
state?: NotebookControllerState;
supportedLanguages?: string[];
supportsInterrupt?: boolean;
supportsExecutionOrder?: boolean;
@@ -196,15 +196,6 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
get rendererScripts() {
return data.preloads ? data.preloads.map(extHostTypeConverters.NotebookRendererScript.to) : [];
},
get state() {
checkProposedApiEnabled(extension, 'notebookProxyController');
return data.state;
},
set state(value) {
checkProposedApiEnabled(extension, 'notebookProxyController');
data.state = value;
_update();
},
get executeHandler() {
return _executeHandler;
},
@@ -3426,10 +3426,6 @@ export class NotebookRendererScript {
}
}
export enum NotebookControllerState {
Idle = 1,
Connecting = 2
}
//#endregion
@@ -29,7 +29,7 @@ import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/note
import { configureKernelIcon, selectKernelIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernel, INotebookKernelService, NotebookControllerState } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookKernel, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
@@ -408,7 +408,7 @@ export class KernelStatus extends Disposable implements IWorkbenchContribution {
this._kernelInfoElement.add(this._statusbarService.addEntry(
{
name: nls.localize('notebook.info', "Notebook Kernel Info"),
text: `$(notebook-kernel-select) ${kernel.label}` + (kernel.state === NotebookControllerState.Idle ? '' : ' Connecting...'),
text: `$(notebook-kernel-select) ${kernel.label}`,
ariaLabel: kernel.label,
tooltip: isSuggested ? nls.localize('tooltop', "{0} (suggestion)", tooltip) : tooltip,
command: SELECT_KERNEL_ID,
@@ -64,18 +64,6 @@ export class NotebookExecutionService implements INotebookExecutionService, IDis
executeCells.push(cell);
}
if (kernel.state !== undefined) {
// kernel has connection state management
const kernelId = kernel.id;
kernel.onDispose(() => {
// proxy kernel scenario, kernel disposed, we should now make way for new preferred kernel
const exes = executeCells.map(c => this._notebookExecutionStateService.createCellExecution(kernelId, notebook.uri, c.handle));
exes.forEach(e => e.complete({}));
this.executeNotebookCells(notebook, executeCells);
});
}
if (executeCells.length > 0) {
this._notebookKernelService.selectKernelForNotebook(kernel, notebook);
@@ -10,7 +10,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { executingStateIcon, selectKernelIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
import { INotebookKernel, INotebookKernelMatchResult, INotebookKernelService, NotebookControllerState } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookKernel, INotebookKernelMatchResult, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { Event } from 'vs/base/common/event';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
@@ -121,11 +121,7 @@ export class NotebooKernelActionViewItem extends ActionViewItem {
}
private _generateKenrelLabel(kernel: INotebookKernel) {
if (kernel.state === NotebookControllerState.Connecting) {
return localize('kernelconnecting', "Connecting...");
} else {
return kernel.label;
}
return kernel.label;
}
private _resetAction(): void {
@@ -28,16 +28,10 @@ export interface INotebookKernelChangeEvent {
description?: true;
detail?: true;
kind?: true;
state?: true;
supportedLanguages?: true;
hasExecutionOrder?: true;
}
export enum NotebookControllerState {
Idle = 1,
Connecting = 2
}
export interface INotebookKernel {
readonly id: string;
readonly viewType: string;
@@ -52,14 +46,12 @@ export interface INotebookKernel {
description?: string;
detail?: string;
kind?: string;
state?: NotebookControllerState;
supportedLanguages: string[];
implementsInterrupt?: boolean;
implementsExecutionOrder?: boolean;
executeNotebookCellsRequest(uri: URI, cellHandles: number[]): Promise<void>;
cancelNotebookCellExecution(uri: URI, cellHandles: number[]): Promise<void>;
onDispose: Event<void>;
}
export const enum ProxyKernelState {
@@ -20,7 +20,7 @@ import { NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewMod
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { CellKind, IOutputDto, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { INotebookKernel, INotebookKernelService, ISelectedNotebooksChangeEvent, NotebookControllerState } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookKernel, INotebookKernelService, ISelectedNotebooksChangeEvent } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { setupInstantiationService, withTestNotebook as _withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor';
@@ -178,7 +178,6 @@ class TestNotebookKernel implements INotebookKernel {
preloadUris: URI[] = [];
preloadProvides: string[] = [];
supportedLanguages: string[] = [];
onDispose = Event.None;
executeNotebookCellsRequest(): Promise<void> {
throw new Error('Method not implemented.');
}
@@ -189,7 +188,6 @@ class TestNotebookKernel implements INotebookKernel {
this.supportedLanguages = opts?.languages ?? [PLAINTEXT_LANGUAGE_ID];
}
kind?: string | undefined;
state?: NotebookControllerState | undefined;
implementsInterrupt?: boolean | undefined;
implementsExecutionOrder?: boolean | undefined;
}
@@ -182,7 +182,6 @@ class TestNotebookKernel implements INotebookKernel {
preloadUris: URI[] = [];
preloadProvides: string[] = [];
supportedLanguages: string[] = [];
onDispose = Event.None;
async executeNotebookCellsRequest(): Promise<void> { }
async cancelNotebookCellExecution(): Promise<void> { }
@@ -8,7 +8,7 @@ import { URI } from 'vs/base/common/uri';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { setupInstantiationService, withTestNotebook as _withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor';
import { Emitter, Event } from 'vs/base/common/event';
import { INotebookKernel, INotebookKernelService, NotebookControllerState } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookKernel, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { mock } from 'vs/base/test/common/mock';
@@ -171,8 +171,6 @@ class TestNotebookKernel implements INotebookKernel {
preloadUris: URI[] = [];
preloadProvides: string[] = [];
supportedLanguages: string[] = [];
state?: NotebookControllerState | undefined = undefined;
onDispose = Event.None;
executeNotebookCellsRequest(): Promise<void> {
throw new Error('Method not implemented.');
}
@@ -174,7 +174,8 @@ const apiMenus: IAPIMenu[] = [
{
key: 'notebook/kernelSource',
id: MenuId.NotebookKernelSource,
description: localize('notebook.kernelSource', "The contributed notebook kernel sources menu")
description: localize('notebook.kernelSource', "The contributed notebook kernel sources menu"),
proposed: 'notebookProxyController'
},
{
key: 'notebook/cell/title',
@@ -4,13 +4,4 @@
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
export enum NotebookControllerState {
Idle = 1,
Connecting = 2
}
export interface NotebookController {
state?: NotebookControllerState;
}
}