@opensumi/ide-ai-native 3.7.1-next-1739430207.0 → 3.7.1-next-1739439717.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-core.contextkeys.d.ts +0 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +0 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +1 -2
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +14 -55
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +0 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +4 -26
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +1 -3
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +1 -9
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +2 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts +3 -2
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js +21 -51
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js +2 -2
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js.map +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +2 -2
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.d.ts +10 -14
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +53 -42
- package/lib/browser/model/enhanceDecorationsCollection.js.map +1 -1
- package/lib/browser/model/styles.module.less +7 -0
- package/lib/browser/types.d.ts +1 -2
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts +1 -2
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +41 -13
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts +13 -3
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js +72 -24
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts +6 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.js +19 -5
- package/lib/browser/widget/inline-chat/inline-chat.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts +5 -2
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +42 -17
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +5 -22
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +30 -61
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +12 -8
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +96 -68
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts +1 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +5 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +2 -12
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +18 -26
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +6 -14
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +169 -320
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.module.less +0 -4
- package/lib/browser/widget/inline-input/inline-input.service.d.ts +7 -19
- package/lib/browser/widget/inline-input/inline-input.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.service.js +12 -72
- package/lib/browser/widget/inline-input/inline-input.service.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +19 -8
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +41 -48
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -17
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js +5 -37
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +11 -7
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +77 -33
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/package.json +21 -21
- package/src/browser/ai-core.contextkeys.ts +0 -3
- package/src/browser/ai-core.contribution.ts +16 -63
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +8 -29
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +1 -13
- package/src/browser/contrib/intelligent-completions/source/base.ts +2 -0
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +24 -79
- package/src/browser/contrib/terminal/component/terminal-command-suggest-controller.tsx +1 -1
- package/src/browser/index.ts +2 -2
- package/src/browser/layout/ai-layout.tsx +2 -5
- package/src/browser/model/enhanceDecorationsCollection.ts +77 -62
- package/src/browser/model/styles.module.less +7 -0
- package/src/browser/types.ts +2 -2
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +56 -21
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +90 -23
- package/src/browser/widget/inline-chat/inline-chat.service.ts +19 -2
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +71 -14
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +32 -87
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +114 -90
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +7 -1
- package/src/browser/widget/inline-input/inline-input-widget.tsx +12 -34
- package/src/browser/widget/inline-input/inline-input.controller.ts +247 -453
- package/src/browser/widget/inline-input/inline-input.module.less +0 -4
- package/src/browser/widget/inline-input/inline-input.service.ts +13 -92
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +69 -58
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +6 -45
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +112 -40
- package/lib/browser/widget/inline-input/model.d.ts +0 -34
- package/lib/browser/widget/inline-input/model.d.ts.map +0 -1
- package/lib/browser/widget/inline-input/model.js +0 -63
- package/lib/browser/widget/inline-input/model.js.map +0 -1
- package/src/browser/widget/inline-input/model.ts +0 -74
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
} from '@opensumi/ide-core-browser';
|
|
28
28
|
import {
|
|
29
29
|
AI_CHAT_VISIBLE,
|
|
30
|
-
AI_INLINE_CHAT_INTERACTIVE_INPUT_CANCEL,
|
|
31
30
|
AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE,
|
|
32
31
|
AI_INLINE_CHAT_VISIBLE,
|
|
33
32
|
AI_INLINE_COMPLETION_REPORTER,
|
|
@@ -38,7 +37,6 @@ import {
|
|
|
38
37
|
InlineChatIsVisible,
|
|
39
38
|
InlineDiffPartialEditsIsVisible,
|
|
40
39
|
InlineHintWidgetIsVisible,
|
|
41
|
-
InlineInputWidgetIsStreaming,
|
|
42
40
|
InlineInputWidgetIsVisible,
|
|
43
41
|
} from '@opensumi/ide-core-browser/lib/contextkey/ai-native';
|
|
44
42
|
import { DesignLayoutConfig } from '@opensumi/ide-core-browser/lib/layout/constants';
|
|
@@ -58,9 +56,8 @@ import {
|
|
|
58
56
|
runWhenIdle,
|
|
59
57
|
} from '@opensumi/ide-core-common';
|
|
60
58
|
import { DESIGN_MENU_BAR_RIGHT } from '@opensumi/ide-design';
|
|
61
|
-
import { IEditor
|
|
59
|
+
import { IEditor } from '@opensumi/ide-editor';
|
|
62
60
|
import { BrowserEditorContribution, IEditorFeatureRegistry } from '@opensumi/ide-editor/lib/browser';
|
|
63
|
-
import { WorkbenchEditorServiceImpl } from '@opensumi/ide-editor/lib/browser/workbench-editor.service';
|
|
64
61
|
import { IMainLayoutService } from '@opensumi/ide-main-layout';
|
|
65
62
|
import { ISettingRegistry, SettingContribution } from '@opensumi/ide-preferences';
|
|
66
63
|
import { EditorContributionInstantiation } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/editorExtensions';
|
|
@@ -104,11 +101,11 @@ import {
|
|
|
104
101
|
} from './types';
|
|
105
102
|
import { InlineChatEditorController } from './widget/inline-chat/inline-chat-editor.controller';
|
|
106
103
|
import { InlineChatFeatureRegistry } from './widget/inline-chat/inline-chat.feature.registry';
|
|
107
|
-
import {
|
|
104
|
+
import { AIInlineChatService } from './widget/inline-chat/inline-chat.service';
|
|
108
105
|
import { InlineDiffController } from './widget/inline-diff/inline-diff.controller';
|
|
109
106
|
import { InlineHintController } from './widget/inline-hint/inline-hint.controller';
|
|
110
107
|
import { InlineInputController } from './widget/inline-input/inline-input.controller';
|
|
111
|
-
import {
|
|
108
|
+
import { InlineInputChatService } from './widget/inline-input/inline-input.service';
|
|
112
109
|
import { InlineStreamDiffService } from './widget/inline-stream-diff/inline-stream-diff.service';
|
|
113
110
|
import { SumiLightBulbWidget } from './widget/light-bulb';
|
|
114
111
|
|
|
@@ -194,10 +191,10 @@ export class AINativeBrowserContribution
|
|
|
194
191
|
private readonly chatProxyService: ChatProxyService;
|
|
195
192
|
|
|
196
193
|
@Autowired(IAIInlineChatService)
|
|
197
|
-
private readonly aiInlineChatService:
|
|
194
|
+
private readonly aiInlineChatService: AIInlineChatService;
|
|
198
195
|
|
|
199
|
-
@Autowired(
|
|
200
|
-
private readonly
|
|
196
|
+
@Autowired(InlineInputChatService)
|
|
197
|
+
private readonly inlineInputChatService: InlineInputChatService;
|
|
201
198
|
|
|
202
199
|
@Autowired(InlineStreamDiffService)
|
|
203
200
|
private readonly inlineStreamDiffService: InlineStreamDiffService;
|
|
@@ -208,9 +205,6 @@ export class AINativeBrowserContribution
|
|
|
208
205
|
@Autowired(CodeActionSingleHandler)
|
|
209
206
|
private readonly codeActionSingleHandler: CodeActionSingleHandler;
|
|
210
207
|
|
|
211
|
-
@Autowired(WorkbenchEditorService)
|
|
212
|
-
private readonly workbenchEditorService: WorkbenchEditorServiceImpl;
|
|
213
|
-
|
|
214
208
|
constructor() {
|
|
215
209
|
this.registerFeature();
|
|
216
210
|
}
|
|
@@ -243,7 +237,7 @@ export class AINativeBrowserContribution
|
|
|
243
237
|
EditorContributionInstantiation.BeforeFirstInteraction,
|
|
244
238
|
);
|
|
245
239
|
|
|
246
|
-
if (this.
|
|
240
|
+
if (this.inlineChatFeatureRegistry.getInteractiveInputHandler()) {
|
|
247
241
|
register(
|
|
248
242
|
InlineHintController.ID,
|
|
249
243
|
new SyncDescriptor(InlineHintController, [this.injector]),
|
|
@@ -424,48 +418,14 @@ export class AINativeBrowserContribution
|
|
|
424
418
|
});
|
|
425
419
|
|
|
426
420
|
commands.registerCommand(AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE, {
|
|
427
|
-
execute:
|
|
428
|
-
if (
|
|
429
|
-
this.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
// 每次在展示 inline input 的时候,先隐藏 inline chat
|
|
434
|
-
this.commandService.executeCommand(AI_INLINE_CHAT_VISIBLE.id, false);
|
|
435
|
-
|
|
436
|
-
const editor = this.workbenchEditorService.currentCodeEditor;
|
|
437
|
-
if (!editor) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
const position = editor.monacoEditor.getPosition();
|
|
442
|
-
if (!position) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const selection = editor.monacoEditor.getSelection();
|
|
447
|
-
const isEmptyLine = position ? editor.monacoEditor.getModel()?.getLineLength(position.lineNumber) === 0 : false;
|
|
448
|
-
|
|
449
|
-
if (isEmptyLine) {
|
|
450
|
-
this.inlineInputService.visibleByPosition(position);
|
|
451
|
-
return;
|
|
421
|
+
execute: (isVisible: boolean) => {
|
|
422
|
+
if (isVisible) {
|
|
423
|
+
this.inlineInputChatService.visible();
|
|
424
|
+
} else {
|
|
425
|
+
this.inlineInputChatService.hide();
|
|
452
426
|
}
|
|
453
427
|
|
|
454
|
-
|
|
455
|
-
this.inlineInputService.visibleBySelection(selection);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
this.inlineInputService.visibleByNearestCodeBlock(position, editor.monacoEditor);
|
|
460
|
-
},
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
commands.registerCommand(AI_INLINE_CHAT_INTERACTIVE_INPUT_CANCEL, {
|
|
464
|
-
execute: () => {
|
|
465
|
-
const editor = this.workbenchEditorService.currentCodeEditor;
|
|
466
|
-
if (editor) {
|
|
467
|
-
InlineInputController.get(editor.monacoEditor)?.cancelToken();
|
|
468
|
-
}
|
|
428
|
+
this.aiInlineChatService._onInteractiveInputVisible.fire(isVisible);
|
|
469
429
|
},
|
|
470
430
|
});
|
|
471
431
|
|
|
@@ -556,12 +516,12 @@ export class AINativeBrowserContribution
|
|
|
556
516
|
when: `editorFocus && ${InlineChatIsVisible.raw}`,
|
|
557
517
|
});
|
|
558
518
|
|
|
559
|
-
if (this.
|
|
519
|
+
if (this.inlineChatFeatureRegistry.getInteractiveInputHandler()) {
|
|
560
520
|
// 当 Inline Chat (浮动组件)展示时,通过 CMD K 唤起 Inline Input
|
|
561
521
|
keybindings.registerKeybinding(
|
|
562
522
|
{
|
|
563
523
|
command: AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,
|
|
564
|
-
keybinding:
|
|
524
|
+
keybinding: 'ctrlcmd+k',
|
|
565
525
|
args: true,
|
|
566
526
|
priority: 0,
|
|
567
527
|
when: `editorFocus && (${InlineChatIsVisible.raw} || inlineSuggestionVisible)`,
|
|
@@ -576,18 +536,11 @@ export class AINativeBrowserContribution
|
|
|
576
536
|
priority: 0,
|
|
577
537
|
when: `editorFocus && ${InlineInputWidgetIsVisible.raw}`,
|
|
578
538
|
});
|
|
579
|
-
// 当 Inline Input 流式编辑时,通过 ESC 退出
|
|
580
|
-
keybindings.registerKeybinding({
|
|
581
|
-
command: AI_INLINE_CHAT_INTERACTIVE_INPUT_CANCEL.id,
|
|
582
|
-
keybinding: 'esc',
|
|
583
|
-
priority: 1,
|
|
584
|
-
when: `editorFocus && ${InlineInputWidgetIsStreaming.raw}`,
|
|
585
|
-
});
|
|
586
539
|
// 当出现 CMD K 展示信息时,通过快捷键快速唤起 Inline Input
|
|
587
540
|
keybindings.registerKeybinding(
|
|
588
541
|
{
|
|
589
542
|
command: AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,
|
|
590
|
-
keybinding:
|
|
543
|
+
keybinding: 'ctrlcmd+k',
|
|
591
544
|
args: true,
|
|
592
545
|
priority: 0,
|
|
593
546
|
when: `editorFocus && ${InlineHintWidgetIsVisible.raw} && ${InlineChatIsVisible.not}`,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Autowired } from '@opensumi/di';
|
|
2
2
|
import {
|
|
3
|
-
AINativeConfigService,
|
|
4
3
|
ClientAppContribution,
|
|
5
4
|
Key,
|
|
6
5
|
KeybindingContribution,
|
|
7
6
|
KeybindingRegistry,
|
|
8
7
|
KeybindingScope,
|
|
9
8
|
} from '@opensumi/ide-core-browser';
|
|
10
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
AI_MULTI_LINE_COMPLETION_ACCEPT,
|
|
11
|
+
AI_MULTI_LINE_COMPLETION_DISCARD,
|
|
12
|
+
} from '@opensumi/ide-core-browser/lib/ai-native/command';
|
|
11
13
|
import { MultiLineEditsIsVisible } from '@opensumi/ide-core-browser/lib/contextkey/ai-native';
|
|
12
14
|
import { CommandContribution, CommandRegistry, Domain } from '@opensumi/ide-core-common';
|
|
13
15
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
14
16
|
import { WorkbenchEditorServiceImpl } from '@opensumi/ide-editor/lib/browser/workbench-editor.service';
|
|
15
|
-
import { transaction } from '@opensumi/ide-monaco/lib/common/observable';
|
|
16
17
|
|
|
17
18
|
import { IntelligentCompletionsController } from './intelligent-completions.controller';
|
|
18
19
|
|
|
@@ -21,11 +22,8 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
|
|
|
21
22
|
@Autowired(WorkbenchEditorService)
|
|
22
23
|
private readonly workbenchEditorService: WorkbenchEditorServiceImpl;
|
|
23
24
|
|
|
24
|
-
@Autowired(AINativeConfigService)
|
|
25
|
-
private readonly aiNativeConfigService: AINativeConfigService;
|
|
26
|
-
|
|
27
25
|
registerCommands(commands: CommandRegistry): void {
|
|
28
|
-
commands.registerCommand(
|
|
26
|
+
commands.registerCommand(AI_MULTI_LINE_COMPLETION_DISCARD, {
|
|
29
27
|
execute: () => {
|
|
30
28
|
const editor = this.workbenchEditorService.currentCodeEditor;
|
|
31
29
|
if (editor) {
|
|
@@ -34,7 +32,7 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
|
|
|
34
32
|
},
|
|
35
33
|
});
|
|
36
34
|
|
|
37
|
-
commands.registerCommand(
|
|
35
|
+
commands.registerCommand(AI_MULTI_LINE_COMPLETION_ACCEPT, {
|
|
38
36
|
execute: () => {
|
|
39
37
|
const editor = this.workbenchEditorService.currentCodeEditor;
|
|
40
38
|
if (editor) {
|
|
@@ -42,24 +40,11 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
|
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
});
|
|
45
|
-
|
|
46
|
-
commands.registerCommand(AI_CODE_EDITS_COMMANDS.TRIGGER, {
|
|
47
|
-
execute: () => {
|
|
48
|
-
const editor = this.workbenchEditorService.currentCodeEditor;
|
|
49
|
-
if (editor) {
|
|
50
|
-
transaction((tx) => {
|
|
51
|
-
IntelligentCompletionsController.get(editor.monacoEditor)?.trigger(tx);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
43
|
}
|
|
57
44
|
|
|
58
45
|
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
59
|
-
const { codeEdits } = this.aiNativeConfigService;
|
|
60
|
-
|
|
61
46
|
keybindings.registerKeybinding({
|
|
62
|
-
command:
|
|
47
|
+
command: AI_MULTI_LINE_COMPLETION_DISCARD.id,
|
|
63
48
|
keybinding: Key.ESCAPE.code,
|
|
64
49
|
when: MultiLineEditsIsVisible.raw,
|
|
65
50
|
priority: 100,
|
|
@@ -67,17 +52,11 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
|
|
|
67
52
|
|
|
68
53
|
keybindings.registerKeybinding(
|
|
69
54
|
{
|
|
70
|
-
command:
|
|
55
|
+
command: AI_MULTI_LINE_COMPLETION_ACCEPT.id,
|
|
71
56
|
keybinding: Key.TAB.code,
|
|
72
57
|
when: MultiLineEditsIsVisible.raw,
|
|
73
58
|
},
|
|
74
59
|
KeybindingScope.USER,
|
|
75
60
|
);
|
|
76
|
-
|
|
77
|
-
keybindings.registerKeybinding({
|
|
78
|
-
command: AI_CODE_EDITS_COMMANDS.TRIGGER.id,
|
|
79
|
-
keybinding: codeEdits.triggerKeybinding,
|
|
80
|
-
when: 'editorFocus',
|
|
81
|
-
});
|
|
82
61
|
}
|
|
83
62
|
}
|
|
@@ -13,13 +13,10 @@ import {
|
|
|
13
13
|
import { Emitter, ICodeEditor, ICursorPositionChangedEvent, IRange, ITextModel, Range } from '@opensumi/ide-monaco';
|
|
14
14
|
import {
|
|
15
15
|
IObservable,
|
|
16
|
-
IObservableSignal,
|
|
17
16
|
ISettableObservable,
|
|
18
|
-
ITransaction,
|
|
19
17
|
autorun,
|
|
20
18
|
autorunWithStoreHandleChanges,
|
|
21
19
|
derived,
|
|
22
|
-
observableSignal,
|
|
23
20
|
observableValue,
|
|
24
21
|
transaction,
|
|
25
22
|
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
@@ -88,13 +85,11 @@ export class IntelligentCompletionsController extends BaseAIMonacoEditorControll
|
|
|
88
85
|
private aiNativeContextKey: AINativeContextKey;
|
|
89
86
|
private rewriteWidget: RewriteWidget | null;
|
|
90
87
|
private whenMultiLineEditsVisibleDisposable: Disposable;
|
|
91
|
-
private codeEditsTriggerSignal: IObservableSignal<void>;
|
|
92
88
|
|
|
93
89
|
public mount(): IDisposable {
|
|
94
90
|
this.handlerAlwaysVisiblePreference();
|
|
95
91
|
|
|
96
92
|
this.codeEditsResult = observableValue<CodeEditsResultValue | undefined>(this, undefined);
|
|
97
|
-
this.codeEditsTriggerSignal = observableSignal(this);
|
|
98
93
|
|
|
99
94
|
this.whenMultiLineEditsVisibleDisposable = new Disposable();
|
|
100
95
|
this.multiLineDecorationModel = new MultiLineDecorationModel(this.monacoEditor);
|
|
@@ -398,10 +393,6 @@ export class IntelligentCompletionsController extends BaseAIMonacoEditorControll
|
|
|
398
393
|
this.hide();
|
|
399
394
|
});
|
|
400
395
|
|
|
401
|
-
public trigger(tx: ITransaction): void {
|
|
402
|
-
this.codeEditsTriggerSignal.trigger(tx);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
396
|
private registerFeature(monacoEditor: ICodeEditor): void {
|
|
406
397
|
this.featureDisposable.addDispose(
|
|
407
398
|
Event.any<any>(
|
|
@@ -441,19 +432,16 @@ export class IntelligentCompletionsController extends BaseAIMonacoEditorControll
|
|
|
441
432
|
autorunWithStoreHandleChanges(
|
|
442
433
|
{
|
|
443
434
|
createEmptyChangeSummary: () => ({}),
|
|
444
|
-
handleChange: (context) => {
|
|
435
|
+
handleChange: (context, changeSummary) => {
|
|
445
436
|
if (context.didChange(this.codeEditsSourceCollection.codeEditsContextBean)) {
|
|
446
437
|
// 如果上一次补全结果还在,则不重复请求
|
|
447
438
|
const isVisible = this.aiNativeContextKey.multiLineEditsIsVisible.get();
|
|
448
439
|
return !isVisible;
|
|
449
|
-
} else if (context.didChange(this.codeEditsTriggerSignal)) {
|
|
450
|
-
return true;
|
|
451
440
|
}
|
|
452
441
|
return false;
|
|
453
442
|
},
|
|
454
443
|
},
|
|
455
444
|
async (reader, _, store) => {
|
|
456
|
-
this.codeEditsTriggerSignal.read(reader);
|
|
457
445
|
const context = this.codeEditsSourceCollection.codeEditsContextBean.read(reader);
|
|
458
446
|
|
|
459
447
|
const provider = this.intelligentCompletionsRegistry.getCodeEditsProvider();
|
|
@@ -69,6 +69,8 @@ export abstract class BaseCodeEditsSource extends Disposable {
|
|
|
69
69
|
private cancellationTokenSource = new CancellationTokenSource();
|
|
70
70
|
private readonly relationID = observableValue<string | undefined>(this, undefined);
|
|
71
71
|
|
|
72
|
+
protected abstract doTrigger(...args: any[]): MaybePromise<void>;
|
|
73
|
+
|
|
72
74
|
public readonly codeEditsContextBean = disposableObservableValue<CodeEditsContextBean | undefined>(this, undefined);
|
|
73
75
|
public abstract priority: number;
|
|
74
76
|
public abstract mount(): IDisposable;
|
|
@@ -1,102 +1,47 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICursorPositionChangedEvent,
|
|
4
|
-
import {
|
|
5
|
-
autorunDelta,
|
|
6
|
-
derivedHandleChanges,
|
|
7
|
-
observableFromEvent,
|
|
8
|
-
recomputeInitiallyAndOnChange,
|
|
9
|
-
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
3
|
+
import { ICursorPositionChangedEvent, Position } from '@opensumi/ide-monaco';
|
|
10
4
|
|
|
11
5
|
import { BaseCodeEditsSource } from './base';
|
|
12
6
|
|
|
13
7
|
export interface ILineChangeData {
|
|
14
8
|
currentLineNumber: number;
|
|
15
9
|
preLineNumber?: number;
|
|
16
|
-
change?: IModelContentChangedEvent;
|
|
17
10
|
}
|
|
18
11
|
|
|
19
12
|
@Injectable({ multiple: true })
|
|
20
13
|
export class LineChangeCodeEditsSource extends BaseCodeEditsSource {
|
|
21
14
|
public priority = 2;
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
const modelContentChangeObs = observableFromEvent<IModelContentChangedEvent>(
|
|
25
|
-
this,
|
|
26
|
-
this.monacoEditor.onDidChangeModelContent,
|
|
27
|
-
(event: IModelContentChangedEvent) => event,
|
|
28
|
-
);
|
|
29
|
-
const positionChangeObs = observableFromEvent<ICursorPositionChangedEvent>(
|
|
30
|
-
this,
|
|
31
|
-
this.monacoEditor.onDidChangeCursorPosition,
|
|
32
|
-
(event: ICursorPositionChangedEvent) => event,
|
|
33
|
-
);
|
|
16
|
+
private prePosition = this.monacoEditor.getPosition();
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
owner: this,
|
|
38
|
-
createEmptyChangeSummary: () => ({ change: undefined }),
|
|
39
|
-
handleChange: (ctx, changeSummary: { change: IModelContentChangedEvent | undefined }) => {
|
|
40
|
-
// 如果只是改了光标则设置 change 为空,避免获取到缓存的 change
|
|
41
|
-
if (ctx.didChange(positionChangeObs)) {
|
|
42
|
-
changeSummary.change = undefined;
|
|
43
|
-
} else {
|
|
44
|
-
changeSummary.change = modelContentChangeObs.get();
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
(reader, changeSummary) => {
|
|
50
|
-
positionChangeObs.read(reader);
|
|
51
|
-
modelContentChangeObs.read(reader);
|
|
52
|
-
return changeSummary.change;
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
this.addDispose(recomputeInitiallyAndOnChange(latestModelContentChangeObs));
|
|
57
|
-
|
|
58
|
-
let lastModelContent: IModelContentChangedEvent | undefined;
|
|
18
|
+
public mount(): IDisposable {
|
|
59
19
|
this.addDispose(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
20
|
+
this.monacoEditor.onDidChangeCursorPosition((event: ICursorPositionChangedEvent) => {
|
|
21
|
+
const currentPosition = event.position;
|
|
22
|
+
if (this.prePosition && this.prePosition.lineNumber !== currentPosition.lineNumber) {
|
|
23
|
+
this.doTrigger(currentPosition);
|
|
24
|
+
this.prePosition = currentPosition;
|
|
25
|
+
}
|
|
66
26
|
}),
|
|
67
27
|
);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
68
30
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const contentChange = lastModelContent;
|
|
72
|
-
|
|
73
|
-
const isLineChangeEnabled = this.preferenceService.getValid(
|
|
74
|
-
AINativeSettingSectionsId.CodeEditsLineChange,
|
|
75
|
-
false,
|
|
76
|
-
);
|
|
77
|
-
if (!isLineChangeEnabled) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const prePosition = lastValue?.position;
|
|
82
|
-
const currentPosition = newValue?.position;
|
|
83
|
-
if (prePosition && prePosition.lineNumber !== currentPosition?.lineNumber) {
|
|
84
|
-
this.setBean({
|
|
85
|
-
typing: ECodeEditsSourceTyping.LineChange,
|
|
86
|
-
position: currentPosition,
|
|
87
|
-
data: {
|
|
88
|
-
preLineNumber: prePosition.lineNumber,
|
|
89
|
-
currentLineNumber: currentPosition.lineNumber,
|
|
90
|
-
change: contentChange,
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
31
|
+
protected doTrigger(position: Position) {
|
|
32
|
+
const isLineChangeEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLineChange, false);
|
|
94
33
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
34
|
+
if (!isLineChangeEnabled || !position) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
99
37
|
|
|
100
|
-
|
|
38
|
+
this.setBean({
|
|
39
|
+
typing: ECodeEditsSourceTyping.LineChange,
|
|
40
|
+
position,
|
|
41
|
+
data: {
|
|
42
|
+
preLineNumber: this.prePosition?.lineNumber,
|
|
43
|
+
currentLineNumber: position.lineNumber,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
101
46
|
}
|
|
102
47
|
}
|
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 { AIInlineChatService } 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: AIInlineChatService,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
token: IChatManagerService,
|
|
@@ -10,14 +10,11 @@ export const AILayout = () => {
|
|
|
10
10
|
const { layout } = getStorageValue();
|
|
11
11
|
const designLayoutConfig = useInjectable(DesignLayoutConfig);
|
|
12
12
|
|
|
13
|
-
const defaultRightSize = useMemo(
|
|
14
|
-
() => (designLayoutConfig.useMergeRightWithLeftPanel ? 0 : 49),
|
|
15
|
-
[designLayoutConfig.useMergeRightWithLeftPanel],
|
|
16
|
-
);
|
|
13
|
+
const defaultRightSize = useMemo(() => designLayoutConfig.useMergeRightWithLeftPanel ? 0 : 49, [designLayoutConfig.useMergeRightWithLeftPanel]);
|
|
17
14
|
|
|
18
15
|
return (
|
|
19
16
|
<BoxPanel direction='top-to-bottom'>
|
|
20
|
-
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size ||
|
|
17
|
+
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size || 35 : 0} slot='top' />
|
|
21
18
|
<SplitPanel
|
|
22
19
|
id='main-horizontal-ai'
|
|
23
20
|
flex={1}
|