@opensumi/ide-ai-native 3.7.1 → 3.7.2-next-1739859371.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 +5 -4
- 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/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 +7 -2
- 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 +20 -48
- 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 +86 -55
- 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 +5 -3
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +29 -64
- 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,6 +1,15 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICursorPositionChangedEvent,
|
|
3
|
+
import { ICursorPositionChangedEvent, IModelContentChangedEvent } from '@opensumi/ide-monaco';
|
|
4
|
+
import {
|
|
5
|
+
autorunDelta,
|
|
6
|
+
derived,
|
|
7
|
+
derivedHandleChanges,
|
|
8
|
+
observableFromEvent,
|
|
9
|
+
onObservableChange,
|
|
10
|
+
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
11
|
+
|
|
12
|
+
import { IntelligentCompletionsController } from '../intelligent-completions.controller';
|
|
4
13
|
|
|
5
14
|
import { BaseCodeEditsSource } from './base';
|
|
6
15
|
|
|
@@ -9,39 +18,137 @@ export interface ILineChangeData {
|
|
|
9
18
|
preLineNumber?: number;
|
|
10
19
|
}
|
|
11
20
|
|
|
21
|
+
const DEPRECATED_LIMIT = 5;
|
|
22
|
+
const CONTENT_CHANGE_VALID_TIME = 60 * 1000;
|
|
23
|
+
|
|
12
24
|
@Injectable({ multiple: true })
|
|
13
25
|
export class LineChangeCodeEditsSource extends BaseCodeEditsSource {
|
|
14
|
-
public priority =
|
|
26
|
+
public priority = 1;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 在当前文件,计算弃用上次 edit 时的次数是否超过了阈值 {@link DEPRECATED_LIMIT} 次,超过则不会触发
|
|
30
|
+
* 1. 直接 esc 弃用
|
|
31
|
+
* 2. 用户再次移动光标位置致使补全消失也视为弃用
|
|
32
|
+
*/
|
|
33
|
+
private readonly deprecatedStore = new Map<string, number>();
|
|
34
|
+
|
|
35
|
+
private readonly positionChangeObs = observableFromEvent<ICursorPositionChangedEvent>(
|
|
36
|
+
this,
|
|
37
|
+
this.monacoEditor.onDidChangeCursorPosition,
|
|
38
|
+
(event: ICursorPositionChangedEvent) => event,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
private readonly contentChangeObs = observableFromEvent<IModelContentChangedEvent>(
|
|
42
|
+
this,
|
|
43
|
+
this.monacoEditor.onDidChangeModelContent,
|
|
44
|
+
(event: IModelContentChangedEvent) => event,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
private readonly latestContentChangeTimeObs = derivedHandleChanges(
|
|
48
|
+
{
|
|
49
|
+
owner: this,
|
|
50
|
+
createEmptyChangeSummary: () => ({ latestContentChangeTime: 0 }),
|
|
51
|
+
handleChange: (context, changeSummary) => {
|
|
52
|
+
if (context.didChange(this.contentChangeObs)) {
|
|
53
|
+
changeSummary.latestContentChangeTime = Date.now();
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
(reader, changeSummary) => {
|
|
59
|
+
this.contentChangeObs.read(reader);
|
|
60
|
+
return changeSummary.latestContentChangeTime;
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
private readonly isAllowTriggerObs = derived((reader) => {
|
|
65
|
+
this.positionChangeObs.read(reader);
|
|
66
|
+
const latestContentChangeTime = this.latestContentChangeTimeObs.read(reader);
|
|
67
|
+
|
|
68
|
+
const isLineChangeEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLineChange, false);
|
|
15
69
|
|
|
16
|
-
|
|
70
|
+
/**
|
|
71
|
+
* 配置开关
|
|
72
|
+
*/
|
|
73
|
+
if (!isLineChangeEnabled) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 弃用次数规则的限制
|
|
79
|
+
*/
|
|
80
|
+
const deprecatedCount = this.deprecatedStore.get(this.model?.id || '');
|
|
81
|
+
if (deprecatedCount && deprecatedCount >= DEPRECATED_LIMIT) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 1. 未编辑过代码不触发
|
|
87
|
+
* 2. 编辑过代码后,60 内没有再次编辑也不触发
|
|
88
|
+
*/
|
|
89
|
+
if (
|
|
90
|
+
latestContentChangeTime === 0 ||
|
|
91
|
+
(latestContentChangeTime && Date.now() - latestContentChangeTime > CONTENT_CHANGE_VALID_TIME)
|
|
92
|
+
) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
});
|
|
17
98
|
|
|
18
99
|
public mount(): IDisposable {
|
|
19
100
|
this.addDispose(
|
|
20
|
-
this.
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
101
|
+
autorunDelta(this.positionChangeObs, ({ lastValue, newValue }, reader) => {
|
|
102
|
+
const isAllowTriggerObs = this.isAllowTriggerObs.read(reader);
|
|
103
|
+
if (!isAllowTriggerObs) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const prePosition = lastValue?.position;
|
|
108
|
+
const currentPosition = newValue?.position;
|
|
109
|
+
if (prePosition && prePosition.lineNumber !== currentPosition?.lineNumber) {
|
|
110
|
+
this.setBean({
|
|
111
|
+
typing: ECodeEditsSourceTyping.LineChange,
|
|
112
|
+
data: {
|
|
113
|
+
[ECodeEditsSourceTyping.LineChange]: {
|
|
114
|
+
preLineNumber: prePosition.lineNumber,
|
|
115
|
+
currentLineNumber: currentPosition.lineNumber,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
});
|
|
25
119
|
}
|
|
26
120
|
}),
|
|
27
121
|
);
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
122
|
|
|
31
|
-
|
|
32
|
-
const
|
|
123
|
+
const discard = IntelligentCompletionsController.get(this.monacoEditor)?.discard;
|
|
124
|
+
const accept = IntelligentCompletionsController.get(this.monacoEditor)?.accept;
|
|
125
|
+
if (discard) {
|
|
126
|
+
this.addDispose(
|
|
127
|
+
onObservableChange(discard, (isValid: boolean) => {
|
|
128
|
+
const modelId = this.model?.id;
|
|
129
|
+
if (!modelId || !isValid) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
33
132
|
|
|
34
|
-
|
|
35
|
-
|
|
133
|
+
const count = this.deprecatedStore.get(modelId) || 0;
|
|
134
|
+
this.deprecatedStore.set(modelId, count + 1);
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
36
137
|
}
|
|
37
138
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
139
|
+
if (accept) {
|
|
140
|
+
this.addDispose(
|
|
141
|
+
onObservableChange(accept, () => {
|
|
142
|
+
const modelId = this.model?.id;
|
|
143
|
+
if (!modelId) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.deprecatedStore.delete(modelId);
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return this;
|
|
46
153
|
}
|
|
47
154
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
AINativeSettingSectionsId,
|
|
4
|
-
ECodeEditsSourceTyping,
|
|
5
|
-
Event,
|
|
6
|
-
FRAME_THREE,
|
|
7
|
-
IDisposable,
|
|
8
|
-
} from '@opensumi/ide-core-common';
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
9
3
|
import { ICursorPositionChangedEvent, IPosition, Position } from '@opensumi/ide-monaco';
|
|
10
4
|
import { URI } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
11
|
-
import {
|
|
5
|
+
import { autorunDelta, observableFromEvent } from '@opensumi/ide-monaco/lib/common/observable';
|
|
12
6
|
import { StandaloneServices } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
13
7
|
import {
|
|
14
8
|
IMarker,
|
|
@@ -20,7 +14,6 @@ import {
|
|
|
20
14
|
import { BaseCodeEditsSource } from './base';
|
|
21
15
|
|
|
22
16
|
export interface ILinterErrorData {
|
|
23
|
-
relativeWorkspacePath: string;
|
|
24
17
|
errors: Array<IMarkerErrorData>;
|
|
25
18
|
}
|
|
26
19
|
|
|
@@ -58,22 +51,19 @@ namespace MarkerErrorData {
|
|
|
58
51
|
|
|
59
52
|
@Injectable({ multiple: true })
|
|
60
53
|
export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
61
|
-
public priority =
|
|
62
|
-
|
|
63
|
-
@Autowired(IWorkspaceService)
|
|
64
|
-
private readonly workspaceService: IWorkspaceService;
|
|
54
|
+
public priority = 0;
|
|
65
55
|
|
|
66
56
|
public mount(): IDisposable {
|
|
67
|
-
|
|
57
|
+
const positionChangeObs = observableFromEvent<ICursorPositionChangedEvent>(
|
|
58
|
+
this,
|
|
59
|
+
this.monacoEditor.onDidChangeCursorPosition,
|
|
60
|
+
(event: ICursorPositionChangedEvent) => event,
|
|
61
|
+
);
|
|
68
62
|
|
|
69
63
|
this.addDispose(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(_, e) => e,
|
|
74
|
-
FRAME_THREE,
|
|
75
|
-
)(async (event: ICursorPositionChangedEvent) => {
|
|
76
|
-
const currentPosition = event.position;
|
|
64
|
+
autorunDelta(positionChangeObs, ({ lastValue, newValue }) => {
|
|
65
|
+
const prePosition = lastValue?.position;
|
|
66
|
+
const currentPosition = newValue?.position;
|
|
77
67
|
|
|
78
68
|
// 如果是 selection 则不触发
|
|
79
69
|
const selection = this.monacoEditor.getSelection();
|
|
@@ -81,16 +71,16 @@ export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
|
81
71
|
return;
|
|
82
72
|
}
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
// 仅在光标的行号发生变化时,才触发
|
|
75
|
+
if (prePosition && prePosition.lineNumber !== currentPosition?.lineNumber) {
|
|
76
|
+
this.doTrigger(currentPosition);
|
|
86
77
|
}
|
|
87
|
-
prePosition = currentPosition;
|
|
88
78
|
}),
|
|
89
79
|
);
|
|
90
80
|
return this;
|
|
91
81
|
}
|
|
92
82
|
|
|
93
|
-
protected
|
|
83
|
+
protected doTrigger(position: Position) {
|
|
94
84
|
const isLintErrorsEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLintErrors, false);
|
|
95
85
|
|
|
96
86
|
if (!isLintErrorsEnabled || !this.model) {
|
|
@@ -104,14 +94,12 @@ export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
|
104
94
|
markers = markers.filter((marker) => Math.abs(marker.startLineNumber - position.lineNumber) <= 1);
|
|
105
95
|
|
|
106
96
|
if (markers.length) {
|
|
107
|
-
const relativeWorkspacePath = await this.workspaceService.asRelativePath(resource.path);
|
|
108
|
-
|
|
109
97
|
this.setBean({
|
|
110
98
|
typing: ECodeEditsSourceTyping.LinterErrors,
|
|
111
|
-
position,
|
|
112
99
|
data: {
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
[ECodeEditsSourceTyping.LinterErrors]: {
|
|
101
|
+
errors: markers.map((marker) => MarkerErrorData.toData(marker)),
|
|
102
|
+
},
|
|
115
103
|
},
|
|
116
104
|
});
|
|
117
105
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
+
import { IModelContentChangedEvent } from '@opensumi/ide-monaco';
|
|
4
|
+
|
|
5
|
+
import { BaseCodeEditsSource } from './base';
|
|
6
|
+
|
|
7
|
+
@Injectable({ multiple: true })
|
|
8
|
+
export class TypingCodeEditsSource extends BaseCodeEditsSource {
|
|
9
|
+
public priority = 2;
|
|
10
|
+
|
|
11
|
+
public mount(): IDisposable {
|
|
12
|
+
this.addDispose(
|
|
13
|
+
this.monacoEditor.onDidChangeModelContent((event: IModelContentChangedEvent) => {
|
|
14
|
+
this.doTrigger(event);
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected async doTrigger(data: IModelContentChangedEvent) {
|
|
21
|
+
const isTypingEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsTyping, false);
|
|
22
|
+
|
|
23
|
+
if (!isTypingEnabled || !this.model) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.setBean({
|
|
28
|
+
typing: ECodeEditsSourceTyping.Typing,
|
|
29
|
+
data: {
|
|
30
|
+
[ECodeEditsSourceTyping.Typing]: data,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/browser/index.ts
CHANGED
|
@@ -46,7 +46,7 @@ import { LanguageParserService } from './languages/service';
|
|
|
46
46
|
import { AINativePreferencesContribution } from './preferences';
|
|
47
47
|
import { AINativeCoreContribution } from './types';
|
|
48
48
|
import { InlineChatFeatureRegistry } from './widget/inline-chat/inline-chat.feature.registry';
|
|
49
|
-
import {
|
|
49
|
+
import { InlineChatService } from './widget/inline-chat/inline-chat.service';
|
|
50
50
|
import { InlineDiffService } from './widget/inline-diff';
|
|
51
51
|
|
|
52
52
|
@Injectable()
|
|
@@ -90,7 +90,7 @@ export class AINativeModule extends BrowserModule {
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
token: IAIInlineChatService,
|
|
93
|
-
useClass:
|
|
93
|
+
useClass: InlineChatService,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
token: IChatManagerService,
|
|
@@ -29,7 +29,12 @@ export class WasmModuleManager {
|
|
|
29
29
|
|
|
30
30
|
async initParser() {
|
|
31
31
|
const baseUrl = await this.resolvedResourceUriDeferred.promise;
|
|
32
|
-
|
|
32
|
+
let wasmPath;
|
|
33
|
+
if (baseUrl.endsWith('/')) {
|
|
34
|
+
wasmPath = `${baseUrl}tree-sitter.wasm`;
|
|
35
|
+
} else {
|
|
36
|
+
wasmPath = `${baseUrl}/tree-sitter.wasm`;
|
|
37
|
+
}
|
|
33
38
|
if (!this.parserInitialized) {
|
|
34
39
|
await Parser.init({
|
|
35
40
|
locateFile: () => wasmPath,
|
|
@@ -45,7 +50,12 @@ export class WasmModuleManager {
|
|
|
45
50
|
const deferred = new Deferred<ArrayBuffer>();
|
|
46
51
|
this.cachedRuntime.set(language, deferred);
|
|
47
52
|
const baseUrl = await this.resolvedResourceUriDeferred.promise;
|
|
48
|
-
|
|
53
|
+
let wasmUrl;
|
|
54
|
+
if (baseUrl.endsWith('/')) {
|
|
55
|
+
wasmUrl = `${baseUrl}tree-sitter-${language}.wasm`;
|
|
56
|
+
} else {
|
|
57
|
+
wasmUrl = `${baseUrl}/tree-sitter-${language}.wasm`;
|
|
58
|
+
}
|
|
49
59
|
fetch(wasmUrl)
|
|
50
60
|
.then((res) => res.arrayBuffer())
|
|
51
61
|
.then((buffer) => {
|
|
@@ -10,11 +10,14 @@ export const AILayout = () => {
|
|
|
10
10
|
const { layout } = getStorageValue();
|
|
11
11
|
const designLayoutConfig = useInjectable(DesignLayoutConfig);
|
|
12
12
|
|
|
13
|
-
const defaultRightSize = useMemo(
|
|
13
|
+
const defaultRightSize = useMemo(
|
|
14
|
+
() => (designLayoutConfig.useMergeRightWithLeftPanel ? 0 : 49),
|
|
15
|
+
[designLayoutConfig.useMergeRightWithLeftPanel],
|
|
16
|
+
);
|
|
14
17
|
|
|
15
18
|
return (
|
|
16
19
|
<BoxPanel direction='top-to-bottom'>
|
|
17
|
-
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size ||
|
|
20
|
+
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size || 32 : 32} slot='top' />
|
|
18
21
|
<SplitPanel
|
|
19
22
|
id='main-horizontal-ai'
|
|
20
23
|
flex={1}
|
|
@@ -119,20 +119,20 @@
|
|
|
119
119
|
border: none;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
.header {
|
|
123
|
+
height: 36px;
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
justify-content: space-between;
|
|
127
|
+
padding: 0 10px;
|
|
128
|
+
background-color: var(--editorGroupHeader-tabsBackground);
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
.right_slot_container_wrap {
|
|
123
132
|
height: 100%;
|
|
124
133
|
display: flex;
|
|
125
134
|
flex-direction: column;
|
|
126
135
|
|
|
127
|
-
.header {
|
|
128
|
-
height: 36px;
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
justify-content: space-between;
|
|
132
|
-
padding: 0 10px;
|
|
133
|
-
background-color: var(--editorGroupHeader-tabsBackground);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
136
|
.container {
|
|
137
137
|
flex: 1;
|
|
138
138
|
}
|
|
@@ -174,16 +174,18 @@ export const AIRightTabRenderer = ({
|
|
|
174
174
|
return (
|
|
175
175
|
<ContainerView
|
|
176
176
|
{...props}
|
|
177
|
+
customTitleBar={
|
|
178
|
+
<div className={styles.header}>
|
|
179
|
+
<span className={styles.title}>{options && options.title}</span>
|
|
180
|
+
<div className={styles.side}>
|
|
181
|
+
<EnhancePopover id={'ai_right_panel_header_close'} title={localize('editor.title.context.close')}>
|
|
182
|
+
<EnhanceIcon icon='close' onClick={handleClose} />
|
|
183
|
+
</EnhancePopover>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
}
|
|
177
187
|
renderContainerWrap={({ children }) => (
|
|
178
188
|
<div className={styles.right_slot_container_wrap}>
|
|
179
|
-
<div className={styles.header}>
|
|
180
|
-
<span className={styles.title}>{options && options.title}</span>
|
|
181
|
-
<div className={styles.side}>
|
|
182
|
-
<EnhancePopover id={'ai_right_panel_header_close'} title={localize('editor.title.context.close')}>
|
|
183
|
-
<EnhanceIcon icon='close' onClick={handleClose} />
|
|
184
|
-
</EnhancePopover>
|
|
185
|
-
</div>
|
|
186
|
-
</div>
|
|
187
189
|
<div className={styles.container}>{children}</div>
|
|
188
190
|
</div>
|
|
189
191
|
)}
|
|
@@ -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
|
}
|