@opensumi/ide-ai-native 3.7.1 → 3.7.2-next-1739848467.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 +60 -15
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/WelcomeMsg.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts +14 -9
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +6 -1
- package/lib/browser/contrib/intelligent-completions/index.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 +6 -5
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +50 -42
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +4 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +7 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +9 -3
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.js +21 -3
- package/lib/browser/contrib/intelligent-completions/source/base.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts +10 -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 +95 -22
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts +1 -3
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js +13 -20
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts +9 -0
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js +36 -0
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js.map +1 -0
- 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/languages/tree-sitter/wasm-manager.d.ts.map +1 -1
- package/lib/browser/languages/tree-sitter/wasm-manager.js +14 -2
- package/lib/browser/languages/tree-sitter/wasm-manager.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/layout/layout.module.less +9 -9
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +5 -6
- package/lib/browser/layout/tabbar.view.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/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +4 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +25 -4
- 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 +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 +21 -49
- 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 -17
- 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 -5
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +321 -165
- 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 +44 -39
- 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/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 +3 -0
- package/src/browser/ai-core.contribution.ts +68 -17
- package/src/browser/components/ChatMarkdown.tsx +1 -1
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/contrib/intelligent-completions/index.ts +16 -4
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +29 -8
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +88 -58
- package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +11 -0
- package/src/browser/contrib/intelligent-completions/source/base.ts +28 -7
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +129 -22
- package/src/browser/contrib/intelligent-completions/source/lint-error.source.ts +19 -31
- package/src/browser/contrib/intelligent-completions/source/typing.source.ts +34 -0
- package/src/browser/contrib/terminal/component/terminal-command-suggest-controller.tsx +1 -1
- package/src/browser/index.ts +2 -2
- package/src/browser/languages/tree-sitter/wasm-manager.ts +12 -2
- package/src/browser/layout/ai-layout.tsx +5 -2
- package/src/browser/layout/layout.module.less +9 -9
- package/src/browser/layout/tabbar.view.tsx +10 -8
- package/src/browser/model/enhanceDecorationsCollection.ts +62 -77
- package/src/browser/preferences/schema.ts +4 -0
- package/src/browser/types.ts +40 -5
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +30 -65
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +23 -90
- package/src/browser/widget/inline-chat/inline-chat.service.ts +2 -17
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +14 -69
- 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 +454 -242
- 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 +54 -67
- 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/src/common/utils.ts +2 -2
- 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,15 @@ import {
|
|
|
13
13
|
MaybePromise,
|
|
14
14
|
MergeConflictEditorMode,
|
|
15
15
|
} from '@opensumi/ide-core-common';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ICodeEditor,
|
|
18
|
+
IRange,
|
|
19
|
+
ISelection,
|
|
20
|
+
ITextModel,
|
|
21
|
+
InlineEditProvider,
|
|
22
|
+
NewSymbolNamesProvider,
|
|
23
|
+
Position,
|
|
24
|
+
} from '@opensumi/ide-monaco';
|
|
17
25
|
import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
|
|
18
26
|
import { IMarker } from '@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers';
|
|
19
27
|
|
|
@@ -42,9 +50,11 @@ interface IBaseInlineChatHandler<T extends any[]> {
|
|
|
42
50
|
providerDiffPreviewStrategy?: (...args: T) => MaybePromise<ChatResponse | InlineChatController>;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
export type IEditorInlineChatHandler = IBaseInlineChatHandler<
|
|
53
|
+
export type IEditorInlineChatHandler = IBaseInlineChatHandler<
|
|
54
|
+
[editor: ICodeEditor, selection: ISelection, token: CancellationToken]
|
|
55
|
+
>;
|
|
46
56
|
export type IInteractiveInputHandler = IBaseInlineChatHandler<
|
|
47
|
-
[editor: ICodeEditor, value: string, token: CancellationToken]
|
|
57
|
+
[editor: ICodeEditor, selection: ISelection, value: string, token: CancellationToken]
|
|
48
58
|
>;
|
|
49
59
|
|
|
50
60
|
export enum ERunStrategy {
|
|
@@ -224,14 +234,39 @@ export type ICodeEditsProvider = (
|
|
|
224
234
|
token: CancellationToken,
|
|
225
235
|
) => MaybePromise<ICodeEditsResult | undefined>;
|
|
226
236
|
|
|
237
|
+
export type IIntelligentInlineEditProvider = (
|
|
238
|
+
editor: ICodeEditor,
|
|
239
|
+
position: IPosition,
|
|
240
|
+
contextBean: IAICompletionOption,
|
|
241
|
+
token: CancellationToken,
|
|
242
|
+
) => MaybePromise<IIntelligentCompletionsResult>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Interface for registering intelligent completion providers and code edits providers.
|
|
246
|
+
*/
|
|
227
247
|
export interface IIntelligentCompletionsRegistry {
|
|
228
248
|
/**
|
|
229
|
-
*
|
|
249
|
+
* Registers an intelligent completion provider.
|
|
250
|
+
* @deprecated Use the `registerInlineCompletionsProvider` method instead.
|
|
251
|
+
* @param provider - The intelligent completion provider to register.
|
|
230
252
|
*/
|
|
231
253
|
registerIntelligentCompletionProvider(provider: IIntelligentCompletionProvider): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Registers an inline completions provider.
|
|
257
|
+
* @param provider - The intelligent completion provider to register.
|
|
258
|
+
*/
|
|
232
259
|
registerInlineCompletionsProvider(provider: IIntelligentCompletionProvider): void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Registers an inline edit provider.
|
|
263
|
+
* @param provider The inline edit provider to register.
|
|
264
|
+
*/
|
|
265
|
+
registerInlineEditProvider(provider: InlineEditProvider): void;
|
|
266
|
+
|
|
233
267
|
/**
|
|
234
|
-
*
|
|
268
|
+
* Registers a code edits provider.
|
|
269
|
+
* @param provider - The code edits provider to register.
|
|
235
270
|
*/
|
|
236
271
|
registerCodeEditsProvider(provider: ICodeEditsProvider): void;
|
|
237
272
|
}
|
|
@@ -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();
|
|
@@ -219,14 +222,26 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
219
222
|
|
|
220
223
|
protected async showInlineChat(monacoEditor: monaco.ICodeEditor): Promise<void> {
|
|
221
224
|
// 调试状态下禁用 inline chat。影响调试体验
|
|
222
|
-
const inDebugMode = this.contextKeyService.
|
|
225
|
+
const inDebugMode = this.contextKeyService.getContextKeyValue(CONTEXT_IN_DEBUG_MODE_KEY);
|
|
223
226
|
if (inDebugMode) {
|
|
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);
|
|
@@ -271,7 +280,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
271
280
|
return undefined;
|
|
272
281
|
}
|
|
273
282
|
|
|
274
|
-
return strategy.bind(this, monacoEditor, this.token);
|
|
283
|
+
return strategy.bind(this, monacoEditor, crossSelection, this.token);
|
|
275
284
|
};
|
|
276
285
|
|
|
277
286
|
this.runAction({
|
|
@@ -288,7 +297,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
288
297
|
});
|
|
289
298
|
return relationId;
|
|
290
299
|
},
|
|
291
|
-
execute: handler.execute ? handler.execute!.bind(this, monacoEditor, this.token) : undefined,
|
|
300
|
+
execute: handler.execute ? handler.execute!.bind(this, monacoEditor, crossSelection, this.token) : undefined,
|
|
292
301
|
providerPreview: previewer(),
|
|
293
302
|
extraData: {
|
|
294
303
|
actionSource: source === 'codeAction' ? ActionSourceEnum.CodeAction : ActionSourceEnum.InlineChat,
|
|
@@ -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);
|
|
@@ -543,12 +508,6 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
543
508
|
return;
|
|
544
509
|
}
|
|
545
510
|
|
|
546
|
-
this.visibleDiffWidget({
|
|
547
|
-
monacoEditor,
|
|
548
|
-
options: { crossSelection, chatResponse: response },
|
|
549
|
-
reportInfo: { relationId, startTime, isRetry, actionType, actionSource },
|
|
550
|
-
});
|
|
551
|
-
|
|
552
511
|
this.aiInlineChatOperationDisposable.addDispose([
|
|
553
512
|
this.aiInlineContentWidget.onResultClick((kind: EResultKind) => {
|
|
554
513
|
const modifyContent = this.inlineDiffController.getModifyContent();
|
|
@@ -614,6 +573,12 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
614
573
|
});
|
|
615
574
|
}),
|
|
616
575
|
]);
|
|
576
|
+
|
|
577
|
+
this.visibleDiffWidget({
|
|
578
|
+
monacoEditor,
|
|
579
|
+
options: { crossSelection, chatResponse: response },
|
|
580
|
+
reportInfo: { relationId, startTime, isRetry, actionType, actionSource },
|
|
581
|
+
});
|
|
617
582
|
}
|
|
618
583
|
|
|
619
584
|
public async runAction(params: {
|