@codingame/monaco-vscode-a793b3ee-7ba9-5176-a019-30ec806fdd95-common 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. package/empty.js +1 -0
  2. package/package.json +50 -0
  3. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.d.ts +159 -0
  4. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +1318 -0
  5. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.d.ts +172 -0
  6. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +482 -0
  7. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +86 -0
  8. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +377 -0
  9. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.d.ts +70 -0
  10. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +456 -0
  11. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.d.ts +40 -0
  12. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.js +276 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.d.ts +22 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +318 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.d.ts +18 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +59 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.d.ts +69 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +318 -0
@@ -0,0 +1,276 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { addDisposableListener, Dimension } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
4
+ import { status } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/aria/aria';
5
+ import { toDisposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
7
+ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
8
+ import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
9
+ import { StableEditorBottomScrollState } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/stableEditorScroll';
10
+ import { EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
11
+ import { ScrollType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorCommon';
12
+ import { ZoneWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/zoneWidget/browser/zoneWidget';
13
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
14
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
15
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
16
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
17
+ import { isResponseVM } from '@codingame/monaco-vscode-c2deffc4-ad68-5e63-8f95-9b89e0fc6898-common/vscode/vs/workbench/contrib/chat/common/chatViewModel';
18
+ import { CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, MENU_INLINE_CHAT_SIDE, MENU_INLINE_CHAT_WIDGET_SECONDARY, ACTION_REGENERATE_RESPONSE, ACTION_TOGGLE_DIFF, ACTION_REPORT_ISSUE, MENU_INLINE_CHAT_WIDGET_STATUS } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
19
+ import { EditorBasedInlineChatWidget } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatWidget';
20
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
21
+
22
+ var InlineChatZoneWidget_1;
23
+ let InlineChatZoneWidget = class InlineChatZoneWidget extends ZoneWidget {
24
+ static { InlineChatZoneWidget_1 = this; }
25
+ static { this._options = {
26
+ showFrame: true,
27
+ frameWidth: 1,
28
+ isResizeable: true,
29
+ showArrow: false,
30
+ isAccessible: true,
31
+ className: 'inline-chat-widget',
32
+ keepEditorSelection: true,
33
+ showInHiddenAreas: true,
34
+ ordinal: 50000,
35
+ }; }
36
+ constructor(location, options, editors, _instaService, _logService, contextKeyService) {
37
+ super(editors.editor, InlineChatZoneWidget_1._options);
38
+ this._instaService = _instaService;
39
+ this._logService = _logService;
40
+ this._scrollUp = this._disposables.add(( new ScrollUpState(this.editor)));
41
+ this.notebookEditor = editors.notebookEditor;
42
+ this._ctxCursorPosition = CTX_INLINE_CHAT_OUTER_CURSOR_POSITION.bindTo(contextKeyService);
43
+ this._disposables.add(toDisposable(() => {
44
+ this._ctxCursorPosition.reset();
45
+ }));
46
+ this.widget = this._instaService.createInstance(EditorBasedInlineChatWidget, location, this.editor, {
47
+ statusMenuId: {
48
+ menu: MENU_INLINE_CHAT_WIDGET_STATUS,
49
+ options: {
50
+ buttonConfigProvider: (action, index) => {
51
+ const isSecondary = index > 0;
52
+ if (( ( new Set([ACTION_REGENERATE_RESPONSE, ACTION_TOGGLE_DIFF, ACTION_REPORT_ISSUE])).has(action.id))) {
53
+ return { isSecondary, showIcon: true, showLabel: false };
54
+ }
55
+ else {
56
+ return { isSecondary };
57
+ }
58
+ }
59
+ }
60
+ },
61
+ secondaryMenuId: MENU_INLINE_CHAT_WIDGET_SECONDARY,
62
+ inZoneWidget: true,
63
+ chatWidgetViewOptions: {
64
+ menus: {
65
+ telemetrySource: 'interactiveEditorWidget-toolbar',
66
+ inputSideToolbar: MENU_INLINE_CHAT_SIDE
67
+ },
68
+ ...options,
69
+ rendererOptions: {
70
+ renderTextEditsAsSummary: (uri) => {
71
+ return isEqual(uri, editors.editor.getModel()?.uri);
72
+ },
73
+ renderDetectedCommandsWithRequest: true,
74
+ ...options?.rendererOptions
75
+ },
76
+ }
77
+ });
78
+ this._disposables.add(this.widget);
79
+ let revealFn;
80
+ this._disposables.add(this.widget.chatWidget.onWillMaybeChangeHeight(() => {
81
+ if (this.position) {
82
+ revealFn = this._createZoneAndScrollRestoreFn(this.position);
83
+ }
84
+ }));
85
+ this._disposables.add(this.widget.onDidChangeHeight(() => {
86
+ if (this.position && !this._usesResizeHeight) {
87
+ revealFn ??= this._createZoneAndScrollRestoreFn(this.position);
88
+ const height = this._computeHeight();
89
+ this._relayout(height.linesValue);
90
+ revealFn?.();
91
+ revealFn = undefined;
92
+ }
93
+ }));
94
+ this.create();
95
+ this._disposables.add(autorun(r => {
96
+ const isBusy = this.widget.requestInProgress.read(r);
97
+ this.domNode.firstElementChild?.classList.toggle('busy', isBusy);
98
+ }));
99
+ this._disposables.add(addDisposableListener(this.domNode, 'click', e => {
100
+ if (!this.editor.hasWidgetFocus() && !this.widget.hasFocus()) {
101
+ this.editor.focus();
102
+ }
103
+ }, true));
104
+ const updateCursorIsAboveContextKey = () => {
105
+ if (!this.position || !this.editor.hasModel()) {
106
+ this._ctxCursorPosition.reset();
107
+ }
108
+ else if (this.position.lineNumber === this.editor.getPosition().lineNumber) {
109
+ this._ctxCursorPosition.set('above');
110
+ }
111
+ else if (this.position.lineNumber + 1 === this.editor.getPosition().lineNumber) {
112
+ this._ctxCursorPosition.set('below');
113
+ }
114
+ else {
115
+ this._ctxCursorPosition.reset();
116
+ }
117
+ };
118
+ this._disposables.add(this.editor.onDidChangeCursorPosition(e => updateCursorIsAboveContextKey()));
119
+ this._disposables.add(this.editor.onDidFocusEditorText(e => updateCursorIsAboveContextKey()));
120
+ updateCursorIsAboveContextKey();
121
+ }
122
+ _fillContainer(container) {
123
+ container.style.setProperty('--vscode-inlineChat-background', 'var(--vscode-editor-background)');
124
+ container.appendChild(this.widget.domNode);
125
+ }
126
+ _doLayout(heightInPixel) {
127
+ this._updatePadding();
128
+ const info = this.editor.getLayoutInfo();
129
+ const width = info.contentWidth - info.verticalScrollbarWidth;
130
+ this._dimension = ( new Dimension(width, heightInPixel));
131
+ this.widget.layout(this._dimension);
132
+ }
133
+ _computeHeight() {
134
+ const chatContentHeight = this.widget.contentHeight;
135
+ const editorHeight = this.notebookEditor?.getLayoutInfo().height ?? this.editor.getLayoutInfo().height;
136
+ const contentHeight = this._decoratingElementsHeight() + Math.min(chatContentHeight, Math.max(this.widget.minHeight, editorHeight * 0.42));
137
+ const heightInLines = contentHeight / this.editor.getOption(EditorOption.lineHeight);
138
+ return { linesValue: heightInLines, pixelsValue: contentHeight };
139
+ }
140
+ _getResizeBounds() {
141
+ const lineHeight = this.editor.getOption(EditorOption.lineHeight);
142
+ const decoHeight = this._decoratingElementsHeight();
143
+ const minHeightPx = decoHeight + this.widget.minHeight;
144
+ const maxHeightPx = decoHeight + this.widget.contentHeight;
145
+ return {
146
+ minLines: minHeightPx / lineHeight,
147
+ maxLines: maxHeightPx / lineHeight
148
+ };
149
+ }
150
+ _onWidth(_widthInPixel) {
151
+ if (this._dimension) {
152
+ this._doLayout(this._dimension.height);
153
+ }
154
+ }
155
+ show(position) {
156
+ assertType(this.container);
157
+ this._updatePadding();
158
+ const revealZone = this._createZoneAndScrollRestoreFn(position);
159
+ super.show(position, this._computeHeight().linesValue);
160
+ this.widget.chatWidget.setVisible(true);
161
+ this.widget.focus();
162
+ revealZone();
163
+ this._scrollUp.enable();
164
+ }
165
+ _updatePadding() {
166
+ assertType(this.container);
167
+ const info = this.editor.getLayoutInfo();
168
+ const marginWithoutIndentation = info.glyphMarginWidth + info.lineNumbersWidth + info.decorationsWidth;
169
+ this.container.style.paddingLeft = `${marginWithoutIndentation}px`;
170
+ }
171
+ reveal(position) {
172
+ const stickyScroll = this.editor.getOption(EditorOption.stickyScroll);
173
+ const magicValue = stickyScroll.enabled ? stickyScroll.maxLineCount : 0;
174
+ this.editor.revealLines(position.lineNumber + magicValue, position.lineNumber + magicValue, ScrollType.Immediate);
175
+ this._scrollUp.reset();
176
+ this.updatePositionAndHeight(position);
177
+ }
178
+ updatePositionAndHeight(position) {
179
+ const revealZone = this._createZoneAndScrollRestoreFn(position);
180
+ super.updatePositionAndHeight(position, !this._usesResizeHeight ? this._computeHeight().linesValue : undefined);
181
+ revealZone();
182
+ }
183
+ _createZoneAndScrollRestoreFn(position) {
184
+ const scrollState = StableEditorBottomScrollState.capture(this.editor);
185
+ const lineNumber = position.lineNumber <= 1 ? 1 : 1 + position.lineNumber;
186
+ const scrollTop = this.editor.getScrollTop();
187
+ const lineTop = this.editor.getTopForLineNumber(lineNumber);
188
+ const zoneTop = lineTop - this._computeHeight().pixelsValue;
189
+ const hasResponse = this.widget.chatWidget.viewModel?.getItems().find(candidate => {
190
+ return isResponseVM(candidate) && candidate.response.value.length > 0;
191
+ });
192
+ if (hasResponse && zoneTop < scrollTop || this._scrollUp.didScrollUpOrDown) {
193
+ return this._scrollUp.runIgnored(() => {
194
+ scrollState.restore(this.editor);
195
+ });
196
+ }
197
+ return this._scrollUp.runIgnored(() => {
198
+ scrollState.restore(this.editor);
199
+ const scrollTop = this.editor.getScrollTop();
200
+ const lineTop = this.editor.getTopForLineNumber(lineNumber);
201
+ const zoneTop = lineTop - this._computeHeight().pixelsValue;
202
+ const editorHeight = this.editor.getLayoutInfo().height;
203
+ const lineBottom = this.editor.getBottomForLineNumber(lineNumber);
204
+ let newScrollTop = zoneTop;
205
+ let forceScrollTop = false;
206
+ if (lineBottom >= (scrollTop + editorHeight)) {
207
+ newScrollTop = lineBottom - editorHeight;
208
+ forceScrollTop = true;
209
+ }
210
+ if (newScrollTop < scrollTop || forceScrollTop) {
211
+ this._logService.trace('[IE] REVEAL zone', { zoneTop, lineTop, lineBottom, scrollTop, newScrollTop, forceScrollTop });
212
+ this.editor.setScrollTop(newScrollTop, ScrollType.Immediate);
213
+ }
214
+ });
215
+ }
216
+ revealRange(range, isLastLine) {
217
+ }
218
+ hide() {
219
+ const scrollState = StableEditorBottomScrollState.capture(this.editor);
220
+ this._scrollUp.disable();
221
+ this._ctxCursorPosition.reset();
222
+ this.widget.reset();
223
+ this.widget.chatWidget.setVisible(false);
224
+ super.hide();
225
+ status(( localize(7693, 'Closed inline chat widget')));
226
+ scrollState.restore(this.editor);
227
+ }
228
+ };
229
+ InlineChatZoneWidget = InlineChatZoneWidget_1 = ( __decorate([
230
+ ( __param(3, IInstantiationService)),
231
+ ( __param(4, ILogService)),
232
+ ( __param(5, IContextKeyService))
233
+ ], InlineChatZoneWidget));
234
+ class ScrollUpState {
235
+ constructor(_editor) {
236
+ this._editor = _editor;
237
+ this._ignoreEvents = false;
238
+ this._listener = ( new MutableDisposable());
239
+ }
240
+ dispose() {
241
+ this._listener.dispose();
242
+ }
243
+ reset() {
244
+ this._didScrollUpOrDown = undefined;
245
+ }
246
+ enable() {
247
+ this._didScrollUpOrDown = undefined;
248
+ this._listener.value = this._editor.onDidScrollChange(e => {
249
+ if (!e.scrollTopChanged || this._ignoreEvents) {
250
+ return;
251
+ }
252
+ this._listener.clear();
253
+ this._didScrollUpOrDown = true;
254
+ });
255
+ }
256
+ disable() {
257
+ this._listener.clear();
258
+ this._didScrollUpOrDown = undefined;
259
+ }
260
+ runIgnored(callback) {
261
+ return () => {
262
+ this._ignoreEvents = true;
263
+ try {
264
+ return callback();
265
+ }
266
+ finally {
267
+ this._ignoreEvents = false;
268
+ }
269
+ };
270
+ }
271
+ get didScrollUpOrDown() {
272
+ return this._didScrollUpOrDown;
273
+ }
274
+ }
275
+
276
+ export { InlineChatZoneWidget };
@@ -0,0 +1,22 @@
1
+ import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
3
+ import { ICellViewModel, INotebookEditor, INotebookEditorContribution, INotebookViewModel } from "@codingame/monaco-vscode-670aae94-7f88-54d7-90ea-6fcbef423557-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
4
+ export declare function formatCellDuration(duration: number, showMilliseconds?: boolean): string;
5
+ export declare class NotebookStatusBarController extends Disposable {
6
+ private readonly _notebookEditor;
7
+ private readonly _itemFactory;
8
+ private readonly _visibleCells;
9
+ private readonly _observer;
10
+ constructor(_notebookEditor: INotebookEditor, _itemFactory: (vm: INotebookViewModel, cell: ICellViewModel) => IDisposable);
11
+ private _updateEverything;
12
+ private _updateVisibleCells;
13
+ dispose(): void;
14
+ }
15
+ export declare class ExecutionStateCellStatusBarContrib extends Disposable implements INotebookEditorContribution {
16
+ static id: string;
17
+ constructor(notebookEditor: INotebookEditor, instantiationService: IInstantiationService);
18
+ }
19
+ export declare class TimerCellStatusBarContrib extends Disposable implements INotebookEditorContribution {
20
+ static id: string;
21
+ constructor(notebookEditor: INotebookEditor, instantiationService: IInstantiationService);
22
+ }
@@ -0,0 +1,318 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { disposableTimeout, RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
+ import { Disposable, dispose, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
5
+ import { language } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
6
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
7
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
8
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { themeColorFromId } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService';
10
+ import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
11
+ import { NotebookVisibleCellObserver } from './notebookVisibleCellObserver.js';
12
+ import { registerNotebookContribution } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
13
+ import { cellStatusIconSuccess, cellStatusIconError } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookEditorWidget';
14
+ import { successStateIcon, errorStateIcon, pendingStateIcon, executingStateIcon } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
15
+ import { NotebookCellExecutionState, CellStatusbarAlignment, NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
16
+ import { NotebookExecutionType } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
17
+ import { INotebookExecutionStateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
18
+ import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
19
+
20
+ var ExecutionStateCellStatusBarItem_1, TimerCellStatusBarItem_1;
21
+ function formatCellDuration(duration, showMilliseconds = true) {
22
+ if (showMilliseconds && duration < 1000) {
23
+ return `${duration}ms`;
24
+ }
25
+ const minutes = Math.floor(duration / 1000 / 60);
26
+ const seconds = Math.floor(duration / 1000) % 60;
27
+ const tenths = Math.floor((duration % 1000) / 100);
28
+ if (minutes > 0) {
29
+ return `${minutes}m ${seconds}.${tenths}s`;
30
+ }
31
+ else {
32
+ return `${seconds}.${tenths}s`;
33
+ }
34
+ }
35
+ class NotebookStatusBarController extends Disposable {
36
+ constructor(_notebookEditor, _itemFactory) {
37
+ super();
38
+ this._notebookEditor = _notebookEditor;
39
+ this._itemFactory = _itemFactory;
40
+ this._visibleCells = ( new Map());
41
+ this._observer = this._register(( new NotebookVisibleCellObserver(this._notebookEditor)));
42
+ this._register(this._observer.onDidChangeVisibleCells(this._updateVisibleCells, this));
43
+ this._updateEverything();
44
+ }
45
+ _updateEverything() {
46
+ this._visibleCells.forEach(dispose);
47
+ this._visibleCells.clear();
48
+ this._updateVisibleCells({ added: this._observer.visibleCells, removed: [] });
49
+ }
50
+ _updateVisibleCells(e) {
51
+ const vm = this._notebookEditor.getViewModel();
52
+ if (!vm) {
53
+ return;
54
+ }
55
+ for (const oldCell of e.removed) {
56
+ this._visibleCells.get(oldCell.handle)?.dispose();
57
+ this._visibleCells.delete(oldCell.handle);
58
+ }
59
+ for (const newCell of e.added) {
60
+ this._visibleCells.set(newCell.handle, this._itemFactory(vm, newCell));
61
+ }
62
+ }
63
+ dispose() {
64
+ super.dispose();
65
+ this._visibleCells.forEach(dispose);
66
+ this._visibleCells.clear();
67
+ }
68
+ }
69
+ let ExecutionStateCellStatusBarContrib = class ExecutionStateCellStatusBarContrib extends Disposable {
70
+ static { this.id = 'workbench.notebook.statusBar.execState'; }
71
+ constructor(notebookEditor, instantiationService) {
72
+ super();
73
+ this._register(( new NotebookStatusBarController(
74
+ notebookEditor,
75
+ (vm, cell) => instantiationService.createInstance(ExecutionStateCellStatusBarItem, vm, cell)
76
+ )));
77
+ }
78
+ };
79
+ ExecutionStateCellStatusBarContrib = ( __decorate([
80
+ ( __param(1, IInstantiationService))
81
+ ], ExecutionStateCellStatusBarContrib));
82
+ registerNotebookContribution(ExecutionStateCellStatusBarContrib.id, ExecutionStateCellStatusBarContrib);
83
+ let ExecutionStateCellStatusBarItem = class ExecutionStateCellStatusBarItem extends Disposable {
84
+ static { ExecutionStateCellStatusBarItem_1 = this; }
85
+ static { this.MIN_SPINNER_TIME = 500; }
86
+ constructor(_notebookViewModel, _cell, _executionStateService) {
87
+ super();
88
+ this._notebookViewModel = _notebookViewModel;
89
+ this._cell = _cell;
90
+ this._executionStateService = _executionStateService;
91
+ this._currentItemIds = [];
92
+ this._clearExecutingStateTimer = this._register(( new MutableDisposable()));
93
+ this._update();
94
+ this._register(this._executionStateService.onDidChangeExecution(e => {
95
+ if (e.type === NotebookExecutionType.cell && e.affectsCell(this._cell.uri)) {
96
+ this._update();
97
+ }
98
+ }));
99
+ this._register(this._cell.model.onDidChangeInternalMetadata(() => this._update()));
100
+ }
101
+ async _update() {
102
+ const items = this._getItemsForCell();
103
+ if (Array.isArray(items)) {
104
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
105
+ }
106
+ }
107
+ _getItemsForCell() {
108
+ const runState = this._executionStateService.getCellExecution(this._cell.uri);
109
+ if (runState?.state === NotebookCellExecutionState.Executing && typeof this._showedExecutingStateTime !== 'number') {
110
+ this._showedExecutingStateTime = Date.now();
111
+ }
112
+ else if (runState?.state !== NotebookCellExecutionState.Executing && typeof this._showedExecutingStateTime === 'number') {
113
+ const timeUntilMin = ExecutionStateCellStatusBarItem_1.MIN_SPINNER_TIME - (Date.now() - this._showedExecutingStateTime);
114
+ if (timeUntilMin > 0) {
115
+ if (!this._clearExecutingStateTimer.value) {
116
+ this._clearExecutingStateTimer.value = disposableTimeout(() => {
117
+ this._showedExecutingStateTime = undefined;
118
+ this._clearExecutingStateTimer.clear();
119
+ this._update();
120
+ }, timeUntilMin);
121
+ }
122
+ return undefined;
123
+ }
124
+ else {
125
+ this._showedExecutingStateTime = undefined;
126
+ }
127
+ }
128
+ const items = this._getItemForState(runState, this._cell.internalMetadata);
129
+ return items;
130
+ }
131
+ _getItemForState(runState, internalMetadata) {
132
+ const state = runState?.state;
133
+ const { lastRunSuccess } = internalMetadata;
134
+ if (!state && lastRunSuccess) {
135
+ return [{
136
+ text: `$(${successStateIcon.id})`,
137
+ color: themeColorFromId(cellStatusIconSuccess),
138
+ tooltip: ( localize(8544, "Success")),
139
+ alignment: CellStatusbarAlignment.Left,
140
+ priority: Number.MAX_SAFE_INTEGER
141
+ }];
142
+ }
143
+ else if (!state && lastRunSuccess === false) {
144
+ return [{
145
+ text: `$(${errorStateIcon.id})`,
146
+ color: themeColorFromId(cellStatusIconError),
147
+ tooltip: ( localize(8545, "Failed")),
148
+ alignment: CellStatusbarAlignment.Left,
149
+ priority: Number.MAX_SAFE_INTEGER
150
+ }];
151
+ }
152
+ else if (state === NotebookCellExecutionState.Pending || state === NotebookCellExecutionState.Unconfirmed) {
153
+ return [{
154
+ text: `$(${pendingStateIcon.id})`,
155
+ tooltip: ( localize(8546, "Pending")),
156
+ alignment: CellStatusbarAlignment.Left,
157
+ priority: Number.MAX_SAFE_INTEGER
158
+ }];
159
+ }
160
+ else if (state === NotebookCellExecutionState.Executing) {
161
+ const icon = runState?.didPause ?
162
+ executingStateIcon :
163
+ ThemeIcon.modify(executingStateIcon, 'spin');
164
+ return [{
165
+ text: `$(${icon.id})`,
166
+ tooltip: ( localize(8547, "Executing")),
167
+ alignment: CellStatusbarAlignment.Left,
168
+ priority: Number.MAX_SAFE_INTEGER
169
+ }];
170
+ }
171
+ return [];
172
+ }
173
+ dispose() {
174
+ super.dispose();
175
+ this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items: [] }]);
176
+ }
177
+ };
178
+ ExecutionStateCellStatusBarItem = ExecutionStateCellStatusBarItem_1 = ( __decorate([
179
+ ( __param(2, INotebookExecutionStateService))
180
+ ], ExecutionStateCellStatusBarItem));
181
+ let TimerCellStatusBarContrib = class TimerCellStatusBarContrib extends Disposable {
182
+ static { this.id = 'workbench.notebook.statusBar.execTimer'; }
183
+ constructor(notebookEditor, instantiationService) {
184
+ super();
185
+ this._register(( new NotebookStatusBarController(
186
+ notebookEditor,
187
+ (vm, cell) => instantiationService.createInstance(TimerCellStatusBarItem, vm, cell)
188
+ )));
189
+ }
190
+ };
191
+ TimerCellStatusBarContrib = ( __decorate([
192
+ ( __param(1, IInstantiationService))
193
+ ], TimerCellStatusBarContrib));
194
+ registerNotebookContribution(TimerCellStatusBarContrib.id, TimerCellStatusBarContrib);
195
+ const UPDATE_TIMER_GRACE_PERIOD = 200;
196
+ let TimerCellStatusBarItem = class TimerCellStatusBarItem extends Disposable {
197
+ static { TimerCellStatusBarItem_1 = this; }
198
+ static { this.UPDATE_INTERVAL = 100; }
199
+ constructor(_notebookViewModel, _cell, _executionStateService, _notebookService, _configurationService) {
200
+ super();
201
+ this._notebookViewModel = _notebookViewModel;
202
+ this._cell = _cell;
203
+ this._executionStateService = _executionStateService;
204
+ this._notebookService = _notebookService;
205
+ this._configurationService = _configurationService;
206
+ this._currentItemIds = [];
207
+ this._isVerbose = this._configurationService.getValue(NotebookSetting.cellExecutionTimeVerbosity) === 'verbose';
208
+ this._scheduler = this._register(( new RunOnceScheduler(() => this._update(), TimerCellStatusBarItem_1.UPDATE_INTERVAL)));
209
+ this._update();
210
+ this._register(this._cell.model.onDidChangeInternalMetadata(() => this._update()));
211
+ this._register(this._configurationService.onDidChangeConfiguration(e => {
212
+ if (e.affectsConfiguration(NotebookSetting.cellExecutionTimeVerbosity)) {
213
+ this._isVerbose = this._configurationService.getValue(NotebookSetting.cellExecutionTimeVerbosity) === 'verbose';
214
+ this._update();
215
+ }
216
+ }));
217
+ }
218
+ async _update() {
219
+ let timerItem;
220
+ const runState = this._executionStateService.getCellExecution(this._cell.uri);
221
+ const state = runState?.state;
222
+ const startTime = this._cell.internalMetadata.runStartTime;
223
+ const adjustment = this._cell.internalMetadata.runStartTimeAdjustment ?? 0;
224
+ const endTime = this._cell.internalMetadata.runEndTime;
225
+ if (runState?.didPause) {
226
+ timerItem = undefined;
227
+ }
228
+ else if (state === NotebookCellExecutionState.Executing) {
229
+ if (typeof startTime === 'number') {
230
+ timerItem = this._getTimeItem(startTime, Date.now(), adjustment);
231
+ this._scheduler.schedule();
232
+ }
233
+ }
234
+ else if (!state) {
235
+ if (typeof startTime === 'number' && typeof endTime === 'number') {
236
+ const timerDuration = Date.now() - startTime + adjustment;
237
+ const executionDuration = endTime - startTime;
238
+ const renderDuration = this._cell.internalMetadata.renderDuration ?? {};
239
+ timerItem = this._getTimeItem(startTime, endTime, undefined, {
240
+ timerDuration,
241
+ executionDuration,
242
+ renderDuration
243
+ });
244
+ }
245
+ }
246
+ const items = timerItem ? [timerItem] : [];
247
+ if (!items.length && !!runState) {
248
+ if (!this._deferredUpdate) {
249
+ this._deferredUpdate = disposableTimeout(() => {
250
+ this._deferredUpdate = undefined;
251
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
252
+ }, UPDATE_TIMER_GRACE_PERIOD, this._store);
253
+ }
254
+ }
255
+ else {
256
+ this._deferredUpdate?.dispose();
257
+ this._deferredUpdate = undefined;
258
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
259
+ }
260
+ }
261
+ _getTimeItem(startTime, endTime, adjustment = 0, runtimeInformation) {
262
+ const duration = endTime - startTime + adjustment;
263
+ let tooltip;
264
+ const lastExecution = ( new Date(endTime)).toLocaleTimeString(language);
265
+ if (runtimeInformation) {
266
+ const { renderDuration, executionDuration, timerDuration } = runtimeInformation;
267
+ let renderTimes = '';
268
+ for (const key in renderDuration) {
269
+ const rendererInfo = this._notebookService.getRendererInfo(key);
270
+ const args = encodeURIComponent(JSON.stringify({
271
+ extensionId: rendererInfo?.extensionId.value ?? '',
272
+ issueBody: `Auto-generated text from notebook cell performance. The duration for the renderer, ${rendererInfo?.displayName ?? key}, is slower than expected.\n` +
273
+ `Execution Time: ${formatCellDuration(executionDuration)}\n` +
274
+ `Renderer Duration: ${formatCellDuration(renderDuration[key])}\n`
275
+ }));
276
+ renderTimes += `- [${rendererInfo?.displayName ?? key}](command:workbench.action.openIssueReporter?${args}) ${formatCellDuration(renderDuration[key])}\n`;
277
+ }
278
+ renderTimes += `\n*${( localize(8548, "Use the links above to file an issue using the issue reporter."))}*\n`;
279
+ tooltip = {
280
+ value: ( localize(
281
+ 8549,
282
+ "**Last Execution** {0}\n\n**Execution Time** {1}\n\n**Overhead Time** {2}\n\n**Render Times**\n\n{3}",
283
+ lastExecution,
284
+ formatCellDuration(executionDuration),
285
+ formatCellDuration(timerDuration - executionDuration),
286
+ renderTimes
287
+ )),
288
+ isTrusted: true
289
+ };
290
+ }
291
+ const executionText = this._isVerbose ?
292
+ ( localize(
293
+ 8550,
294
+ "Last Execution: {0}, Duration: {1}",
295
+ lastExecution,
296
+ formatCellDuration(duration, false)
297
+ )) :
298
+ formatCellDuration(duration, false);
299
+ return {
300
+ text: executionText,
301
+ alignment: CellStatusbarAlignment.Left,
302
+ priority: Number.MAX_SAFE_INTEGER - 5,
303
+ tooltip
304
+ };
305
+ }
306
+ dispose() {
307
+ super.dispose();
308
+ this._deferredUpdate?.dispose();
309
+ this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items: [] }]);
310
+ }
311
+ };
312
+ TimerCellStatusBarItem = TimerCellStatusBarItem_1 = ( __decorate([
313
+ ( __param(2, INotebookExecutionStateService)),
314
+ ( __param(3, INotebookService)),
315
+ ( __param(4, IConfigurationService))
316
+ ], TimerCellStatusBarItem));
317
+
318
+ export { ExecutionStateCellStatusBarContrib, NotebookStatusBarController, TimerCellStatusBarContrib, formatCellDuration };
@@ -0,0 +1,18 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { ICellViewModel, INotebookEditor } from "@codingame/monaco-vscode-670aae94-7f88-54d7-90ea-6fcbef423557-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
3
+ export interface ICellVisibilityChangeEvent {
4
+ added: ICellViewModel[];
5
+ removed: ICellViewModel[];
6
+ }
7
+ export declare class NotebookVisibleCellObserver extends Disposable {
8
+ private readonly _notebookEditor;
9
+ private readonly _onDidChangeVisibleCells;
10
+ readonly onDidChangeVisibleCells: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<ICellVisibilityChangeEvent>;
11
+ private readonly _viewModelDisposables;
12
+ private _visibleCells;
13
+ get visibleCells(): ICellViewModel[];
14
+ constructor(_notebookEditor: INotebookEditor);
15
+ private _onModelChange;
16
+ protected updateEverything(): void;
17
+ private _updateVisibleCells;
18
+ }