@opensumi/ide-ai-native 3.7.1-next-1738979076.0 → 3.7.1-next-1738980928.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.
- package/lib/browser/layout/layout.module.less +9 -9
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +6 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/types.d.ts +2 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +0 -5
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +7 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +5 -3
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +14 -10
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +3 -0
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +89 -45
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/model.d.ts +19 -1
- package/lib/browser/widget/inline-input/model.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/model.js +39 -1
- package/lib/browser/widget/inline-input/model.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +3 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +2 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/package.json +21 -21
- package/src/browser/layout/layout.module.less +9 -9
- package/src/browser/layout/tabbar.view.tsx +8 -10
- package/src/browser/types.ts +2 -2
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +0 -7
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +5 -1
- package/src/browser/widget/inline-input/inline-input-widget.tsx +14 -5
- package/src/browser/widget/inline-input/inline-input.controller.ts +132 -52
- package/src/browser/widget/inline-input/model.ts +41 -1
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +3 -1
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +2 -1
|
@@ -15,6 +15,13 @@ import {
|
|
|
15
15
|
import { EditorGroupCloseEvent } from '@opensumi/ide-editor/lib/browser';
|
|
16
16
|
import * as monaco from '@opensumi/ide-monaco';
|
|
17
17
|
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
18
|
+
import {
|
|
19
|
+
IObservable,
|
|
20
|
+
ISettableObservable,
|
|
21
|
+
autorun,
|
|
22
|
+
observableFromEvent,
|
|
23
|
+
observableValue,
|
|
24
|
+
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
18
25
|
import { MessageService } from '@opensumi/ide-overlay/lib/browser/message.service';
|
|
19
26
|
import { EditOperation } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/editOperation';
|
|
20
27
|
import { LineRange } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/lineRange';
|
|
@@ -28,10 +35,10 @@ import { EInlineChatStatus, EResultKind } from '../inline-chat/inline-chat.servi
|
|
|
28
35
|
import { InlineDiffController } from '../inline-diff';
|
|
29
36
|
import { InlineInputPreviewDecorationID } from '../internal.type';
|
|
30
37
|
|
|
31
|
-
import {
|
|
38
|
+
import { InlineInputWidget } from './inline-input-widget';
|
|
32
39
|
import styles from './inline-input.module.less';
|
|
33
40
|
import { InlineInputService } from './inline-input.service';
|
|
34
|
-
|
|
41
|
+
import { InlineInputWidgetStoreInEmptyLine, InlineInputWidgetStoreInSelection } from './model';
|
|
35
42
|
@Injectable()
|
|
36
43
|
export class InlineInputController extends BaseAIMonacoEditorController {
|
|
37
44
|
public static readonly ID = 'editor.contrib.ai.inline.input';
|
|
@@ -60,11 +67,26 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
60
67
|
private inputDisposable: Disposable;
|
|
61
68
|
private aiNativeContextKey: AINativeContextKey;
|
|
62
69
|
|
|
70
|
+
private inputValue: ISettableObservable<string>;
|
|
71
|
+
private modelChangeObs: IObservable<monaco.editor.ITextModel, unknown>;
|
|
72
|
+
private inlineInputWidgetStore: Map<
|
|
73
|
+
string,
|
|
74
|
+
InlineInputWidgetStoreInEmptyLine | InlineInputWidgetStoreInSelection | null
|
|
75
|
+
>;
|
|
76
|
+
|
|
63
77
|
mount(): IDisposable {
|
|
64
78
|
this.inputDisposable = new Disposable();
|
|
65
79
|
this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
66
80
|
this.inlineDiffController = InlineDiffController.get(this.monacoEditor)!;
|
|
67
81
|
|
|
82
|
+
this.inputValue = observableValue(this, '');
|
|
83
|
+
this.modelChangeObs = observableFromEvent<monaco.editor.ITextModel>(
|
|
84
|
+
this,
|
|
85
|
+
this.monacoEditor.onDidChangeModel,
|
|
86
|
+
() => this.monacoEditor.getModel()!,
|
|
87
|
+
);
|
|
88
|
+
this.inlineInputWidgetStore = new Map();
|
|
89
|
+
|
|
68
90
|
this.featureDisposable.addDispose(
|
|
69
91
|
/**
|
|
70
92
|
* 如果在流式过程中,直接关闭了当前文件,则需要销毁 diff previewer 并隐藏 input,恢复原始代码
|
|
@@ -91,10 +113,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
91
113
|
);
|
|
92
114
|
|
|
93
115
|
this.featureDisposable.addDispose(
|
|
94
|
-
|
|
95
|
-
this.inlineInputService.onHidden,
|
|
96
|
-
this.monacoEditor.onWillChangeModel,
|
|
97
|
-
)(() => {
|
|
116
|
+
this.inlineInputService.onHidden(() => {
|
|
98
117
|
this.hideInput();
|
|
99
118
|
}),
|
|
100
119
|
);
|
|
@@ -119,6 +138,27 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
119
138
|
}),
|
|
120
139
|
);
|
|
121
140
|
|
|
141
|
+
this.featureDisposable.addDispose(
|
|
142
|
+
autorun((reader) => {
|
|
143
|
+
const model = this.modelChangeObs.read(reader);
|
|
144
|
+
if (!model) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const storeData = this.inlineInputWidgetStore.get(model.id);
|
|
149
|
+
if (!storeData) {
|
|
150
|
+
this.hideInput();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (storeData instanceof InlineInputWidgetStoreInEmptyLine) {
|
|
155
|
+
this.showInputInEmptyLine(storeData.getPosition(), this.monacoEditor, storeData.getValue());
|
|
156
|
+
} else if (storeData instanceof InlineInputWidgetStoreInSelection) {
|
|
157
|
+
this.showInputInSelection(storeData.getSelection(), this.monacoEditor, storeData.getValue());
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
|
|
122
162
|
this.featureDisposable.addDispose(this.inputDisposable);
|
|
123
163
|
|
|
124
164
|
return this.featureDisposable;
|
|
@@ -130,6 +170,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
130
170
|
}
|
|
131
171
|
|
|
132
172
|
private hideInput() {
|
|
173
|
+
this.inlineInputWidgetStore.delete(this.monacoEditor.getModel()!.id);
|
|
133
174
|
this.inputDisposable.dispose();
|
|
134
175
|
}
|
|
135
176
|
|
|
@@ -145,15 +186,16 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
145
186
|
return;
|
|
146
187
|
}
|
|
147
188
|
|
|
189
|
+
this.inputValue.set(defaultValue || '', undefined);
|
|
190
|
+
this.inlineInputWidgetStore.set(model.id, new InlineInputWidgetStoreInEmptyLine(position, defaultValue));
|
|
191
|
+
|
|
148
192
|
if (this.inputDisposable) {
|
|
149
193
|
this.inputDisposable.dispose();
|
|
150
194
|
this.inputDisposable = new Disposable();
|
|
151
195
|
}
|
|
152
196
|
|
|
153
197
|
const collection = monacoEditor.createDecorationsCollection();
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
let inputValue = defaultValue;
|
|
198
|
+
const inlineInputWidget = this.injector.get(InlineInputWidget, [monacoEditor, this.inputValue.get()]);
|
|
157
199
|
|
|
158
200
|
// 仅在空行情况下增加装饰逻辑
|
|
159
201
|
collection.append([
|
|
@@ -172,12 +214,12 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
172
214
|
let preLineRange: LineRange;
|
|
173
215
|
if (decorationRange) {
|
|
174
216
|
preLineRange = LineRange.fromRange(decorationRange);
|
|
175
|
-
|
|
217
|
+
inlineInputWidget.show({ position: decorationRange.getStartPosition() });
|
|
176
218
|
this.aiNativeContextKey.inlineInputWidgetIsVisible.set(true);
|
|
177
219
|
}
|
|
178
220
|
|
|
179
221
|
this.inputDisposable.addDispose(
|
|
180
|
-
|
|
222
|
+
inlineInputWidget.onDispose(() => {
|
|
181
223
|
this.cancelToken();
|
|
182
224
|
collection.clear();
|
|
183
225
|
this.aiNativeContextKey.inlineInputWidgetIsVisible.set(false);
|
|
@@ -185,7 +227,18 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
185
227
|
);
|
|
186
228
|
|
|
187
229
|
this.inputDisposable.addDispose(
|
|
188
|
-
|
|
230
|
+
inlineInputWidget.onValueChange((value) => {
|
|
231
|
+
this.inputValue.set(value, undefined);
|
|
232
|
+
|
|
233
|
+
const storeData = this.inlineInputWidgetStore.get(model.id);
|
|
234
|
+
if (storeData instanceof InlineInputWidgetStoreInEmptyLine) {
|
|
235
|
+
storeData.setValue(value);
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
this.inputDisposable.addDispose(
|
|
241
|
+
inlineInputWidget.onResultClick(async (kind: EResultKind) => {
|
|
189
242
|
const clear = () => {
|
|
190
243
|
const curPosi = collection.getRange(0)!;
|
|
191
244
|
|
|
@@ -210,7 +263,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
210
263
|
*/
|
|
211
264
|
const curPosi = collection.getRange(0)!;
|
|
212
265
|
const curPosition = curPosi.getStartPosition();
|
|
213
|
-
this.showInputInEmptyLine(curPosition, monacoEditor, inputValue);
|
|
266
|
+
this.showInputInEmptyLine(curPosition, monacoEditor, this.inputValue.get());
|
|
214
267
|
});
|
|
215
268
|
break;
|
|
216
269
|
|
|
@@ -233,18 +286,18 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
233
286
|
const range = collection.getRange(0)!;
|
|
234
287
|
const curLineRange = LineRange.fromRange(range);
|
|
235
288
|
if (!preLineRange.equals(curLineRange)) {
|
|
236
|
-
|
|
289
|
+
inlineInputWidget.setOptions({
|
|
237
290
|
position: range.getStartPosition(),
|
|
238
291
|
});
|
|
239
292
|
|
|
240
|
-
|
|
293
|
+
inlineInputWidget.layoutContentWidget();
|
|
241
294
|
}
|
|
242
295
|
preLineRange = curLineRange;
|
|
243
296
|
}),
|
|
244
297
|
);
|
|
245
298
|
|
|
246
299
|
this.inputDisposable.addDispose(
|
|
247
|
-
|
|
300
|
+
inlineInputWidget.onClose(() => {
|
|
248
301
|
const isStreaming = this.aiNativeContextKey.inlineInputWidgetIsStreaming.get();
|
|
249
302
|
if (isStreaming) {
|
|
250
303
|
this.cancelToken();
|
|
@@ -255,8 +308,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
255
308
|
);
|
|
256
309
|
|
|
257
310
|
this.inputDisposable.addDispose(
|
|
258
|
-
|
|
259
|
-
inputValue = value;
|
|
311
|
+
inlineInputWidget.onSend(async (value) => {
|
|
260
312
|
monacoEditor.focus();
|
|
261
313
|
|
|
262
314
|
const handler = this.inlineInputService.getInteractiveInputHandler();
|
|
@@ -266,22 +318,23 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
266
318
|
return;
|
|
267
319
|
}
|
|
268
320
|
|
|
269
|
-
|
|
321
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.THINKING);
|
|
270
322
|
|
|
271
323
|
const strategy = await this.inlineInputService.getInteractiveInputStrategyHandler()(monacoEditor, value);
|
|
324
|
+
const selection = monaco.Selection.fromPositions(position);
|
|
272
325
|
|
|
273
326
|
if (strategy === ERunStrategy.EXECUTE && handler.execute) {
|
|
274
|
-
handler.execute(monacoEditor, value, this.token);
|
|
275
|
-
|
|
327
|
+
handler.execute(monacoEditor, selection, value, this.token);
|
|
328
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
276
329
|
this.hideInput();
|
|
277
330
|
return;
|
|
278
331
|
}
|
|
279
332
|
|
|
280
333
|
if (strategy === ERunStrategy.PREVIEW && handler.providePreviewStrategy) {
|
|
281
|
-
const previewResponse = await handler.providePreviewStrategy(monacoEditor, value, this.token);
|
|
334
|
+
const previewResponse = await handler.providePreviewStrategy(monacoEditor, selection, value, this.token);
|
|
282
335
|
|
|
283
336
|
if (CancelResponse.is(previewResponse)) {
|
|
284
|
-
|
|
337
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.READY);
|
|
285
338
|
this.hideInput();
|
|
286
339
|
return;
|
|
287
340
|
}
|
|
@@ -314,17 +367,17 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
314
367
|
}),
|
|
315
368
|
controller.onError((error) => {
|
|
316
369
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
317
|
-
|
|
370
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.READY);
|
|
318
371
|
}),
|
|
319
372
|
controller.onAbort(() => {
|
|
320
373
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
321
374
|
model.pushStackElement();
|
|
322
|
-
|
|
375
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
323
376
|
}),
|
|
324
377
|
controller.onEnd(() => {
|
|
325
378
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
326
379
|
model.pushStackElement();
|
|
327
|
-
|
|
380
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
328
381
|
}),
|
|
329
382
|
]);
|
|
330
383
|
|
|
@@ -334,7 +387,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
334
387
|
}),
|
|
335
388
|
);
|
|
336
389
|
|
|
337
|
-
this.inputDisposable.addDispose(
|
|
390
|
+
this.inputDisposable.addDispose(inlineInputWidget);
|
|
338
391
|
}
|
|
339
392
|
|
|
340
393
|
private async showInputInSelection(selection: monaco.Selection, monacoEditor: ICodeEditor, defaultValue?: string) {
|
|
@@ -343,6 +396,11 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
343
396
|
this.inputDisposable = new Disposable();
|
|
344
397
|
}
|
|
345
398
|
|
|
399
|
+
const model = monacoEditor.getModel();
|
|
400
|
+
if (!model) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
|
|
346
404
|
const decorationsCollection = monacoEditor.createDecorationsCollection();
|
|
347
405
|
decorationsCollection.set([
|
|
348
406
|
{
|
|
@@ -360,16 +418,22 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
360
418
|
}),
|
|
361
419
|
},
|
|
362
420
|
]);
|
|
421
|
+
const decorationSelection = monaco.Selection.fromRange(
|
|
422
|
+
decorationsCollection.getRange(0)!,
|
|
423
|
+
selection.getDirection(),
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
this.inputValue.set(defaultValue || '', undefined);
|
|
427
|
+
this.inlineInputWidgetStore.set(model.id, new InlineInputWidgetStoreInSelection(decorationSelection, defaultValue));
|
|
363
428
|
|
|
364
|
-
const
|
|
365
|
-
|
|
429
|
+
const inlineInputWidget = this.injector.get(InlineInputWidget, [monacoEditor, this.inputValue.get()]);
|
|
430
|
+
inlineInputWidget.show({ selection: decorationSelection });
|
|
366
431
|
|
|
367
432
|
this.aiNativeContextKey.inlineInputWidgetIsVisible.set(true);
|
|
368
433
|
this.inlineDiffController.destroyPreviewer(monacoEditor.getModel()?.uri.toString());
|
|
369
|
-
let inputValue = defaultValue;
|
|
370
434
|
|
|
371
435
|
this.inputDisposable.addDispose(
|
|
372
|
-
|
|
436
|
+
inlineInputWidget.onDispose(() => {
|
|
373
437
|
this.cancelToken();
|
|
374
438
|
decorationsCollection.clear();
|
|
375
439
|
this.aiNativeContextKey.inlineInputWidgetIsVisible.set(false);
|
|
@@ -377,7 +441,18 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
377
441
|
);
|
|
378
442
|
|
|
379
443
|
this.inputDisposable.addDispose(
|
|
380
|
-
|
|
444
|
+
inlineInputWidget.onValueChange((value) => {
|
|
445
|
+
this.inputValue.set(value, undefined);
|
|
446
|
+
|
|
447
|
+
const storeData = this.inlineInputWidgetStore.get(model.id);
|
|
448
|
+
if (storeData instanceof InlineInputWidgetStoreInSelection) {
|
|
449
|
+
storeData.setValue(value);
|
|
450
|
+
}
|
|
451
|
+
}),
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
this.inputDisposable.addDispose(
|
|
455
|
+
inlineInputWidget.onClose(() => {
|
|
381
456
|
const isStreaming = this.aiNativeContextKey.inlineInputWidgetIsStreaming.get();
|
|
382
457
|
if (isStreaming) {
|
|
383
458
|
this.cancelToken();
|
|
@@ -388,10 +463,8 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
388
463
|
);
|
|
389
464
|
|
|
390
465
|
this.inputDisposable.addDispose(
|
|
391
|
-
|
|
392
|
-
inputValue = value;
|
|
466
|
+
inlineInputWidget.onSend(async (value) => {
|
|
393
467
|
monacoEditor.focus();
|
|
394
|
-
decorationsCollection.clear();
|
|
395
468
|
|
|
396
469
|
const handler = this.inlineInputService.getInteractiveInputHandler();
|
|
397
470
|
|
|
@@ -399,20 +472,22 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
399
472
|
return;
|
|
400
473
|
}
|
|
401
474
|
|
|
402
|
-
|
|
475
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.THINKING);
|
|
403
476
|
|
|
404
477
|
const strategy = await this.inlineInputService.getInteractiveInputStrategyHandler()(monacoEditor, value);
|
|
405
478
|
|
|
406
|
-
const crossSelection = selection
|
|
407
|
-
.setStartPosition(selection.startLineNumber, 1)
|
|
408
|
-
.setEndPosition(selection.endLineNumber, monacoEditor.getModel()!.getLineMaxColumn(selection.endLineNumber));
|
|
409
|
-
|
|
410
479
|
if (strategy === ERunStrategy.PREVIEW && handler.providePreviewStrategy) {
|
|
411
|
-
const previewResponse = await handler.providePreviewStrategy(
|
|
480
|
+
const previewResponse = await handler.providePreviewStrategy(
|
|
481
|
+
monacoEditor,
|
|
482
|
+
decorationSelection,
|
|
483
|
+
value,
|
|
484
|
+
this.token,
|
|
485
|
+
);
|
|
412
486
|
|
|
413
487
|
if (CancelResponse.is(previewResponse)) {
|
|
414
|
-
|
|
415
|
-
this.
|
|
488
|
+
decorationsCollection.clear();
|
|
489
|
+
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
490
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
416
491
|
return;
|
|
417
492
|
}
|
|
418
493
|
|
|
@@ -421,52 +496,57 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
421
496
|
|
|
422
497
|
this.inputDisposable.addDispose([
|
|
423
498
|
chatResponse.onData((data) => {
|
|
499
|
+
decorationsCollection.clear();
|
|
424
500
|
if (ReplyResponse.is(data)) {
|
|
425
501
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(true);
|
|
426
502
|
}
|
|
427
503
|
}),
|
|
428
504
|
chatResponse.onError((error) => {
|
|
429
505
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
430
|
-
|
|
506
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.READY);
|
|
431
507
|
}),
|
|
432
508
|
chatResponse.onAbort(() => {
|
|
509
|
+
decorationsCollection.clear();
|
|
433
510
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
434
|
-
|
|
511
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
435
512
|
}),
|
|
436
513
|
chatResponse.onEnd(() => {
|
|
514
|
+
decorationsCollection.clear();
|
|
437
515
|
this.aiNativeContextKey.inlineInputWidgetIsStreaming.set(false);
|
|
438
|
-
|
|
516
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.DONE);
|
|
439
517
|
}),
|
|
440
518
|
]);
|
|
441
519
|
|
|
442
520
|
chatResponse.listen();
|
|
443
521
|
|
|
444
522
|
const diffPreviewer = this.inlineDiffController.showPreviewerByStream(monacoEditor, {
|
|
445
|
-
crossSelection,
|
|
523
|
+
crossSelection: decorationSelection,
|
|
446
524
|
chatResponse,
|
|
447
525
|
});
|
|
448
|
-
|
|
526
|
+
|
|
527
|
+
diffPreviewer.mount(inlineInputWidget);
|
|
449
528
|
}
|
|
450
529
|
} else {
|
|
451
|
-
|
|
530
|
+
decorationsCollection.clear();
|
|
531
|
+
inlineInputWidget.launchChatStatus(EInlineChatStatus.READY);
|
|
452
532
|
this.hideInput();
|
|
453
533
|
}
|
|
454
534
|
}),
|
|
455
535
|
);
|
|
456
536
|
|
|
457
537
|
this.inputDisposable.addDispose(
|
|
458
|
-
|
|
538
|
+
inlineInputWidget.onResultClick((kind: EResultKind) => {
|
|
459
539
|
this.inlineDiffController.handleAction(kind);
|
|
460
540
|
this.hideInput();
|
|
461
541
|
|
|
462
542
|
if (kind === EResultKind.REGENERATE) {
|
|
463
543
|
requestAnimationFrame(() => {
|
|
464
|
-
this.showInputInSelection(
|
|
544
|
+
this.showInputInSelection(decorationSelection, monacoEditor, this.inputValue.get());
|
|
465
545
|
});
|
|
466
546
|
}
|
|
467
547
|
}),
|
|
468
548
|
);
|
|
469
549
|
|
|
470
|
-
this.inputDisposable.addDispose(
|
|
550
|
+
this.inputDisposable.addDispose(inlineInputWidget);
|
|
471
551
|
}
|
|
472
552
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
2
2
|
import { MaybePromise, uuid } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
3
|
+
import { ICodeEditor, IPosition, Selection } from '@opensumi/ide-monaco';
|
|
4
4
|
|
|
5
5
|
import { ERunStrategy, IInteractiveInputHandler } from '../../types';
|
|
6
6
|
|
|
@@ -32,3 +32,43 @@ export class InteractiveInputModel {
|
|
|
32
32
|
this._handler = undefined;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export class InlineInputWidgetStoreInEmptyLine {
|
|
37
|
+
constructor(private position: IPosition, private value?: string) {}
|
|
38
|
+
|
|
39
|
+
public getPosition(): IPosition {
|
|
40
|
+
return this.position;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public setPosition(position: IPosition): void {
|
|
44
|
+
this.position = position;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public getValue(): string | undefined {
|
|
48
|
+
return this.value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public setValue(value: string): void {
|
|
52
|
+
this.value = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class InlineInputWidgetStoreInSelection {
|
|
57
|
+
constructor(private selection: Selection, private value?: string) {}
|
|
58
|
+
|
|
59
|
+
public getSelection(): Selection {
|
|
60
|
+
return this.selection;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public setSelection(selection: Selection): void {
|
|
64
|
+
this.selection = selection;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public getValue(): string | undefined {
|
|
68
|
+
return this.value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public setValue(value: string): void {
|
|
72
|
+
this.value = value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -328,7 +328,9 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
328
328
|
preRemovedLen += removedLinesOriginalRange.length - addedRange.length;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
this.livePreviewDiffDecorationModel.touchRemovedWidget(states)
|
|
331
|
+
this.livePreviewDiffDecorationModel.touchRemovedWidget(states, () => {
|
|
332
|
+
this._onDidEditChange.fire();
|
|
333
|
+
});
|
|
332
334
|
}
|
|
333
335
|
|
|
334
336
|
/**
|
|
@@ -676,12 +676,13 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
676
676
|
this.recordPartialEditWidgetWithAddedDec();
|
|
677
677
|
}
|
|
678
678
|
|
|
679
|
-
public touchRemovedWidget(states: IRemovedWidgetState[]) {
|
|
679
|
+
public touchRemovedWidget(states: IRemovedWidgetState[], cb?: () => void) {
|
|
680
680
|
const run = () => {
|
|
681
681
|
this.clearRemovedWidgets();
|
|
682
682
|
states.forEach(({ textLines, position }) => {
|
|
683
683
|
this.showRemovedWidgetByLineNumber(position.lineNumber, textLines, {});
|
|
684
684
|
});
|
|
685
|
+
cb?.();
|
|
685
686
|
};
|
|
686
687
|
|
|
687
688
|
if (this.options.renderRemovedWidgetImmediately) {
|