@opensumi/ide-ai-native 3.7.1-next-1739428766.0 → 3.7.1-next-1739439717.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 +0 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +0 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +1 -2
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +14 -55
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +0 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +4 -26
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +1 -3
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +1 -9
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +2 -1
- 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 +3 -2
- 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 +21 -51
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js +2 -2
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.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 +10 -14
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +53 -42
- package/lib/browser/model/enhanceDecorationsCollection.js.map +1 -1
- package/lib/browser/model/styles.module.less +7 -0
- package/lib/browser/types.d.ts +2 -7
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts +1 -2
- 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 +48 -20
- 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 +13 -3
- 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 +72 -24
- 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 +6 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.js +19 -5
- package/lib/browser/widget/inline-chat/inline-chat.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts +5 -2
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +42 -17
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +5 -22
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +30 -61
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +12 -8
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +96 -68
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts +1 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +5 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +2 -12
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +18 -26
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +6 -14
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +169 -320
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.module.less +0 -4
- package/lib/browser/widget/inline-input/inline-input.service.d.ts +7 -19
- package/lib/browser/widget/inline-input/inline-input.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.service.js +12 -72
- package/lib/browser/widget/inline-input/inline-input.service.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +19 -8
- 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 +39 -44
- 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 +4 -17
- 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 +5 -37
- 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 +11 -7
- 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 +77 -33
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/utils.js +2 -2
- package/lib/common/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/browser/ai-core.contextkeys.ts +0 -3
- package/src/browser/ai-core.contribution.ts +16 -63
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +8 -29
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +1 -13
- package/src/browser/contrib/intelligent-completions/source/base.ts +2 -0
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +24 -79
- package/src/browser/contrib/terminal/component/terminal-command-suggest-controller.tsx +1 -1
- package/src/browser/index.ts +2 -2
- package/src/browser/layout/ai-layout.tsx +2 -5
- package/src/browser/model/enhanceDecorationsCollection.ts +77 -62
- package/src/browser/model/styles.module.less +7 -0
- package/src/browser/types.ts +3 -5
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +64 -29
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +90 -23
- package/src/browser/widget/inline-chat/inline-chat.service.ts +19 -2
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +71 -14
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +32 -87
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +114 -90
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +7 -1
- package/src/browser/widget/inline-input/inline-input-widget.tsx +12 -34
- package/src/browser/widget/inline-input/inline-input.controller.ts +247 -453
- package/src/browser/widget/inline-input/inline-input.module.less +0 -4
- package/src/browser/widget/inline-input/inline-input.service.ts +13 -92
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +67 -54
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +6 -45
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +112 -40
- package/src/common/utils.ts +2 -2
- package/lib/browser/widget/inline-input/model.d.ts +0 -34
- package/lib/browser/widget/inline-input/model.d.ts.map +0 -1
- package/lib/browser/widget/inline-input/model.js +0 -63
- package/lib/browser/widget/inline-input/model.js.map +0 -1
- package/src/browser/widget/inline-input/model.ts +0 -74
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { Disposable, Emitter, Event, isDefined, isUndefined
|
|
1
|
+
import { Disposable, Emitter, Event, isDefined, isUndefined } from '@opensumi/ide-core-common';
|
|
2
2
|
import {
|
|
3
3
|
ICodeEditor,
|
|
4
4
|
IContentSizeChangedEvent,
|
|
5
5
|
IModelDecorationOptions,
|
|
6
|
+
IModelDecorationsChangeAccessor,
|
|
6
7
|
IModelDeltaDecoration,
|
|
7
8
|
IPosition,
|
|
8
9
|
IRange,
|
|
9
10
|
ITextModel,
|
|
11
|
+
Range,
|
|
10
12
|
} from '@opensumi/ide-monaco';
|
|
13
|
+
import { space } from '@opensumi/ide-utils/lib/strings';
|
|
11
14
|
import { UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
12
15
|
|
|
16
|
+
import styles from './styles.module.less';
|
|
17
|
+
|
|
13
18
|
export interface IDecorationSerializableState {
|
|
14
19
|
startPosition: IPosition;
|
|
15
20
|
endPosition: IPosition;
|
|
@@ -23,10 +28,8 @@ interface IDeltaData extends IModelDeltaDecoration {
|
|
|
23
28
|
|
|
24
29
|
export interface IEnhanceModelDeltaDecoration extends IDeltaData {
|
|
25
30
|
id: string;
|
|
26
|
-
decorationId: string;
|
|
27
31
|
isHidden: boolean;
|
|
28
32
|
readonly editorDecoration: IModelDeltaDecoration;
|
|
29
|
-
show(): void;
|
|
30
33
|
hide(): void;
|
|
31
34
|
resume(): void;
|
|
32
35
|
getRange(): IRange;
|
|
@@ -44,13 +47,12 @@ export interface IDeltaDecorationsOptions {
|
|
|
44
47
|
group?: UndoRedoGroup;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
48
51
|
length: number;
|
|
49
52
|
range: IRange;
|
|
50
53
|
options: IModelDecorationOptions;
|
|
51
54
|
|
|
52
55
|
private resumeRange: IRange;
|
|
53
|
-
private _decorationId: string;
|
|
54
56
|
private _group: UndoRedoGroup;
|
|
55
57
|
|
|
56
58
|
private _hidden = false;
|
|
@@ -70,10 +72,6 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
70
72
|
return this.metadata.id;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
get decorationId(): string {
|
|
74
|
-
return this._decorationId;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
75
|
get editorDecoration(): IModelDeltaDecoration {
|
|
78
76
|
return this.metadata.editorDecoration;
|
|
79
77
|
}
|
|
@@ -110,6 +108,25 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
110
108
|
this._group = group;
|
|
111
109
|
}
|
|
112
110
|
|
|
111
|
+
private changeVisibility(newClassName: string, newRange: Range): void {
|
|
112
|
+
if (!this.options.className) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const classList = this.options.className
|
|
117
|
+
.split(space)
|
|
118
|
+
.filter((s) => s !== styles.hidden && s !== styles.visible)
|
|
119
|
+
.filter(Boolean);
|
|
120
|
+
classList.push(newClassName);
|
|
121
|
+
|
|
122
|
+
this.options.className = classList.join(space);
|
|
123
|
+
|
|
124
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
125
|
+
accessor.changeDecorationOptions(this.id, this.options);
|
|
126
|
+
accessor.changeDecoration(this.id, newRange);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
setRange(newRange: IRange): void {
|
|
114
131
|
this.range = newRange;
|
|
115
132
|
}
|
|
@@ -119,45 +136,28 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
119
136
|
}
|
|
120
137
|
|
|
121
138
|
dispose(): void {
|
|
122
|
-
this.hide();
|
|
123
139
|
this.deltaData.dispose?.();
|
|
124
140
|
}
|
|
125
141
|
|
|
126
|
-
show(): void {
|
|
127
|
-
this.codeEditor.changeDecorations((accessor) => {
|
|
128
|
-
this._decorationId = accessor.addDecoration(this.range, this.options);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
142
|
hide(): void {
|
|
133
143
|
this.resumeRange = this.range;
|
|
134
144
|
this._hidden = true;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
}
|
|
145
|
+
const startPosition = { lineNumber: this.range.startLineNumber, column: 1 };
|
|
146
|
+
const newRange = Range.fromPositions(startPosition);
|
|
147
|
+
this.changeVisibility(styles.hidden, newRange);
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
resume(): void {
|
|
143
|
-
if (!this._hidden) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
151
|
this._hidden = false;
|
|
148
|
-
this.
|
|
149
|
-
this._decorationId = accessor.addDecoration(this.resumeRange, this.options);
|
|
150
|
-
});
|
|
152
|
+
this.changeVisibility(styles.visible, Range.lift(this.resumeRange));
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
export class EnhanceDecorationsCollection
|
|
155
|
-
|
|
156
|
-
> extends Disposable {
|
|
157
|
-
private deltaDecorations: T[] = [];
|
|
156
|
+
export class EnhanceDecorationsCollection extends Disposable {
|
|
157
|
+
private deltaDecorations: IEnhanceModelDeltaDecoration[] = [];
|
|
158
158
|
|
|
159
|
-
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<
|
|
160
|
-
public readonly onDidDecorationsChange: Event<
|
|
159
|
+
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<IEnhanceModelDeltaDecoration[]>());
|
|
160
|
+
public readonly onDidDecorationsChange: Event<IEnhanceModelDeltaDecoration[]> = this._onDidDecorationsChange.event;
|
|
161
161
|
|
|
162
162
|
private get model(): ITextModel {
|
|
163
163
|
return this.codeEditor.getModel()!;
|
|
@@ -182,11 +182,11 @@ export class EnhanceDecorationsCollection<
|
|
|
182
182
|
private flush(): void {
|
|
183
183
|
this.deltaDecorations = this.deltaDecorations.map((d) => {
|
|
184
184
|
const {
|
|
185
|
-
|
|
185
|
+
id,
|
|
186
186
|
editorDecoration: { range },
|
|
187
187
|
} = d;
|
|
188
188
|
|
|
189
|
-
const newRange = this.model.getDecorationRange(
|
|
189
|
+
const newRange = this.model.getDecorationRange(id);
|
|
190
190
|
d.setRange(newRange ?? range);
|
|
191
191
|
|
|
192
192
|
return d;
|
|
@@ -196,51 +196,66 @@ export class EnhanceDecorationsCollection<
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
private delete(id: string): void {
|
|
199
|
-
this.
|
|
199
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
200
|
+
accessor.removeDecoration(id);
|
|
201
|
+
|
|
202
|
+
this.deltaDecorations = this.deltaDecorations.filter((d) => d.id !== id);
|
|
203
|
+
});
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
protected createDecorations(metaData: IDeltaDecorationsOptions) {
|
|
203
|
-
return new DeltaDecorations(metaData)
|
|
207
|
+
return new DeltaDecorations(metaData);
|
|
204
208
|
}
|
|
205
209
|
|
|
206
|
-
set(
|
|
210
|
+
set(
|
|
211
|
+
decorations: (IModelDeltaDecoration &
|
|
212
|
+
Partial<Pick<IEnhanceModelDeltaDecoration, 'length' | 'isHidden' | 'group'>>)[],
|
|
213
|
+
): void {
|
|
207
214
|
this.clear();
|
|
208
215
|
|
|
209
|
-
this.
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
id,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
216
|
+
this.codeEditor.changeDecorations((accessor: IModelDecorationsChangeAccessor) => {
|
|
217
|
+
const newDecorations: IEnhanceModelDeltaDecoration[] = [];
|
|
218
|
+
|
|
219
|
+
for (const decoration of decorations) {
|
|
220
|
+
const id = accessor.addDecoration(decoration.range, decoration.options);
|
|
221
|
+
newDecorations.push(
|
|
222
|
+
this.createDecorations({
|
|
223
|
+
id,
|
|
224
|
+
editorDecoration: decoration,
|
|
225
|
+
codeEditor: this.codeEditor,
|
|
226
|
+
isHidden: decoration.isHidden,
|
|
227
|
+
group: decoration.group,
|
|
228
|
+
deltaData: {
|
|
229
|
+
dispose: () => this.delete(id),
|
|
230
|
+
length: decoration.length,
|
|
231
|
+
},
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.deltaDecorations = newDecorations;
|
|
227
237
|
});
|
|
228
238
|
}
|
|
229
239
|
|
|
230
|
-
getDecorations():
|
|
240
|
+
getDecorations(): IEnhanceModelDeltaDecoration[] {
|
|
231
241
|
return this.deltaDecorations;
|
|
232
242
|
}
|
|
233
243
|
|
|
234
|
-
getDecorationByGroup(group: UndoRedoGroup):
|
|
244
|
+
getDecorationByGroup(group: UndoRedoGroup): IEnhanceModelDeltaDecoration | undefined {
|
|
235
245
|
return this.deltaDecorations.find((d) => d.group === group);
|
|
236
246
|
}
|
|
237
247
|
|
|
238
|
-
getDecorationByLineNumber(lineNumber: number):
|
|
248
|
+
getDecorationByLineNumber(lineNumber: number): IEnhanceModelDeltaDecoration | undefined {
|
|
239
249
|
return this.deltaDecorations.find((d) => d.getRange().startLineNumber === lineNumber);
|
|
240
250
|
}
|
|
241
251
|
|
|
242
252
|
clear(): void {
|
|
243
|
-
this.
|
|
244
|
-
|
|
253
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
254
|
+
for (const decoration of this.deltaDecorations) {
|
|
255
|
+
accessor.removeDecoration(decoration.id);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
this.deltaDecorations = [];
|
|
259
|
+
});
|
|
245
260
|
}
|
|
246
261
|
}
|
package/src/browser/types.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
MaybePromise,
|
|
14
14
|
MergeConflictEditorMode,
|
|
15
15
|
} from '@opensumi/ide-core-common';
|
|
16
|
-
import { ICodeEditor, IRange,
|
|
16
|
+
import { ICodeEditor, IRange, ITextModel, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
|
|
17
17
|
import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
|
|
18
18
|
import { IMarker } from '@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers';
|
|
19
19
|
|
|
@@ -42,11 +42,9 @@ interface IBaseInlineChatHandler<T extends any[]> {
|
|
|
42
42
|
providerDiffPreviewStrategy?: (...args: T) => MaybePromise<ChatResponse | InlineChatController>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export type IEditorInlineChatHandler = IBaseInlineChatHandler<
|
|
46
|
-
[editor: ICodeEditor, selection: ISelection, token: CancellationToken]
|
|
47
|
-
>;
|
|
45
|
+
export type IEditorInlineChatHandler = IBaseInlineChatHandler<[editor: ICodeEditor, token: CancellationToken]>;
|
|
48
46
|
export type IInteractiveInputHandler = IBaseInlineChatHandler<
|
|
49
|
-
[editor: ICodeEditor,
|
|
47
|
+
[editor: ICodeEditor, value: string, token: CancellationToken]
|
|
50
48
|
>;
|
|
51
49
|
|
|
52
50
|
export enum ERunStrategy {
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
Disposable,
|
|
16
16
|
ErrorResponse,
|
|
17
17
|
Event,
|
|
18
|
-
FRAME_THREE,
|
|
19
18
|
IAIReporter,
|
|
20
19
|
IDisposable,
|
|
21
20
|
ILogServiceClient,
|
|
@@ -31,14 +30,14 @@ import * as monaco from '@opensumi/ide-monaco';
|
|
|
31
30
|
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
32
31
|
import { monacoApi } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
33
32
|
|
|
34
|
-
import { AINativeContextKey } from '../../ai-core.contextkeys';
|
|
35
33
|
import { BaseAIMonacoEditorController } from '../../contrib/base';
|
|
36
34
|
import { CodeActionService } from '../../contrib/code-action/code-action.service';
|
|
35
|
+
import { ERunStrategy } from '../../types';
|
|
37
36
|
import { InlineDiffController } from '../inline-diff/inline-diff.controller';
|
|
38
37
|
|
|
39
38
|
import { InlineChatController } from './inline-chat-controller';
|
|
40
39
|
import { InlineChatFeatureRegistry } from './inline-chat.feature.registry';
|
|
41
|
-
import { EInlineChatStatus, EResultKind
|
|
40
|
+
import { AIInlineChatService, EInlineChatStatus, EResultKind } from './inline-chat.service';
|
|
42
41
|
import { AIInlineContentWidget } from './inline-content-widget';
|
|
43
42
|
|
|
44
43
|
export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
@@ -52,7 +51,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
52
51
|
return this.injector.get(AINativeConfigService);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
private get aiInlineChatService():
|
|
54
|
+
private get aiInlineChatService(): AIInlineChatService {
|
|
56
55
|
return this.injector.get(IAIInlineChatService);
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -87,13 +86,11 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
87
86
|
private aiInlineContentWidget: AIInlineContentWidget;
|
|
88
87
|
private aiInlineChatDisposable: Disposable = new Disposable();
|
|
89
88
|
private aiInlineChatOperationDisposable: Disposable = new Disposable();
|
|
90
|
-
private aiNativeContextKey: AINativeContextKey;
|
|
91
89
|
private inlineChatInUsing = false;
|
|
92
90
|
|
|
93
91
|
private inlineDiffController: InlineDiffController;
|
|
94
92
|
|
|
95
93
|
mount(): IDisposable {
|
|
96
|
-
this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
97
94
|
this.inlineDiffController = InlineDiffController.get(this.monacoEditor)!;
|
|
98
95
|
|
|
99
96
|
if (!this.monacoEditor) {
|
|
@@ -181,7 +178,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
181
178
|
Event.debounce(
|
|
182
179
|
Event.any<any>(this.monacoEditor.onDidChangeCursorSelection, this.monacoEditor.onMouseUp),
|
|
183
180
|
(_, e) => e,
|
|
184
|
-
|
|
181
|
+
100,
|
|
185
182
|
)(() => {
|
|
186
183
|
if (!prefInlineChatAutoVisible || !needShowInlineChat) {
|
|
187
184
|
return;
|
|
@@ -200,7 +197,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
200
197
|
return this.featureDisposable;
|
|
201
198
|
}
|
|
202
199
|
|
|
203
|
-
|
|
200
|
+
private disposeAllWidget() {
|
|
204
201
|
[this.aiInlineContentWidget, this.aiInlineChatDisposable, this.aiInlineChatOperationDisposable].forEach(
|
|
205
202
|
(widget) => {
|
|
206
203
|
widget?.dispose();
|
|
@@ -227,21 +224,9 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
227
224
|
return;
|
|
228
225
|
}
|
|
229
226
|
|
|
230
|
-
// 如果 inline input 正在展示,则不展示 inline chat
|
|
231
|
-
const isInlineInputVisible = this.aiNativeContextKey.inlineInputWidgetIsVisible.get();
|
|
232
|
-
if (isInlineInputVisible) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const isInlineStreaming = this.aiNativeContextKey.inlineInputWidgetIsStreaming.get();
|
|
237
|
-
if (isInlineStreaming) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
227
|
if (!this.aiNativeConfigService.capabilities.supportsInlineChat) {
|
|
242
228
|
return;
|
|
243
229
|
}
|
|
244
|
-
|
|
245
230
|
if (this.inlineChatInUsing) {
|
|
246
231
|
return;
|
|
247
232
|
}
|
|
@@ -258,6 +243,12 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
258
243
|
|
|
259
244
|
this.showInlineContentWidget(monacoEditor, selection);
|
|
260
245
|
|
|
246
|
+
this.aiInlineChatDisposable.addDispose(
|
|
247
|
+
this.inlineChatFeatureRegistry.onChatClick(() => {
|
|
248
|
+
this.aiInlineChatService.launchInputVisible(true);
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
|
|
261
252
|
this.aiInlineChatDisposable.addDispose(
|
|
262
253
|
this.aiInlineContentWidget.onActionClick(({ actionId, source }) => {
|
|
263
254
|
const handler = this.inlineChatFeatureRegistry.getEditorHandler(actionId);
|
|
@@ -280,7 +271,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
280
271
|
return undefined;
|
|
281
272
|
}
|
|
282
273
|
|
|
283
|
-
return strategy.bind(this, monacoEditor,
|
|
274
|
+
return strategy.bind(this, monacoEditor, this.token);
|
|
284
275
|
};
|
|
285
276
|
|
|
286
277
|
this.runAction({
|
|
@@ -297,7 +288,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
297
288
|
});
|
|
298
289
|
return relationId;
|
|
299
290
|
},
|
|
300
|
-
execute: handler.execute ? handler.execute!.bind(this, monacoEditor,
|
|
291
|
+
execute: handler.execute ? handler.execute!.bind(this, monacoEditor, this.token) : undefined,
|
|
301
292
|
providerPreview: previewer(),
|
|
302
293
|
extraData: {
|
|
303
294
|
actionSource: source === 'codeAction' ? ActionSourceEnum.CodeAction : ActionSourceEnum.InlineChat,
|
|
@@ -306,6 +297,49 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
306
297
|
});
|
|
307
298
|
}),
|
|
308
299
|
);
|
|
300
|
+
|
|
301
|
+
this.aiInlineChatDisposable.addDispose(
|
|
302
|
+
this.aiInlineContentWidget.onInteractiveInputValue(async (value) => {
|
|
303
|
+
const handler = this.inlineChatFeatureRegistry.getInteractiveInputHandler();
|
|
304
|
+
|
|
305
|
+
if (!handler) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const strategy = await this.inlineChatFeatureRegistry.getInteractiveInputStrategyHandler()(monacoEditor, value);
|
|
310
|
+
|
|
311
|
+
const crossSelection = this.getCrossSelection(monacoEditor);
|
|
312
|
+
if (!crossSelection) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
this.runAction({
|
|
317
|
+
monacoEditor,
|
|
318
|
+
crossSelection,
|
|
319
|
+
reporterFn: () => {
|
|
320
|
+
const relationId = this.aiReporter.start(AIServiceType.InlineChatInput, {
|
|
321
|
+
message: value,
|
|
322
|
+
type: AIServiceType.InlineChatInput,
|
|
323
|
+
source: 'input',
|
|
324
|
+
actionSource: ActionSourceEnum.InlineChatInput,
|
|
325
|
+
});
|
|
326
|
+
return relationId;
|
|
327
|
+
},
|
|
328
|
+
execute:
|
|
329
|
+
handler.execute && strategy === ERunStrategy.EXECUTE
|
|
330
|
+
? handler.execute!.bind(this, monacoEditor, value, this.token)
|
|
331
|
+
: undefined,
|
|
332
|
+
providerPreview:
|
|
333
|
+
handler.providePreviewStrategy && strategy === ERunStrategy.PREVIEW
|
|
334
|
+
? handler.providePreviewStrategy.bind(this, monacoEditor, value, this.token)
|
|
335
|
+
: undefined,
|
|
336
|
+
extraData: {
|
|
337
|
+
actionSource: ActionSourceEnum.InlineChatInput,
|
|
338
|
+
actionType: strategy,
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
}),
|
|
342
|
+
);
|
|
309
343
|
}
|
|
310
344
|
|
|
311
345
|
private getCrossSelection(monacoEditor: monaco.ICodeEditor) {
|
|
@@ -446,7 +480,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
446
480
|
}
|
|
447
481
|
|
|
448
482
|
const diffPreviewer = this.inlineDiffController.showPreviewerByStream(monacoEditor, options);
|
|
449
|
-
diffPreviewer.
|
|
483
|
+
diffPreviewer.mount(this.aiInlineContentWidget);
|
|
450
484
|
}
|
|
451
485
|
|
|
452
486
|
private ensureInlineChatVisible(monacoEditor: monaco.ICodeEditor, crossSelection: monaco.Selection) {
|
|
@@ -472,6 +506,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
472
506
|
const { monacoEditor, strategy, crossSelection, relationId, isRetry, actionType, actionSource } = params;
|
|
473
507
|
const model = monacoEditor.getModel();
|
|
474
508
|
|
|
509
|
+
this.inlineDiffController.destroyPreviewer(model!.uri.toString());
|
|
475
510
|
this.aiInlineChatOperationDisposable.dispose();
|
|
476
511
|
|
|
477
512
|
this.ensureInlineChatVisible(monacoEditor, crossSelection);
|
|
@@ -508,6 +543,12 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
508
543
|
return;
|
|
509
544
|
}
|
|
510
545
|
|
|
546
|
+
this.visibleDiffWidget({
|
|
547
|
+
monacoEditor,
|
|
548
|
+
options: { crossSelection, chatResponse: response },
|
|
549
|
+
reportInfo: { relationId, startTime, isRetry, actionType, actionSource },
|
|
550
|
+
});
|
|
551
|
+
|
|
511
552
|
this.aiInlineChatOperationDisposable.addDispose([
|
|
512
553
|
this.aiInlineContentWidget.onResultClick((kind: EResultKind) => {
|
|
513
554
|
const modifyContent = this.inlineDiffController.getModifyContent();
|
|
@@ -573,12 +614,6 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
573
614
|
});
|
|
574
615
|
}),
|
|
575
616
|
]);
|
|
576
|
-
|
|
577
|
-
this.visibleDiffWidget({
|
|
578
|
-
monacoEditor,
|
|
579
|
-
options: { crossSelection, chatResponse: response },
|
|
580
|
-
reportInfo: { relationId, startTime, isRetry, actionType, actionSource },
|
|
581
|
-
});
|
|
582
617
|
}
|
|
583
618
|
|
|
584
619
|
public async runAction(params: {
|
|
@@ -2,18 +2,48 @@ import { Autowired, Injectable } from '@opensumi/di';
|
|
|
2
2
|
import { KeybindingRegistry, Logger } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE } from '@opensumi/ide-core-browser/lib/ai-native/command';
|
|
4
4
|
import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
5
|
-
import {
|
|
5
|
+
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native/interactive-input/index';
|
|
6
|
+
import { Disposable, Emitter, Event, IDisposable, MaybePromise, isUndefined, uuid } from '@opensumi/ide-core-common';
|
|
7
|
+
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
6
8
|
|
|
7
9
|
import { CodeActionService } from '../../contrib/code-action/code-action.service';
|
|
8
10
|
import {
|
|
11
|
+
ERunStrategy,
|
|
9
12
|
IEditorInlineChatHandler,
|
|
10
13
|
IInlineChatFeatureRegistry,
|
|
11
14
|
IInteractiveInputHandler,
|
|
12
15
|
IInteractiveInputRunStrategy,
|
|
13
16
|
ITerminalInlineChatHandler,
|
|
14
17
|
} from '../../types';
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
type TRunStrategyFn = (editor: ICodeEditor, value: string) => MaybePromise<ERunStrategy>;
|
|
20
|
+
|
|
21
|
+
class InteractiveInputModel {
|
|
22
|
+
static ID: string = `${InteractiveInput.displayName}:${uuid(4)}`;
|
|
23
|
+
|
|
24
|
+
private _handler: IInteractiveInputHandler | undefined;
|
|
25
|
+
private _strategyHandler: TRunStrategyFn;
|
|
26
|
+
|
|
27
|
+
public setHandler(h: IInteractiveInputHandler): void {
|
|
28
|
+
this._handler = h;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public handler(): IInteractiveInputHandler | undefined {
|
|
32
|
+
return this._handler;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setStrategyHandler(fn: TRunStrategyFn): void {
|
|
36
|
+
this._strategyHandler = fn;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public strategyHandler(): TRunStrategyFn {
|
|
40
|
+
return this._strategyHandler;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public dispose(): void {
|
|
44
|
+
this._handler = undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
17
47
|
|
|
18
48
|
@Injectable()
|
|
19
49
|
export class InlineChatFeatureRegistry extends Disposable implements IInlineChatFeatureRegistry {
|
|
@@ -23,9 +53,6 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
23
53
|
@Autowired(CodeActionService)
|
|
24
54
|
private readonly codeActionService: CodeActionService;
|
|
25
55
|
|
|
26
|
-
@Autowired(InlineInputService)
|
|
27
|
-
private readonly inlineInputService: InlineInputService;
|
|
28
|
-
|
|
29
56
|
@Autowired(KeybindingRegistry)
|
|
30
57
|
private readonly keybindingRegistry: KeybindingRegistry;
|
|
31
58
|
|
|
@@ -33,6 +60,11 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
33
60
|
private editorHandlerMap: Map<string, IEditorInlineChatHandler> = new Map();
|
|
34
61
|
private terminalHandlerMap: Map<string, ITerminalInlineChatHandler> = new Map();
|
|
35
62
|
|
|
63
|
+
private interactiveInputModel: InteractiveInputModel = new InteractiveInputModel();
|
|
64
|
+
|
|
65
|
+
public readonly _onChatClick = new Emitter<void>();
|
|
66
|
+
public readonly onChatClick: Event<void> = this._onChatClick.event;
|
|
67
|
+
|
|
36
68
|
override dispose() {
|
|
37
69
|
super.dispose();
|
|
38
70
|
this.actionsMap.clear();
|
|
@@ -40,6 +72,10 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
40
72
|
this.terminalHandlerMap.clear();
|
|
41
73
|
}
|
|
42
74
|
|
|
75
|
+
private updateActions(id: string, operational: AIActionItem): void {
|
|
76
|
+
this.actionsMap.set(id, operational);
|
|
77
|
+
}
|
|
78
|
+
|
|
43
79
|
private collectActions(operational: AIActionItem): boolean {
|
|
44
80
|
const { id } = operational;
|
|
45
81
|
|
|
@@ -66,6 +102,10 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
66
102
|
this.codeActionService.deleteCodeActionById(operational.id);
|
|
67
103
|
}
|
|
68
104
|
|
|
105
|
+
public getInteractiveInputId(): string {
|
|
106
|
+
return InteractiveInputModel.ID;
|
|
107
|
+
}
|
|
108
|
+
|
|
69
109
|
public registerEditorInlineChat(operational: AIActionItem, handler: IEditorInlineChatHandler): IDisposable {
|
|
70
110
|
const isCollect = this.collectActions(operational);
|
|
71
111
|
|
|
@@ -111,23 +151,29 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
111
151
|
runStrategy: IInteractiveInputRunStrategy,
|
|
112
152
|
handler: IInteractiveInputHandler,
|
|
113
153
|
): IDisposable {
|
|
114
|
-
|
|
115
|
-
const keybindingStr = String(this.inlineInputService.getSequenceKeyString());
|
|
116
|
-
if (!keybindingStr) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
154
|
+
this.interactiveInputModel.setHandler(handler);
|
|
119
155
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
156
|
+
if (runStrategy.handleStrategy) {
|
|
157
|
+
this.interactiveInputModel.setStrategyHandler(runStrategy.handleStrategy);
|
|
158
|
+
} else {
|
|
159
|
+
this.interactiveInputModel.setStrategyHandler(() => runStrategy.strategy || ERunStrategy.EXECUTE);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const doCollect = () => {
|
|
163
|
+
const keybindingStr = String(this.getSequenceKeyString());
|
|
164
|
+
if (keybindingStr) {
|
|
165
|
+
const operational: AIActionItem = {
|
|
166
|
+
id: InteractiveInputModel.ID,
|
|
167
|
+
name: `Chat(${keybindingStr.toLocaleUpperCase()})`,
|
|
168
|
+
renderType: 'button',
|
|
169
|
+
order: Number.MAX_SAFE_INTEGER,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
if (this.actionsMap.has(operational.id)) {
|
|
173
|
+
this.updateActions(operational.id, operational);
|
|
174
|
+
} else {
|
|
175
|
+
this.collectActions(operational);
|
|
176
|
+
}
|
|
131
177
|
}
|
|
132
178
|
};
|
|
133
179
|
|
|
@@ -139,7 +185,28 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
139
185
|
|
|
140
186
|
doCollect();
|
|
141
187
|
|
|
142
|
-
return
|
|
188
|
+
return {
|
|
189
|
+
dispose: () => {
|
|
190
|
+
this.interactiveInputModel.dispose();
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private getSequenceKeyString() {
|
|
196
|
+
const keybindings = this.keybindingRegistry.getKeybindingsForCommand(AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id);
|
|
197
|
+
const resolved = keybindings[0]?.resolved;
|
|
198
|
+
if (!resolved) {
|
|
199
|
+
return '';
|
|
200
|
+
}
|
|
201
|
+
return this.keybindingRegistry.acceleratorForSequence(resolved, '+');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public getInteractiveInputHandler(): IInteractiveInputHandler | undefined {
|
|
205
|
+
return this.interactiveInputModel.handler();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public getInteractiveInputStrategyHandler(): TRunStrategyFn {
|
|
209
|
+
return this.interactiveInputModel.strategyHandler();
|
|
143
210
|
}
|
|
144
211
|
|
|
145
212
|
public getEditorActionButtons(): AIActionItem[] {
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { IAIInlineChatService } from '@opensumi/ide-core-browser';
|
|
3
|
-
import { Emitter, Event } from '@opensumi/ide-core-common';
|
|
3
|
+
import { Emitter, Event, runWhenIdle } from '@opensumi/ide-core-common';
|
|
4
4
|
|
|
5
5
|
export { EInlineChatStatus, EResultKind } from '../../../common';
|
|
6
6
|
|
|
7
7
|
@Injectable({ multiple: false })
|
|
8
|
-
export class
|
|
8
|
+
export class AIInlineChatService implements IAIInlineChatService {
|
|
9
|
+
private _interactiveInputVisible: boolean = false;
|
|
10
|
+
public get interactiveInputVisible(): boolean {
|
|
11
|
+
const visible = this._interactiveInputVisible;
|
|
12
|
+
this._interactiveInputVisible = false;
|
|
13
|
+
return visible;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public readonly _onInteractiveInputVisible = new Emitter<boolean>();
|
|
17
|
+
public readonly onInteractiveInputVisible: Event<boolean> = this._onInteractiveInputVisible.event;
|
|
18
|
+
|
|
9
19
|
public readonly _onInlineChatVisible = new Emitter<boolean>();
|
|
10
20
|
public readonly onInlineChatVisible: Event<boolean> = this._onInlineChatVisible.event;
|
|
11
21
|
|
|
@@ -15,4 +25,11 @@ export class InlineChatService implements IAIInlineChatService {
|
|
|
15
25
|
public fireThumbsEvent(isThumbsUp: boolean) {
|
|
16
26
|
this._onThumbs.fire(isThumbsUp);
|
|
17
27
|
}
|
|
28
|
+
|
|
29
|
+
public launchInputVisible(v: boolean) {
|
|
30
|
+
return runWhenIdle(() => {
|
|
31
|
+
this._interactiveInputVisible = v;
|
|
32
|
+
this._onInteractiveInputVisible.fire(v);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
18
35
|
}
|