@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
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { Disposable, Emitter, Event, isDefined, isUndefined } from '@opensumi/ide-core-common';
|
|
1
|
+
import { Disposable, Emitter, Event, isDefined, isUndefined, uuid } from '@opensumi/ide-core-common';
|
|
2
2
|
import {
|
|
3
3
|
ICodeEditor,
|
|
4
4
|
IContentSizeChangedEvent,
|
|
5
5
|
IModelDecorationOptions,
|
|
6
|
-
IModelDecorationsChangeAccessor,
|
|
7
6
|
IModelDeltaDecoration,
|
|
8
7
|
IPosition,
|
|
9
8
|
IRange,
|
|
10
9
|
ITextModel,
|
|
11
|
-
Range,
|
|
12
10
|
} from '@opensumi/ide-monaco';
|
|
13
|
-
import { space } from '@opensumi/ide-utils/lib/strings';
|
|
14
11
|
import { UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
15
12
|
|
|
16
|
-
import styles from './styles.module.less';
|
|
17
|
-
|
|
18
13
|
export interface IDecorationSerializableState {
|
|
19
14
|
startPosition: IPosition;
|
|
20
15
|
endPosition: IPosition;
|
|
@@ -28,8 +23,10 @@ interface IDeltaData extends IModelDeltaDecoration {
|
|
|
28
23
|
|
|
29
24
|
export interface IEnhanceModelDeltaDecoration extends IDeltaData {
|
|
30
25
|
id: string;
|
|
26
|
+
decorationId: string;
|
|
31
27
|
isHidden: boolean;
|
|
32
28
|
readonly editorDecoration: IModelDeltaDecoration;
|
|
29
|
+
show(): void;
|
|
33
30
|
hide(): void;
|
|
34
31
|
resume(): void;
|
|
35
32
|
getRange(): IRange;
|
|
@@ -47,12 +44,13 @@ export interface IDeltaDecorationsOptions {
|
|
|
47
44
|
group?: UndoRedoGroup;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
47
|
+
export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
51
48
|
length: number;
|
|
52
49
|
range: IRange;
|
|
53
50
|
options: IModelDecorationOptions;
|
|
54
51
|
|
|
55
52
|
private resumeRange: IRange;
|
|
53
|
+
private _decorationId: string;
|
|
56
54
|
private _group: UndoRedoGroup;
|
|
57
55
|
|
|
58
56
|
private _hidden = false;
|
|
@@ -72,6 +70,10 @@ class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
72
70
|
return this.metadata.id;
|
|
73
71
|
}
|
|
74
72
|
|
|
73
|
+
get decorationId(): string {
|
|
74
|
+
return this._decorationId;
|
|
75
|
+
}
|
|
76
|
+
|
|
75
77
|
get editorDecoration(): IModelDeltaDecoration {
|
|
76
78
|
return this.metadata.editorDecoration;
|
|
77
79
|
}
|
|
@@ -108,25 +110,6 @@ class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
108
110
|
this._group = group;
|
|
109
111
|
}
|
|
110
112
|
|
|
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
|
-
|
|
130
113
|
setRange(newRange: IRange): void {
|
|
131
114
|
this.range = newRange;
|
|
132
115
|
}
|
|
@@ -136,28 +119,45 @@ class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
136
119
|
}
|
|
137
120
|
|
|
138
121
|
dispose(): void {
|
|
122
|
+
this.hide();
|
|
139
123
|
this.deltaData.dispose?.();
|
|
140
124
|
}
|
|
141
125
|
|
|
126
|
+
show(): void {
|
|
127
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
128
|
+
this._decorationId = accessor.addDecoration(this.range, this.options);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
142
132
|
hide(): void {
|
|
143
133
|
this.resumeRange = this.range;
|
|
144
134
|
this._hidden = true;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
if (this._decorationId) {
|
|
136
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
137
|
+
accessor.removeDecoration(this._decorationId);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
148
140
|
}
|
|
149
141
|
|
|
150
142
|
resume(): void {
|
|
143
|
+
if (!this._hidden) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
151
147
|
this._hidden = false;
|
|
152
|
-
this.
|
|
148
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
149
|
+
this._decorationId = accessor.addDecoration(this.resumeRange, this.options);
|
|
150
|
+
});
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
export class EnhanceDecorationsCollection
|
|
157
|
-
|
|
154
|
+
export class EnhanceDecorationsCollection<
|
|
155
|
+
T extends IEnhanceModelDeltaDecoration = IEnhanceModelDeltaDecoration,
|
|
156
|
+
> extends Disposable {
|
|
157
|
+
private deltaDecorations: T[] = [];
|
|
158
158
|
|
|
159
|
-
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<
|
|
160
|
-
public readonly onDidDecorationsChange: Event<
|
|
159
|
+
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<T[]>());
|
|
160
|
+
public readonly onDidDecorationsChange: Event<T[]> = this._onDidDecorationsChange.event;
|
|
161
161
|
|
|
162
162
|
private get model(): ITextModel {
|
|
163
163
|
return this.codeEditor.getModel()!;
|
|
@@ -182,11 +182,11 @@ export class EnhanceDecorationsCollection extends Disposable {
|
|
|
182
182
|
private flush(): void {
|
|
183
183
|
this.deltaDecorations = this.deltaDecorations.map((d) => {
|
|
184
184
|
const {
|
|
185
|
-
|
|
185
|
+
decorationId,
|
|
186
186
|
editorDecoration: { range },
|
|
187
187
|
} = d;
|
|
188
188
|
|
|
189
|
-
const newRange = this.model.getDecorationRange(
|
|
189
|
+
const newRange = this.model.getDecorationRange(decorationId);
|
|
190
190
|
d.setRange(newRange ?? range);
|
|
191
191
|
|
|
192
192
|
return d;
|
|
@@ -196,66 +196,51 @@ export class EnhanceDecorationsCollection extends Disposable {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
private delete(id: string): void {
|
|
199
|
-
this.
|
|
200
|
-
accessor.removeDecoration(id);
|
|
201
|
-
|
|
202
|
-
this.deltaDecorations = this.deltaDecorations.filter((d) => d.id !== id);
|
|
203
|
-
});
|
|
199
|
+
this.deltaDecorations = this.deltaDecorations.filter((d) => d.id !== id);
|
|
204
200
|
}
|
|
205
201
|
|
|
206
202
|
protected createDecorations(metaData: IDeltaDecorationsOptions) {
|
|
207
|
-
return new DeltaDecorations(metaData);
|
|
203
|
+
return new DeltaDecorations(metaData) as unknown as T;
|
|
208
204
|
}
|
|
209
205
|
|
|
210
|
-
set(
|
|
211
|
-
decorations: (IModelDeltaDecoration &
|
|
212
|
-
Partial<Pick<IEnhanceModelDeltaDecoration, 'length' | 'isHidden' | 'group'>>)[],
|
|
213
|
-
): void {
|
|
206
|
+
set(decorations: (IModelDeltaDecoration & Partial<Pick<T, 'length' | 'isHidden' | 'group'>>)[]): void {
|
|
214
207
|
this.clear();
|
|
215
208
|
|
|
216
|
-
this.
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
this.deltaDecorations = newDecorations;
|
|
209
|
+
this.deltaDecorations = decorations.map((decoration) => {
|
|
210
|
+
const id = uuid(6);
|
|
211
|
+
|
|
212
|
+
const dec = this.createDecorations({
|
|
213
|
+
id,
|
|
214
|
+
editorDecoration: decoration,
|
|
215
|
+
codeEditor: this.codeEditor,
|
|
216
|
+
isHidden: decoration.isHidden,
|
|
217
|
+
group: decoration.group,
|
|
218
|
+
deltaData: {
|
|
219
|
+
dispose: () => this.delete(id),
|
|
220
|
+
length: decoration.length,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
dec.show();
|
|
225
|
+
|
|
226
|
+
return dec;
|
|
237
227
|
});
|
|
238
228
|
}
|
|
239
229
|
|
|
240
|
-
getDecorations():
|
|
230
|
+
getDecorations(): T[] {
|
|
241
231
|
return this.deltaDecorations;
|
|
242
232
|
}
|
|
243
233
|
|
|
244
|
-
getDecorationByGroup(group: UndoRedoGroup):
|
|
234
|
+
getDecorationByGroup(group: UndoRedoGroup): T | undefined {
|
|
245
235
|
return this.deltaDecorations.find((d) => d.group === group);
|
|
246
236
|
}
|
|
247
237
|
|
|
248
|
-
getDecorationByLineNumber(lineNumber: number):
|
|
238
|
+
getDecorationByLineNumber(lineNumber: number): T | undefined {
|
|
249
239
|
return this.deltaDecorations.find((d) => d.getRange().startLineNumber === lineNumber);
|
|
250
240
|
}
|
|
251
241
|
|
|
252
242
|
clear(): void {
|
|
253
|
-
this.
|
|
254
|
-
|
|
255
|
-
accessor.removeDecoration(decoration.id);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this.deltaDecorations = [];
|
|
259
|
-
});
|
|
243
|
+
this.deltaDecorations.map((d) => d.dispose());
|
|
244
|
+
this.deltaDecorations = [];
|
|
260
245
|
}
|
|
261
246
|
}
|
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, ITextModel, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
|
|
16
|
+
import { ICodeEditor, IRange, ISelection, 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
|
|
|
@@ -44,7 +44,7 @@ interface IBaseInlineChatHandler<T extends any[]> {
|
|
|
44
44
|
|
|
45
45
|
export type IEditorInlineChatHandler = IBaseInlineChatHandler<[editor: ICodeEditor, token: CancellationToken]>;
|
|
46
46
|
export type IInteractiveInputHandler = IBaseInlineChatHandler<
|
|
47
|
-
[editor: ICodeEditor, value: string, token: CancellationToken]
|
|
47
|
+
[editor: ICodeEditor, selection: ISelection, value: string, token: CancellationToken]
|
|
48
48
|
>;
|
|
49
49
|
|
|
50
50
|
export enum ERunStrategy {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Disposable,
|
|
16
16
|
ErrorResponse,
|
|
17
17
|
Event,
|
|
18
|
+
FRAME_THREE,
|
|
18
19
|
IAIReporter,
|
|
19
20
|
IDisposable,
|
|
20
21
|
ILogServiceClient,
|
|
@@ -30,14 +31,14 @@ import * as monaco from '@opensumi/ide-monaco';
|
|
|
30
31
|
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
31
32
|
import { monacoApi } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
32
33
|
|
|
34
|
+
import { AINativeContextKey } from '../../ai-core.contextkeys';
|
|
33
35
|
import { BaseAIMonacoEditorController } from '../../contrib/base';
|
|
34
36
|
import { CodeActionService } from '../../contrib/code-action/code-action.service';
|
|
35
|
-
import { ERunStrategy } from '../../types';
|
|
36
37
|
import { InlineDiffController } from '../inline-diff/inline-diff.controller';
|
|
37
38
|
|
|
38
39
|
import { InlineChatController } from './inline-chat-controller';
|
|
39
40
|
import { InlineChatFeatureRegistry } from './inline-chat.feature.registry';
|
|
40
|
-
import {
|
|
41
|
+
import { EInlineChatStatus, EResultKind, InlineChatService } from './inline-chat.service';
|
|
41
42
|
import { AIInlineContentWidget } from './inline-content-widget';
|
|
42
43
|
|
|
43
44
|
export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
@@ -51,7 +52,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
51
52
|
return this.injector.get(AINativeConfigService);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
private get aiInlineChatService():
|
|
55
|
+
private get aiInlineChatService(): InlineChatService {
|
|
55
56
|
return this.injector.get(IAIInlineChatService);
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -86,11 +87,13 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
86
87
|
private aiInlineContentWidget: AIInlineContentWidget;
|
|
87
88
|
private aiInlineChatDisposable: Disposable = new Disposable();
|
|
88
89
|
private aiInlineChatOperationDisposable: Disposable = new Disposable();
|
|
90
|
+
private aiNativeContextKey: AINativeContextKey;
|
|
89
91
|
private inlineChatInUsing = false;
|
|
90
92
|
|
|
91
93
|
private inlineDiffController: InlineDiffController;
|
|
92
94
|
|
|
93
95
|
mount(): IDisposable {
|
|
96
|
+
this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
94
97
|
this.inlineDiffController = InlineDiffController.get(this.monacoEditor)!;
|
|
95
98
|
|
|
96
99
|
if (!this.monacoEditor) {
|
|
@@ -178,7 +181,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
178
181
|
Event.debounce(
|
|
179
182
|
Event.any<any>(this.monacoEditor.onDidChangeCursorSelection, this.monacoEditor.onMouseUp),
|
|
180
183
|
(_, e) => e,
|
|
181
|
-
|
|
184
|
+
FRAME_THREE,
|
|
182
185
|
)(() => {
|
|
183
186
|
if (!prefInlineChatAutoVisible || !needShowInlineChat) {
|
|
184
187
|
return;
|
|
@@ -197,7 +200,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
197
200
|
return this.featureDisposable;
|
|
198
201
|
}
|
|
199
202
|
|
|
200
|
-
|
|
203
|
+
public disposeAllWidget() {
|
|
201
204
|
[this.aiInlineContentWidget, this.aiInlineChatDisposable, this.aiInlineChatOperationDisposable].forEach(
|
|
202
205
|
(widget) => {
|
|
203
206
|
widget?.dispose();
|
|
@@ -224,9 +227,21 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
224
227
|
return;
|
|
225
228
|
}
|
|
226
229
|
|
|
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
|
+
|
|
227
241
|
if (!this.aiNativeConfigService.capabilities.supportsInlineChat) {
|
|
228
242
|
return;
|
|
229
243
|
}
|
|
244
|
+
|
|
230
245
|
if (this.inlineChatInUsing) {
|
|
231
246
|
return;
|
|
232
247
|
}
|
|
@@ -243,12 +258,6 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
243
258
|
|
|
244
259
|
this.showInlineContentWidget(monacoEditor, selection);
|
|
245
260
|
|
|
246
|
-
this.aiInlineChatDisposable.addDispose(
|
|
247
|
-
this.inlineChatFeatureRegistry.onChatClick(() => {
|
|
248
|
-
this.aiInlineChatService.launchInputVisible(true);
|
|
249
|
-
}),
|
|
250
|
-
);
|
|
251
|
-
|
|
252
261
|
this.aiInlineChatDisposable.addDispose(
|
|
253
262
|
this.aiInlineContentWidget.onActionClick(({ actionId, source }) => {
|
|
254
263
|
const handler = this.inlineChatFeatureRegistry.getEditorHandler(actionId);
|
|
@@ -297,49 +306,6 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
297
306
|
});
|
|
298
307
|
}),
|
|
299
308
|
);
|
|
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
|
-
);
|
|
343
309
|
}
|
|
344
310
|
|
|
345
311
|
private getCrossSelection(monacoEditor: monaco.ICodeEditor) {
|
|
@@ -480,7 +446,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
480
446
|
}
|
|
481
447
|
|
|
482
448
|
const diffPreviewer = this.inlineDiffController.showPreviewerByStream(monacoEditor, options);
|
|
483
|
-
diffPreviewer.
|
|
449
|
+
diffPreviewer.mountWidget(this.aiInlineContentWidget);
|
|
484
450
|
}
|
|
485
451
|
|
|
486
452
|
private ensureInlineChatVisible(monacoEditor: monaco.ICodeEditor, crossSelection: monaco.Selection) {
|
|
@@ -506,7 +472,6 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
506
472
|
const { monacoEditor, strategy, crossSelection, relationId, isRetry, actionType, actionSource } = params;
|
|
507
473
|
const model = monacoEditor.getModel();
|
|
508
474
|
|
|
509
|
-
this.inlineDiffController.destroyPreviewer(model!.uri.toString());
|
|
510
475
|
this.aiInlineChatOperationDisposable.dispose();
|
|
511
476
|
|
|
512
477
|
this.ensureInlineChatVisible(monacoEditor, crossSelection);
|
|
@@ -2,48 +2,18 @@ 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 {
|
|
6
|
-
import { Disposable, Emitter, Event, IDisposable, MaybePromise, isUndefined, uuid } from '@opensumi/ide-core-common';
|
|
7
|
-
import { ICodeEditor } from '@opensumi/ide-monaco';
|
|
5
|
+
import { Disposable, Event, IDisposable, formatLocalize, isUndefined } from '@opensumi/ide-core-common';
|
|
8
6
|
|
|
9
7
|
import { CodeActionService } from '../../contrib/code-action/code-action.service';
|
|
10
8
|
import {
|
|
11
|
-
ERunStrategy,
|
|
12
9
|
IEditorInlineChatHandler,
|
|
13
10
|
IInlineChatFeatureRegistry,
|
|
14
11
|
IInteractiveInputHandler,
|
|
15
12
|
IInteractiveInputRunStrategy,
|
|
16
13
|
ITerminalInlineChatHandler,
|
|
17
14
|
} from '../../types';
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
15
|
+
import { InlineInputService } from '../inline-input/inline-input.service';
|
|
16
|
+
import { InteractiveInputModel } from '../inline-input/model';
|
|
47
17
|
|
|
48
18
|
@Injectable()
|
|
49
19
|
export class InlineChatFeatureRegistry extends Disposable implements IInlineChatFeatureRegistry {
|
|
@@ -53,6 +23,9 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
53
23
|
@Autowired(CodeActionService)
|
|
54
24
|
private readonly codeActionService: CodeActionService;
|
|
55
25
|
|
|
26
|
+
@Autowired(InlineInputService)
|
|
27
|
+
private readonly inlineInputService: InlineInputService;
|
|
28
|
+
|
|
56
29
|
@Autowired(KeybindingRegistry)
|
|
57
30
|
private readonly keybindingRegistry: KeybindingRegistry;
|
|
58
31
|
|
|
@@ -60,11 +33,6 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
60
33
|
private editorHandlerMap: Map<string, IEditorInlineChatHandler> = new Map();
|
|
61
34
|
private terminalHandlerMap: Map<string, ITerminalInlineChatHandler> = new Map();
|
|
62
35
|
|
|
63
|
-
private interactiveInputModel: InteractiveInputModel = new InteractiveInputModel();
|
|
64
|
-
|
|
65
|
-
public readonly _onChatClick = new Emitter<void>();
|
|
66
|
-
public readonly onChatClick: Event<void> = this._onChatClick.event;
|
|
67
|
-
|
|
68
36
|
override dispose() {
|
|
69
37
|
super.dispose();
|
|
70
38
|
this.actionsMap.clear();
|
|
@@ -72,10 +40,6 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
72
40
|
this.terminalHandlerMap.clear();
|
|
73
41
|
}
|
|
74
42
|
|
|
75
|
-
private updateActions(id: string, operational: AIActionItem): void {
|
|
76
|
-
this.actionsMap.set(id, operational);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
43
|
private collectActions(operational: AIActionItem): boolean {
|
|
80
44
|
const { id } = operational;
|
|
81
45
|
|
|
@@ -102,10 +66,6 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
102
66
|
this.codeActionService.deleteCodeActionById(operational.id);
|
|
103
67
|
}
|
|
104
68
|
|
|
105
|
-
public getInteractiveInputId(): string {
|
|
106
|
-
return InteractiveInputModel.ID;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
69
|
public registerEditorInlineChat(operational: AIActionItem, handler: IEditorInlineChatHandler): IDisposable {
|
|
110
70
|
const isCollect = this.collectActions(operational);
|
|
111
71
|
|
|
@@ -151,29 +111,23 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
151
111
|
runStrategy: IInteractiveInputRunStrategy,
|
|
152
112
|
handler: IInteractiveInputHandler,
|
|
153
113
|
): IDisposable {
|
|
154
|
-
this.interactiveInputModel.setHandler(handler);
|
|
155
|
-
|
|
156
|
-
if (runStrategy.handleStrategy) {
|
|
157
|
-
this.interactiveInputModel.setStrategyHandler(runStrategy.handleStrategy);
|
|
158
|
-
} else {
|
|
159
|
-
this.interactiveInputModel.setStrategyHandler(() => runStrategy.strategy || ERunStrategy.EXECUTE);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
114
|
const doCollect = () => {
|
|
163
|
-
const keybindingStr = String(this.getSequenceKeyString());
|
|
164
|
-
if (keybindingStr) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
115
|
+
const keybindingStr = String(this.inlineInputService.getSequenceKeyString());
|
|
116
|
+
if (!keybindingStr) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const operational: AIActionItem = {
|
|
121
|
+
id: InteractiveInputModel.ID,
|
|
122
|
+
name: formatLocalize('aiNative.inline.chat.operate.chat.title', keybindingStr.toLocaleUpperCase()),
|
|
123
|
+
renderType: 'button',
|
|
124
|
+
order: Number.MAX_SAFE_INTEGER,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if (this.actionsMap.has(operational.id)) {
|
|
128
|
+
this.actionsMap.set(operational.id, operational);
|
|
129
|
+
} else {
|
|
130
|
+
this.collectActions(operational);
|
|
177
131
|
}
|
|
178
132
|
};
|
|
179
133
|
|
|
@@ -185,28 +139,7 @@ export class InlineChatFeatureRegistry extends Disposable implements IInlineChat
|
|
|
185
139
|
|
|
186
140
|
doCollect();
|
|
187
141
|
|
|
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();
|
|
142
|
+
return this.inlineInputService.registerInlineInput(runStrategy, handler);
|
|
210
143
|
}
|
|
211
144
|
|
|
212
145
|
public getEditorActionButtons(): AIActionItem[] {
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { IAIInlineChatService } from '@opensumi/ide-core-browser';
|
|
3
|
-
import { Emitter, Event
|
|
3
|
+
import { Emitter, Event } from '@opensumi/ide-core-common';
|
|
4
4
|
|
|
5
5
|
export { EInlineChatStatus, EResultKind } from '../../../common';
|
|
6
6
|
|
|
7
7
|
@Injectable({ multiple: false })
|
|
8
|
-
export class
|
|
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
|
-
|
|
8
|
+
export class InlineChatService implements IAIInlineChatService {
|
|
19
9
|
public readonly _onInlineChatVisible = new Emitter<boolean>();
|
|
20
10
|
public readonly onInlineChatVisible: Event<boolean> = this._onInlineChatVisible.event;
|
|
21
11
|
|
|
@@ -25,11 +15,4 @@ export class AIInlineChatService implements IAIInlineChatService {
|
|
|
25
15
|
public fireThumbsEvent(isThumbsUp: boolean) {
|
|
26
16
|
this._onThumbs.fire(isThumbsUp);
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
public launchInputVisible(v: boolean) {
|
|
30
|
-
return runWhenIdle(() => {
|
|
31
|
-
this._interactiveInputVisible = v;
|
|
32
|
-
this._onInteractiveInputVisible.fire(v);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
18
|
}
|