@opensumi/ide-ai-native 3.7.1-next-1739439717.0 → 3.7.1-next-1739448958.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/ai-core.contextkeys.d.ts +1 -0
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +1 -0
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +2 -1
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +55 -14
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +26 -4
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +3 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +9 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +1 -2
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts +2 -3
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js +51 -21
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +2 -2
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.d.ts +14 -10
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +42 -53
- package/lib/browser/model/enhanceDecorationsCollection.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-chat-editor.controller.d.ts +2 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +13 -41
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts +3 -13
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js +24 -72
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts +1 -6
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.js +5 -19
- package/lib/browser/widget/inline-chat/inline-chat.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts +2 -5
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +17 -42
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +22 -5
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +61 -30
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +8 -12
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +68 -96
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts +0 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +0 -5
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +12 -2
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +26 -18
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +14 -6
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +320 -169
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.module.less +4 -0
- package/lib/browser/widget/inline-input/inline-input.service.d.ts +19 -7
- package/lib/browser/widget/inline-input/inline-input.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.service.js +72 -12
- package/lib/browser/widget/inline-input/inline-input.service.js.map +1 -1
- package/lib/browser/widget/inline-input/model.d.ts +34 -0
- package/lib/browser/widget/inline-input/model.d.ts.map +1 -0
- package/lib/browser/widget/inline-input/model.js +63 -0
- package/lib/browser/widget/inline-input/model.js.map +1 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +8 -19
- 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 +48 -41
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +17 -4
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js +37 -5
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +7 -11
- 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 +33 -77
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/package.json +21 -21
- package/src/browser/ai-core.contextkeys.ts +3 -0
- package/src/browser/ai-core.contribution.ts +63 -16
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +29 -8
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +13 -1
- package/src/browser/contrib/intelligent-completions/source/base.ts +0 -2
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +79 -24
- package/src/browser/index.ts +2 -2
- package/src/browser/layout/ai-layout.tsx +5 -2
- package/src/browser/model/enhanceDecorationsCollection.ts +62 -77
- package/src/browser/types.ts +2 -2
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +21 -56
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +23 -90
- package/src/browser/widget/inline-chat/inline-chat.service.ts +2 -19
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +14 -71
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +87 -32
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +90 -114
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +1 -7
- package/src/browser/widget/inline-input/inline-input-widget.tsx +34 -12
- package/src/browser/widget/inline-input/inline-input.controller.ts +453 -247
- package/src/browser/widget/inline-input/inline-input.module.less +4 -0
- package/src/browser/widget/inline-input/inline-input.service.ts +92 -13
- package/src/browser/widget/inline-input/model.ts +74 -0
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +58 -69
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +45 -6
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +40 -112
- package/lib/browser/model/styles.module.less +0 -7
- package/src/browser/model/styles.module.less +0 -7
|
@@ -6,12 +6,18 @@ import {
|
|
|
6
6
|
Emitter,
|
|
7
7
|
Event,
|
|
8
8
|
IDisposable,
|
|
9
|
-
IEventBus,
|
|
10
9
|
ReplyResponse,
|
|
11
10
|
} from '@opensumi/ide-core-common';
|
|
12
|
-
import { EditorGroupCloseEvent } from '@opensumi/ide-editor/lib/browser';
|
|
13
11
|
import * as monaco from '@opensumi/ide-monaco';
|
|
14
12
|
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
13
|
+
import {
|
|
14
|
+
IObservable,
|
|
15
|
+
ISettableObservable,
|
|
16
|
+
autorun,
|
|
17
|
+
observableFromEvent,
|
|
18
|
+
observableValue,
|
|
19
|
+
transaction,
|
|
20
|
+
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
15
21
|
|
|
16
22
|
import { BaseAIMonacoEditorController } from '../../contrib/base';
|
|
17
23
|
import { EInlineDiffPreviewMode } from '../../preferences/schema';
|
|
@@ -27,6 +33,8 @@ import {
|
|
|
27
33
|
} from './inline-diff-previewer';
|
|
28
34
|
import { InlineDiffWidget } from './inline-diff-widget';
|
|
29
35
|
|
|
36
|
+
type IInlineDiffPreviewer = BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler>;
|
|
37
|
+
|
|
30
38
|
export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
31
39
|
public static readonly ID = 'editor.contrib.ai.inline.diff';
|
|
32
40
|
|
|
@@ -38,106 +46,68 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
38
46
|
return this.injector.get(PreferenceService);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
private get eventBus(): IEventBus {
|
|
42
|
-
return this.injector.get(IEventBus);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
49
|
private readonly _onMaxLineCount = new Emitter<number>();
|
|
46
50
|
public readonly onMaxLineCount: Event<number> = this._onMaxLineCount.event;
|
|
47
51
|
|
|
48
|
-
private
|
|
49
|
-
private
|
|
52
|
+
private previewerStore: Map<string, IInlineDiffPreviewer>;
|
|
53
|
+
private currentPreviewer: ISettableObservable<IInlineDiffPreviewer | undefined>;
|
|
54
|
+
private modelChangeObs: IObservable<monaco.editor.ITextModel, unknown>;
|
|
50
55
|
|
|
51
56
|
mount(): IDisposable {
|
|
57
|
+
this.previewerStore = new Map();
|
|
58
|
+
this.currentPreviewer = observableValue(this, undefined);
|
|
59
|
+
this.modelChangeObs = observableFromEvent<monaco.editor.ITextModel>(
|
|
60
|
+
this,
|
|
61
|
+
this.monacoEditor.onDidChangeModel,
|
|
62
|
+
() => this.monacoEditor.getModel()!,
|
|
63
|
+
);
|
|
64
|
+
|
|
52
65
|
this.featureDisposable.addDispose(
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
66
|
+
autorun((reader) => {
|
|
67
|
+
const model = this.modelChangeObs.read(reader);
|
|
68
|
+
if (!model) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
/**
|
|
73
|
+
* 切换到其他 model 且 previewer 未卸载时
|
|
74
|
+
* 保留 previewer 的实例,仅卸载 previewer 的渲染层
|
|
75
|
+
*/
|
|
76
|
+
const id = model.id;
|
|
77
|
+
const previewer = this.currentPreviewer.read(reader);
|
|
78
|
+
if (previewer && previewer.modelId !== id && !previewer.disposed) {
|
|
79
|
+
previewer.hide();
|
|
59
80
|
}
|
|
81
|
+
|
|
82
|
+
const storedPreview = this.previewerStore.get(model.id);
|
|
83
|
+
transaction((tx) => {
|
|
84
|
+
if (storedPreview && storedPreview.modelId === id) {
|
|
85
|
+
this.currentPreviewer.set(storedPreview, tx);
|
|
86
|
+
storedPreview.resume();
|
|
87
|
+
} else {
|
|
88
|
+
this.currentPreviewer.set(undefined, tx);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
60
91
|
}),
|
|
61
92
|
);
|
|
62
93
|
|
|
63
|
-
this.registerInlineDiffFeature(this.monacoEditor);
|
|
64
|
-
|
|
65
94
|
return this.featureDisposable;
|
|
66
95
|
}
|
|
67
96
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 存储的是快照
|
|
74
|
-
const node = this.previewer.createNodeSnapshot();
|
|
75
|
-
if (node) {
|
|
76
|
-
this._previewerNodeStore.set(key, node as InlineStreamDiffHandler);
|
|
77
|
-
}
|
|
97
|
+
getPreviewer(): IInlineDiffPreviewer | undefined {
|
|
98
|
+
return this.currentPreviewer.get();
|
|
78
99
|
}
|
|
79
100
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!node) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (node.disposed) {
|
|
87
|
-
this.destroyPreviewer(key);
|
|
101
|
+
private renderDiff(previewer: IInlineDiffPreviewer, data: ReplyResponse) {
|
|
102
|
+
if (!previewer) {
|
|
88
103
|
return;
|
|
89
104
|
}
|
|
90
105
|
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
restoreState(monacoEditor: monaco.ICodeEditor, node: InlineStreamDiffHandler) {
|
|
95
|
-
const uri = monacoEditor.getModel()?.uri;
|
|
96
|
-
|
|
97
|
-
if (uri) {
|
|
98
|
-
this.previewer = this.injector.get(LiveInlineDiffPreviewer, [monacoEditor]);
|
|
99
|
-
this.previewer.attachNode(node);
|
|
100
|
-
this.listenPreviewer(this.previewer);
|
|
101
|
-
|
|
102
|
-
const dispose = this.previewer.onDispose(() => {
|
|
103
|
-
this.destroyPreviewer();
|
|
104
|
-
dispose.dispose();
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
registerInlineDiffFeature(monacoEditor: monaco.ICodeEditor): void {
|
|
110
|
-
const model = monacoEditor.getModel();
|
|
111
|
-
|
|
112
|
-
this.featureDisposable.addDispose(
|
|
113
|
-
monacoEditor.onWillChangeModel((e) => {
|
|
114
|
-
if (!e.oldModelUrl) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const urlString = e.oldModelUrl.toString();
|
|
119
|
-
this.storeState(urlString);
|
|
120
|
-
|
|
121
|
-
this.destroyPreviewer();
|
|
122
|
-
}),
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
this.featureDisposable.addDispose(
|
|
126
|
-
monacoEditor.onDidChangeModel((e) => {
|
|
127
|
-
if (!e.newModelUrl) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
this.tryRestoreState(monacoEditor, e.newModelUrl.toString());
|
|
131
|
-
}),
|
|
132
|
-
);
|
|
106
|
+
previewer.onData(data);
|
|
133
107
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const uriString = model.uri.toString();
|
|
138
|
-
this.destroyPreviewer(uriString);
|
|
139
|
-
}),
|
|
140
|
-
);
|
|
108
|
+
// 仅在当前 model 中进行流式渲染
|
|
109
|
+
if (this.modelChangeObs.get()?.id === previewer.modelId) {
|
|
110
|
+
previewer.render();
|
|
141
111
|
}
|
|
142
112
|
}
|
|
143
113
|
|
|
@@ -154,6 +124,10 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
154
124
|
const disposable = new Disposable();
|
|
155
125
|
|
|
156
126
|
const previewer = this.createDiffPreviewer(monacoEditor, crossSelection, options.previewerOptions);
|
|
127
|
+
transaction((tx) => {
|
|
128
|
+
this.currentPreviewer.set(previewer, tx);
|
|
129
|
+
this.previewerStore.set(previewer.modelId, previewer);
|
|
130
|
+
});
|
|
157
131
|
|
|
158
132
|
const onFinish = () => {
|
|
159
133
|
previewer.layout();
|
|
@@ -168,7 +142,7 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
168
142
|
disposable.addDispose([
|
|
169
143
|
controller.onData((data) => {
|
|
170
144
|
if (ReplyResponse.is(data)) {
|
|
171
|
-
|
|
145
|
+
this.renderDiff(previewer, data);
|
|
172
146
|
}
|
|
173
147
|
}),
|
|
174
148
|
controller.onError((error) => {
|
|
@@ -203,59 +177,61 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
203
177
|
EInlineDiffPreviewMode.inlineLive,
|
|
204
178
|
);
|
|
205
179
|
|
|
206
|
-
|
|
180
|
+
let previewer: IInlineDiffPreviewer;
|
|
207
181
|
|
|
208
182
|
if (inlineDiffMode === EInlineDiffPreviewMode.sideBySide) {
|
|
209
|
-
|
|
183
|
+
previewer = this.injector.get(SideBySideInlineDiffWidget, [monacoEditor]);
|
|
210
184
|
} else {
|
|
211
|
-
|
|
185
|
+
previewer = this.injector.get(LiveInlineDiffPreviewer, [monacoEditor]);
|
|
212
186
|
}
|
|
213
187
|
|
|
214
|
-
|
|
215
|
-
|
|
188
|
+
previewer.create(selection, options);
|
|
189
|
+
previewer.show(selection.startLineNumber - 1, selection.endLineNumber - selection.startLineNumber + 2);
|
|
216
190
|
|
|
217
|
-
|
|
191
|
+
previewer.addDispose(previewer.onLineCount((lineCount) => this._onMaxLineCount.fire(lineCount)));
|
|
218
192
|
|
|
219
|
-
|
|
193
|
+
previewer.addDispose(
|
|
194
|
+
Disposable.create(() => {
|
|
195
|
+
this.previewerStore.delete(previewer.modelId);
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
return previewer;
|
|
220
200
|
}
|
|
221
201
|
|
|
222
|
-
|
|
202
|
+
handleAction(action: EResultKind): void {
|
|
203
|
+
const previewer = this.getPreviewer();
|
|
223
204
|
if (!previewer) {
|
|
224
205
|
return;
|
|
225
206
|
}
|
|
226
207
|
|
|
227
|
-
previewer.
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
getPreviewer(): BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined {
|
|
231
|
-
return this.previewer;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
getStoredState(uri: string) {
|
|
235
|
-
return this._previewerNodeStore.get(uri);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
handleAction(action: EResultKind): void {
|
|
239
|
-
this.previewer?.handleAction(action);
|
|
208
|
+
previewer.handleAction(action);
|
|
240
209
|
}
|
|
241
210
|
|
|
242
211
|
getModifyContent() {
|
|
243
|
-
|
|
244
|
-
|
|
212
|
+
const previewer = this.getPreviewer();
|
|
213
|
+
if (!previewer) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
245
216
|
|
|
246
|
-
|
|
247
|
-
return this.previewer?.getOriginValue();
|
|
217
|
+
return previewer.getValue();
|
|
248
218
|
}
|
|
249
219
|
|
|
250
|
-
|
|
251
|
-
this.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this._previewerNodeStore.delete(uriString);
|
|
220
|
+
getOriginContent() {
|
|
221
|
+
const previewer = this.getPreviewer();
|
|
222
|
+
if (!previewer) {
|
|
223
|
+
return;
|
|
255
224
|
}
|
|
225
|
+
|
|
226
|
+
return previewer.getOriginValue();
|
|
256
227
|
}
|
|
257
228
|
|
|
258
229
|
revealFirstDiff() {
|
|
259
|
-
this.
|
|
230
|
+
const previewer = this.getPreviewer();
|
|
231
|
+
if (!previewer) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
previewer.revealFirstDiff();
|
|
260
236
|
}
|
|
261
237
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import throttle from 'lodash/throttle';
|
|
2
2
|
|
|
3
3
|
import { Disposable, IDisposable } from '@opensumi/ide-core-common';
|
|
4
|
-
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
5
4
|
import * as monaco from '@opensumi/ide-monaco';
|
|
5
|
+
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
6
6
|
|
|
7
7
|
import { AINativeContextKey } from '../../ai-core.contextkeys';
|
|
8
8
|
import { BaseAIMonacoEditorController } from '../../contrib/base';
|
|
9
9
|
import { AICompletionsService } from '../../contrib/inline-completions/service/ai-completions.service';
|
|
10
|
-
import { InlineInputChatService } from '../inline-input/inline-input.service';
|
|
11
10
|
import { InlineInputPreviewDecorationID } from '../internal.type';
|
|
12
11
|
|
|
13
12
|
import { InlineHintLineDecoration } from './inline-hint-line-widget';
|
|
@@ -23,10 +22,6 @@ export class InlineHintController extends BaseAIMonacoEditorController {
|
|
|
23
22
|
return this.injector.get(AICompletionsService);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
private get inlineInputChatService(): InlineInputChatService {
|
|
27
|
-
return this.injector.get(InlineInputChatService);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
25
|
mount(): IDisposable {
|
|
31
26
|
return this.registerHintLineFeature(this.monacoEditor);
|
|
32
27
|
}
|
|
@@ -59,7 +54,6 @@ export class InlineHintController extends BaseAIMonacoEditorController {
|
|
|
59
54
|
if (!lineContent?.trim()) {
|
|
60
55
|
inlineHintLineDecoration.show(position);
|
|
61
56
|
}
|
|
62
|
-
this.inlineInputChatService.setCurrentVisiblePosition(position);
|
|
63
57
|
|
|
64
58
|
aiNativeContextKey.inlineHintWidgetIsVisible.set(true);
|
|
65
59
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Injectable } from '@opensumi/di';
|
|
4
|
+
import { AINativeConfigService, useInjectable } from '@opensumi/ide-core-browser';
|
|
4
5
|
import { AIAction, InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native/index';
|
|
5
|
-
import { AIInlineInputChatContentWidgetId, Disposable, Event, localize } from '@opensumi/ide-core-common';
|
|
6
|
+
import { AIInlineInputChatContentWidgetId, Disposable, Emitter, Event, localize } from '@opensumi/ide-core-common';
|
|
6
7
|
import { ContentWidgetPositionPreference } from '@opensumi/ide-monaco/lib/browser/monaco-exports/editor';
|
|
7
8
|
|
|
8
9
|
import { InlineResultAction } from '../inline-actions/result-items/index';
|
|
@@ -10,19 +11,24 @@ import { EInlineChatStatus, EResultKind } from '../inline-chat/inline-chat.servi
|
|
|
10
11
|
import { AIInlineContentWidget } from '../inline-chat/inline-content-widget';
|
|
11
12
|
|
|
12
13
|
import styles from './inline-input.module.less';
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
import type { ICodeEditor as IMonacoCodeEditor } from '@opensumi/ide-monaco';
|
|
14
16
|
|
|
15
17
|
interface IInlineInputWidgetRenderProps {
|
|
18
|
+
defaultValue?: string;
|
|
16
19
|
onLayoutChange: (height: number) => void;
|
|
17
20
|
onClose?: () => void;
|
|
18
21
|
onInteractiveInputSend?: (value: string) => void;
|
|
19
22
|
onChatStatus: Event<EInlineChatStatus>;
|
|
20
23
|
onResultClick: (k: EResultKind) => void;
|
|
24
|
+
onValueChange?: (value: string) => void;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
|
|
24
|
-
const { onClose, onInteractiveInputSend, onLayoutChange, onChatStatus, onResultClick } =
|
|
28
|
+
const { defaultValue, onClose, onInteractiveInputSend, onLayoutChange, onChatStatus, onResultClick, onValueChange } =
|
|
29
|
+
props;
|
|
25
30
|
const [status, setStatus] = useState<EInlineChatStatus>(EInlineChatStatus.READY);
|
|
31
|
+
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
26
32
|
|
|
27
33
|
useEffect(() => {
|
|
28
34
|
const dis = new Disposable();
|
|
@@ -64,10 +70,12 @@ const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
|
|
|
64
70
|
customOperationRender={
|
|
65
71
|
<InteractiveInput
|
|
66
72
|
autoFocus
|
|
73
|
+
defaultValue={defaultValue}
|
|
74
|
+
onValueChange={onValueChange}
|
|
67
75
|
onHeightChange={(height) => onLayoutChange(height)}
|
|
68
76
|
size='small'
|
|
69
77
|
placeholder={localize('aiNative.inline.chat.input.placeholder.default')}
|
|
70
|
-
width={
|
|
78
|
+
width={aiNativeConfigService.inlineChat.inputWidth}
|
|
71
79
|
disabled={isLoading}
|
|
72
80
|
onSend={handleInteractiveInputSend}
|
|
73
81
|
/>
|
|
@@ -77,16 +85,26 @@ const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
|
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
@Injectable({ multiple: true })
|
|
80
|
-
export class
|
|
81
|
-
@Autowired(InlineInputChatService)
|
|
82
|
-
private inlineInputChatService: InlineInputChatService;
|
|
83
|
-
|
|
88
|
+
export class InlineInputWidget extends AIInlineContentWidget {
|
|
84
89
|
allowEditorOverflow = true;
|
|
85
90
|
positionPreference = [ContentWidgetPositionPreference.ABOVE];
|
|
86
91
|
|
|
92
|
+
protected readonly _onSend = new Emitter<string>();
|
|
93
|
+
public readonly onSend = this._onSend.event;
|
|
94
|
+
|
|
95
|
+
protected readonly _onClose = new Emitter<void>();
|
|
96
|
+
public readonly onClose = this._onClose.event;
|
|
97
|
+
|
|
98
|
+
protected readonly _onValueChange = new Emitter<string>();
|
|
99
|
+
public readonly onValueChange = this._onValueChange.event;
|
|
100
|
+
|
|
101
|
+
constructor(protected readonly editor: IMonacoCodeEditor, protected readonly defaultValue?: string) {
|
|
102
|
+
super(editor);
|
|
103
|
+
}
|
|
104
|
+
|
|
87
105
|
override dispose(): void {
|
|
88
106
|
super.dispose();
|
|
89
|
-
this.
|
|
107
|
+
this.inlineInputService.hide();
|
|
90
108
|
}
|
|
91
109
|
|
|
92
110
|
override id(): string {
|
|
@@ -97,14 +115,18 @@ export class InlineInputChatWidget extends AIInlineContentWidget {
|
|
|
97
115
|
return (
|
|
98
116
|
<div className={styles.input_wrapper}>
|
|
99
117
|
<InlineInputWidgetRender
|
|
100
|
-
|
|
118
|
+
defaultValue={this.defaultValue}
|
|
119
|
+
onClose={() => this._onClose.fire()}
|
|
101
120
|
onChatStatus={this.onStatusChange.bind(this)}
|
|
102
121
|
onLayoutChange={() => {
|
|
103
122
|
this.editor.layoutContentWidget(this);
|
|
104
123
|
}}
|
|
124
|
+
onValueChange={(value) => {
|
|
125
|
+
this._onValueChange.fire(value);
|
|
126
|
+
}}
|
|
105
127
|
onInteractiveInputSend={(value) => {
|
|
106
128
|
this.launchChatStatus(EInlineChatStatus.THINKING);
|
|
107
|
-
this.
|
|
129
|
+
this._onSend.fire(value);
|
|
108
130
|
}}
|
|
109
131
|
onResultClick={(k: EResultKind) => {
|
|
110
132
|
this._onResultClick.fire(k);
|