diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index f1489879e81..8b96161afd9 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -988,15 +988,16 @@ declare module 'vscode' { // todo@API duplicates status bar API readonly statusMessage?: string; - constructor(editable?: boolean, breakpointMargin?: boolean, statusMessage?: string, lastRunDuration?: number, inputCollapsed?: boolean, outputCollapsed?: boolean, custom?: Record) + constructor(editable?: boolean, breakpointMargin?: boolean, statusMessage?: string, inputCollapsed?: boolean, outputCollapsed?: boolean, custom?: Record) - with(change: { editable?: boolean | null, breakpointMargin?: boolean | null, statusMessage?: string | null, lastRunDuration?: number | null, inputCollapsed?: boolean | null, outputCollapsed?: boolean | null, custom?: Record | null, }): NotebookCellMetadata; + with(change: { editable?: boolean | null, breakpointMargin?: boolean | null, statusMessage?: string | null, inputCollapsed?: boolean | null, outputCollapsed?: boolean | null, custom?: Record | null, }): NotebookCellMetadata; } export interface NotebookCellExecutionSummary { executionOrder?: number; success?: boolean; - duration?: number; + startTime?: number; + endTime?: number; } // todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md @@ -1648,7 +1649,6 @@ declare module 'vscode' { } export interface NotebookCellExecuteStartContext { - // TODO@roblou are we concerned about clock issues with this absolute time? /** * The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock * that shows for how long a cell has been running. If not given, the clock won't be shown. @@ -1664,9 +1664,9 @@ declare module 'vscode' { success?: boolean; /** - * The total execution time in milliseconds. + * The time that execution finished, in milliseconds in the Unix epoch. */ - duration?: number; + endTime?: number; } /** diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 68618446c2d..43c6f6df2c3 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -1027,7 +1027,6 @@ class NotebookCellExecutionTask extends Disposable { this._executionOrder = _cell.internalMetadata.executionOrder; this.mixinMetadata({ runState: extHostTypes.NotebookCellExecutionState.Pending, - lastRunDuration: null, executionOrder: null }); } @@ -1105,7 +1104,7 @@ class NotebookCellExecutionTask extends Disposable { that.mixinMetadata({ runState: extHostTypes.NotebookCellExecutionState.Idle, lastRunSuccess: result?.success ?? null, - lastRunDuration: result?.duration ?? null, + runEndTime: result?.endTime ?? null, }); }, diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 82c989a0199..18f6adaadcb 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -1437,7 +1437,8 @@ export namespace NotebookDocumentMetadata { export namespace NotebookCellPreviousExecutionResult { export function to(data: notebooks.NotebookCellMetadata): vscode.NotebookCellExecutionSummary { return { - duration: data.lastRunDuration, + startTime: data.runStartTime, + endTime: data.runEndTime, executionOrder: data.executionOrder, success: data.lastRunSuccess }; @@ -1446,7 +1447,7 @@ export namespace NotebookCellPreviousExecutionResult { export function from(data: vscode.NotebookCellExecutionSummary): Partial { return { lastRunSuccess: data.success, - lastRunDuration: data.duration, + runEndTime: data.endTime, executionOrder: data.executionOrder }; } @@ -1634,10 +1635,10 @@ export namespace NotebookDocumentContentOptions { transientMetadata: { ...options?.transientMetadata, executionOrder: true, - lastRunDuration: true, runState: true, runStartTime: true, runStartTimeAdjustment: true, + runEndTime: true, lastRunSuccess: true } }; diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index f6983355356..49537cfb0ca 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -1319,7 +1319,7 @@ registerAction2(class extends NotebookCellAction { runState: NotebookCellExecutionState.Idle, runStartTime: undefined, runStartTimeAdjustment: undefined, - lastRunDuration: undefined, + runEndTime: undefined, statusMessage: undefined, executionOrder: undefined } diff --git a/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts index ef67f19dd33..3ad6a241475 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts @@ -494,7 +494,6 @@ abstract class AbstractElementRenderer extends Disposable { break; case 'executionOrder': - case 'lastRunDuration': // number if (typeof newMetadataObj[key] === 'number') { result[key] = newMetadataObj[key]; diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts index cfd93d3dc0d..d944c62e5a7 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts @@ -848,8 +848,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende } else { templateData.timer.clear(); } - } else if (typeof metadata.lastRunDuration === 'number') { - templateData.timer.show(metadata.lastRunDuration); + } else if (metadata.runState === NotebookCellExecutionState.Idle && metadata.runStartTime && metadata.runEndTime) { + templateData.timer.show(metadata.runEndTime - metadata.runStartTime); } else { templateData.timer.clear(); } diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 782944efeac..7cbcbffcfc8 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -91,7 +91,7 @@ export interface NotebookCellMetadata { runState?: NotebookCellExecutionState; runStartTime?: number; runStartTimeAdjustment?: number; - lastRunDuration?: number; + runEndTime?: number; inputCollapsed?: boolean; outputCollapsed?: boolean; custom?: { [key: string]: unknown };