remove old notebookCellExecutionState proposal (#248522)

re https://github.com/microsoft/vscode/issues/124970#issuecomment-2864279668
This commit is contained in:
Johannes Rieken
2025-05-12 02:36:15 +02:00
committed by GitHub
parent c6baa8f4ad
commit e29c92acaf
8 changed files with 3 additions and 132 deletions

View File

@@ -278,38 +278,6 @@ const apiTestSerializer: vscode.NotebookSerializer = {
});
});
test('onDidChangeCellExecutionState is fired', async () => {
const notebook = await openRandomNotebookDocument();
const editor = await vscode.window.showNotebookDocument(notebook);
const cell = editor.notebook.cellAt(0);
let eventCount = 0;
const def = new DeferredPromise<void>();
testDisposables.push(vscode.notebooks.onDidChangeNotebookCellExecutionState(e => {
try {
assert.strictEqual(e.cell.document.uri.toString(), cell.document.uri.toString(), 'event should be fired for the executing cell');
if (eventCount === 0) {
assert.strictEqual(e.state, vscode.NotebookCellExecutionState.Pending, 'should be set to Pending');
} else if (eventCount === 1) {
assert.strictEqual(e.state, vscode.NotebookCellExecutionState.Executing, 'should be set to Executing');
assert.strictEqual(cell.outputs.length, 0, 'no outputs yet: ' + JSON.stringify(cell.outputs[0]));
} else if (e.state === vscode.NotebookCellExecutionState.Idle) {
assert.strictEqual(cell.outputs.length, 1, 'should have an output');
def.complete();
}
eventCount++;
} catch (err) {
def.error(err);
}
}));
vscode.commands.executeCommand('notebook.cell.execute', { document: notebook.uri, ranges: [{ start: 0, end: 1 }] });
await def.p;
});
test('Output changes are applied once the promise resolves', async function () {
let called = false;

View File

@@ -254,9 +254,6 @@ const _allApiProposals = {
notebookCellExecution: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecution.d.ts',
},
notebookCellExecutionState: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts',
},
notebookControllerAffinityHidden: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts',
},

View File

@@ -15,7 +15,7 @@ import { NotebookDto } from './mainThreadNotebookDto.js';
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
import { INotebookEditor } from '../../contrib/notebook/browser/notebookBrowser.js';
import { INotebookEditorService } from '../../contrib/notebook/browser/services/notebookEditorService.js';
import { INotebookCellExecution, INotebookExecution, INotebookExecutionStateService, NotebookExecutionType } from '../../contrib/notebook/common/notebookExecutionStateService.js';
import { INotebookCellExecution, INotebookExecution, INotebookExecutionStateService } from '../../contrib/notebook/common/notebookExecutionStateService.js';
import { IKernelSourceActionProvider, INotebookKernel, INotebookKernelChangeEvent, INotebookKernelDetectionTask, INotebookKernelService, VariablesResult } from '../../contrib/notebook/common/notebookKernelService.js';
import { SerializableObjectWithBuffers } from '../../services/extensions/common/proxyIdentifier.js';
import { ExtHostContext, ExtHostNotebookKernelsShape, ICellExecuteUpdateDto, ICellExecutionCompleteDto, INotebookKernelDto2, MainContext, MainThreadNotebookKernelsShape } from '../common/extHost.protocol.js';
@@ -146,12 +146,6 @@ export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape
this._notebookExecutions.forEach(e => e.complete());
}));
this._disposables.add(this._notebookExecutionStateService.onDidChangeExecution(e => {
if (e.type === NotebookExecutionType.cell) {
this._proxy.$cellExecutionChanged(e.notebook, e.cellHandle, e.changed?.state);
}
}));
this._disposables.add(this._notebookKernelService.onDidChangeSelectedNotebooks(e => {
for (const [handle, [kernel,]] of this._kernels) {
if (e.oldKernel === kernel.id) {

View File

@@ -1391,10 +1391,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension, 'notebookKernelSource');
return extHostNotebookKernels.registerKernelSourceActionProvider(extension, notebookType, provider);
},
onDidChangeNotebookCellExecutionState(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension, 'notebookCellExecutionState');
return _asExtensionEvent(extHostNotebookKernels.onDidChangeNotebookCellExecutionState)(listener, thisArgs, disposables);
}
};
// namespace: l10n

View File

@@ -2899,7 +2899,6 @@ export interface ExtHostNotebookKernelsShape {
$executeCells(handle: number, uri: UriComponents, handles: number[]): Promise<void>;
$cancelCells(handle: number, uri: UriComponents, handles: number[]): Promise<void>;
$acceptKernelMessageFromRenderer(handle: number, editorId: string, message: any): void;
$cellExecutionChanged(uri: UriComponents, cellHandle: number, state: notebookCommon.NotebookCellExecutionState | undefined): void;
$provideKernelSourceActions(handle: number, token: CancellationToken): Promise<notebookCommon.INotebookKernelSourceAction[]>;
$provideVariables(handle: number, requestId: string, notebookUri: UriComponents, parentId: number | undefined, kind: 'named' | 'indexed', start: number, token: CancellationToken): Promise<void>;
}

View File

@@ -18,9 +18,9 @@ import { IExtHostInitDataService } from './extHostInitDataService.js';
import { ExtHostNotebookController } from './extHostNotebook.js';
import { ExtHostCell, ExtHostNotebookDocument } from './extHostNotebookDocument.js';
import * as extHostTypeConverters from './extHostTypeConverters.js';
import { NotebookCellExecutionState as ExtHostNotebookCellExecutionState, NotebookCellOutput, NotebookControllerAffinity2, NotebookVariablesRequestKind } from './extHostTypes.js';
import { NotebookCellOutput, NotebookControllerAffinity2, NotebookVariablesRequestKind } from './extHostTypes.js';
import { asWebviewUri } from '../../contrib/webview/common/webview.js';
import { INotebookKernelSourceAction, NotebookCellExecutionState } from '../../contrib/notebook/common/notebookCommon.js';
import { INotebookKernelSourceAction } from '../../contrib/notebook/common/notebookCommon.js';
import { CellExecutionUpdateType } from '../../contrib/notebook/common/notebookExecutionService.js';
import { checkProposedApiEnabled } from '../../services/extensions/common/extensions.js';
import { SerializableObjectWithBuffers } from '../../services/extensions/common/proxyIdentifier.js';
@@ -55,9 +55,6 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
private readonly _kernelData = new Map<number, IKernelData>();
private _handlePool: number = 0;
private readonly _onDidChangeCellExecutionState = new Emitter<vscode.NotebookCellExecutionStateChangeEvent>();
readonly onDidChangeNotebookCellExecutionState = this._onDidChangeCellExecutionState.event;
constructor(
mainContext: IMainContext,
private readonly _initData: IExtHostInitDataService,
@@ -511,19 +508,6 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
obj.onDidReceiveMessage.fire(Object.freeze({ editor: editor.apiEditor, message }));
}
$cellExecutionChanged(uri: UriComponents, cellHandle: number, state: NotebookCellExecutionState | undefined): void {
const document = this._extHostNotebook.getNotebookDocument(URI.revive(uri));
const cell = document.getCell(cellHandle);
if (cell) {
const newState = state ? extHostTypeConverters.NotebookCellExecutionState.to(state) : ExtHostNotebookCellExecutionState.Idle;
if (newState !== undefined) {
this._onDidChangeCellExecutionState.fire({
cell: cell.apiCell,
state: newState
});
}
}
}
// ---

View File

@@ -1657,21 +1657,6 @@ export namespace NotebookCellExecutionSummary {
}
}
export namespace NotebookCellExecutionState {
export function to(state: notebooks.NotebookCellExecutionState): vscode.NotebookCellExecutionState | undefined {
if (state === notebooks.NotebookCellExecutionState.Unconfirmed) {
return types.NotebookCellExecutionState.Pending;
} else if (state === notebooks.NotebookCellExecutionState.Pending) {
// Since the (proposed) extension API doesn't have the distinction between Unconfirmed and Pending, we don't want to fire an update for Pending twice
return undefined;
} else if (state === notebooks.NotebookCellExecutionState.Executing) {
return types.NotebookCellExecutionState.Executing;
} else {
throw new Error(`Unknown state: ${state}`);
}
}
}
export namespace NotebookCellKind {
export function from(data: vscode.NotebookCellKind): notebooks.CellKind {
switch (data) {

View File

@@ -1,52 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/124970
/**
* The execution state of a notebook cell.
*/
export enum NotebookCellExecutionState {
/**
* The cell is idle.
*/
Idle = 1,
/**
* Execution for the cell is pending.
*/
Pending = 2,
/**
* The cell is currently executing.
*/
Executing = 3,
}
/**
* An event describing a cell execution state change.
*/
export interface NotebookCellExecutionStateChangeEvent {
/**
* The {@link NotebookCell cell} for which the execution state has changed.
*/
readonly cell: NotebookCell;
/**
* The new execution state of the cell.
*/
readonly state: NotebookCellExecutionState;
}
export namespace notebooks {
/**
* An {@link Event} which fires when the execution state of a cell has changed.
*/
// todo@API this is an event that is fired for a property that cells don't have and that makes me wonder
// how a correct consumer works, e.g the consumer could have been late and missed an event?
export const onDidChangeNotebookCellExecutionState: Event<NotebookCellExecutionStateChangeEvent>;
}
}