@opensumi/ide-ai-native 3.8.1-next-1741091353.0 → 3.8.1-next-1741092802.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.contribution.d.ts +3 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +45 -1
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +0 -4
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +8 -2
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +1 -7
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/chat-history.module.less +0 -1
- package/lib/browser/mcp/base-apply.service.d.ts +7 -18
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +65 -185
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.js +9 -15
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +0 -3
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +11 -18
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +0 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +0 -3
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +6 -1
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.js +8 -68
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +4 -10
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +3 -14
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +3 -3
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +5 -10
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +17 -46
- 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 +53 -110
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +0 -4
- 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 +1 -26
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/model.d.ts +12 -0
- package/lib/common/model.d.ts.map +1 -0
- package/lib/common/model.js +83 -0
- package/lib/common/model.js.map +1 -0
- package/lib/common/types.d.ts +0 -1
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +3 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.js +6 -2
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -1
- package/lib/node/base-language-model.d.ts +4 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +6 -5
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +3 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.js +6 -2
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +5 -4
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +8 -7
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts +10 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts.map +1 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.js +32 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.js.map +1 -0
- package/package.json +24 -23
- package/src/browser/ai-core.contribution.ts +57 -1
- package/src/browser/chat/chat-manager.service.ts +0 -6
- package/src/browser/chat/chat-proxy.service.ts +7 -2
- package/src/browser/chat/chat.view.tsx +2 -7
- package/src/browser/components/chat-history.module.less +0 -1
- package/src/browser/mcp/base-apply.service.ts +67 -222
- package/src/browser/mcp/tools/components/EditFile.tsx +9 -16
- package/src/browser/mcp/tools/components/index.module.less +0 -3
- package/src/browser/mcp/tools/createNewFileWithText.ts +12 -20
- package/src/browser/mcp/tools/handlers/EditFile.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +0 -4
- package/src/browser/preferences/schema.ts +6 -1
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +21 -143
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +7 -25
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +8 -16
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +68 -139
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -30
- package/src/common/index.ts +2 -0
- package/src/common/model.ts +90 -0
- package/src/common/types.ts +0 -1
- package/src/node/anthropic/anthropic-language-model.ts +7 -2
- package/src/node/base-language-model.ts +9 -9
- package/src/node/deepseek/deepseek-language-model.ts +7 -2
- package/src/node/openai/openai-language-model.ts +10 -9
- package/src/node/openai-compatible/openai-compatible-language-model.ts +30 -0
|
@@ -128,10 +128,6 @@ export class MsgHistoryManager extends Disposable {
|
|
|
128
128
|
return this.messageAdditionalMap.get(id) || {};
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
public get sessionAdditionals() {
|
|
132
|
-
return this.messageAdditionalMap;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
131
|
toJSON() {
|
|
136
132
|
return {
|
|
137
133
|
messages: this.getMessages(),
|
|
@@ -69,9 +69,14 @@ export const aiNativePreferenceSchema: PreferenceSchema = {
|
|
|
69
69
|
[AINativeSettingSectionsId.LLMModelSelection]: {
|
|
70
70
|
type: 'string',
|
|
71
71
|
default: 'deepseek',
|
|
72
|
-
enum: ['deepseek', 'anthropic', 'openai'],
|
|
72
|
+
enum: ['deepseek', 'anthropic', 'openai', 'openai-compatible'],
|
|
73
73
|
description: localize('preference.ai.native.llm.model.selection.description'),
|
|
74
74
|
},
|
|
75
|
+
[AINativeSettingSectionsId.ModelID]: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
default: 'deepseek-chat',
|
|
78
|
+
description: localize('preference.ai.native.llm.model.id'),
|
|
79
|
+
},
|
|
75
80
|
[AINativeSettingSectionsId.DeepseekApiKey]: {
|
|
76
81
|
type: 'string',
|
|
77
82
|
default: '',
|
|
@@ -1,160 +1,38 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { IResource
|
|
6
|
-
import { Path } from '@opensumi/ide-utils/lib/path';
|
|
3
|
+
import { Button } from '@opensumi/ide-components';
|
|
4
|
+
import { localize, useInjectable } from '@opensumi/ide-core-browser';
|
|
5
|
+
import { IResource } from '@opensumi/ide-editor';
|
|
7
6
|
|
|
8
7
|
import { BaseApplyService } from '../../mcp/base-apply.service';
|
|
9
8
|
|
|
10
9
|
import styles from './inline-diff-widget.module.less';
|
|
11
10
|
|
|
12
|
-
const IconWithPopover = (props: {
|
|
13
|
-
icon: string;
|
|
14
|
-
content: string;
|
|
15
|
-
id: string;
|
|
16
|
-
onClick?: () => void;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
}) => (
|
|
19
|
-
<Popover content={props.content} id={props.id} onClick={props.onClick}>
|
|
20
|
-
<Icon iconClass={props.icon} className={props.disabled ? styles.disabled : ''} />
|
|
21
|
-
</Popover>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
11
|
export const InlineDiffManager: React.FC<{ resource: IResource }> = (props) => {
|
|
25
|
-
const { resource } = props;
|
|
26
12
|
const applyService = useInjectable<BaseApplyService>(BaseApplyService);
|
|
27
|
-
const editorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
|
|
28
|
-
const appConfig = useInjectable<AppConfig>(AppConfig);
|
|
29
13
|
const [show, setShow] = useState(true);
|
|
30
|
-
const [changesCount, setChangesCount] = useState(0);
|
|
31
|
-
const [currentChangeIndex, setCurrentChangeIndex] = useState(0);
|
|
32
|
-
const [filePaths, setFilePaths] = useState<string[]>([]);
|
|
33
|
-
|
|
34
|
-
const currentFilePath = useMemo(
|
|
35
|
-
() => path.relative(appConfig.workspaceDir, resource.uri.path.toString()),
|
|
36
|
-
[resource],
|
|
37
|
-
);
|
|
38
|
-
|
|
39
14
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
setShow(codeBlock.status === 'pending');
|
|
43
|
-
}
|
|
44
|
-
const pendingPaths = applyService.getPendingPaths();
|
|
45
|
-
setFilePaths(pendingPaths);
|
|
15
|
+
applyService.onCodeBlockUpdate((codeBlock) => {
|
|
16
|
+
setShow(codeBlock.status === 'pending');
|
|
46
17
|
});
|
|
47
|
-
return () => {
|
|
48
|
-
toDispose.dispose();
|
|
49
|
-
};
|
|
50
18
|
}, []);
|
|
51
|
-
|
|
52
|
-
// 不同编辑器是不同实例,所以不需要监听
|
|
53
|
-
const decorationModelService = applyService.currentPreviewer?.getNode()?.livePreviewDiffDecorationModel;
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
let toDispose: IDisposable | undefined;
|
|
57
|
-
if (decorationModelService) {
|
|
58
|
-
setChangesCount(decorationModelService.partialEditWidgetCount);
|
|
59
|
-
toDispose = decorationModelService.onPartialEditWidgetListChange((e) => {
|
|
60
|
-
setChangesCount(e.filter((item) => item.status === 'pending').length);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return () => {
|
|
64
|
-
toDispose?.dispose();
|
|
65
|
-
};
|
|
66
|
-
}, [decorationModelService]);
|
|
67
|
-
|
|
68
|
-
const handleSiblingChange = useCallback(
|
|
69
|
-
(direction: 'up' | 'down') => {
|
|
70
|
-
const index = decorationModelService?.revealSiblingChange(direction);
|
|
71
|
-
if (index !== undefined) {
|
|
72
|
-
setCurrentChangeIndex(index);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
[decorationModelService],
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const handleSiblingFile = useCallback(
|
|
79
|
-
(direction: 'up' | 'down') => {
|
|
80
|
-
const index = filePaths.indexOf(currentFilePath!);
|
|
81
|
-
if (index === -1) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const uri = URI.file(path.join(appConfig.workspaceDir, filePaths[index + (direction === 'up' ? -1 : 1)]));
|
|
85
|
-
editorService.open(uri);
|
|
86
|
-
},
|
|
87
|
-
[currentFilePath, filePaths],
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const changeTip = useMemo(() => {
|
|
91
|
-
if (changesCount === 0) {
|
|
92
|
-
return '';
|
|
93
|
-
}
|
|
94
|
-
return ` ${currentChangeIndex + 1} of ${changesCount}`;
|
|
95
|
-
}, [changesCount, currentChangeIndex]);
|
|
96
|
-
|
|
97
|
-
const fileTip = useMemo(() => {
|
|
98
|
-
if (!currentFilePath) {
|
|
99
|
-
return '';
|
|
100
|
-
}
|
|
101
|
-
return ` ${filePaths.indexOf(currentFilePath) + 1} of ${filePaths.length}`;
|
|
102
|
-
}, [currentFilePath, filePaths]);
|
|
103
|
-
|
|
104
19
|
return (
|
|
105
20
|
<div className={styles.inlineDiffManager} style={{ display: show ? 'flex' : 'none' }}>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<IconWithPopover
|
|
122
|
-
icon='codicon codicon-close'
|
|
123
|
-
onClick={() => applyService.processAll(props.resource.uri, 'reject')}
|
|
124
|
-
content={localize('aiNative.inlineDiff.rejectAll')}
|
|
125
|
-
id='inline-diff-manager-reject-all'
|
|
126
|
-
/>
|
|
127
|
-
<IconWithPopover
|
|
128
|
-
icon='codicon codicon-arrow-up'
|
|
129
|
-
content={localize('aiNative.inlineDiff.up') + changeTip}
|
|
130
|
-
id='inline-diff-manager-up'
|
|
131
|
-
disabled={currentChangeIndex === 0}
|
|
132
|
-
onClick={() => handleSiblingChange('up')}
|
|
133
|
-
/>
|
|
134
|
-
<IconWithPopover
|
|
135
|
-
icon='codicon codicon-arrow-down'
|
|
136
|
-
content={localize('aiNative.inlineDiff.down') + changeTip}
|
|
137
|
-
id='inline-diff-manager-down'
|
|
138
|
-
disabled={currentChangeIndex === changesCount - 1}
|
|
139
|
-
onClick={() => handleSiblingChange('down')}
|
|
140
|
-
/>
|
|
141
|
-
</div>
|
|
142
|
-
<div className={styles.right}>
|
|
143
|
-
<IconWithPopover
|
|
144
|
-
icon='codicon codicon-arrow-left'
|
|
145
|
-
onClick={() => handleSiblingFile('up')}
|
|
146
|
-
disabled={filePaths.length === 0 || filePaths[0] === currentFilePath}
|
|
147
|
-
content={localize('aiNative.inlineDiff.left') + fileTip}
|
|
148
|
-
id='inline-diff-manager-left'
|
|
149
|
-
/>
|
|
150
|
-
<IconWithPopover
|
|
151
|
-
icon='codicon codicon-arrow-right'
|
|
152
|
-
onClick={() => handleSiblingFile('down')}
|
|
153
|
-
disabled={filePaths.length === 0 || filePaths[filePaths.length - 1] === currentFilePath}
|
|
154
|
-
content={localize('aiNative.inlineDiff.right') + fileTip}
|
|
155
|
-
id='inline-diff-manager-right'
|
|
156
|
-
/>
|
|
157
|
-
</div>
|
|
21
|
+
<Button
|
|
22
|
+
onClick={() => {
|
|
23
|
+
applyService.processAll(props.resource.uri, 'accept');
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
{localize('aiNative.inlineDiff.acceptAll')}
|
|
27
|
+
</Button>
|
|
28
|
+
<Button
|
|
29
|
+
type='ghost'
|
|
30
|
+
onClick={() => {
|
|
31
|
+
applyService.processAll(props.resource.uri, 'reject');
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{localize('aiNative.inlineDiff.rejectAll')}
|
|
35
|
+
</Button>
|
|
158
36
|
</div>
|
|
159
37
|
);
|
|
160
38
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
2
|
import { Disposable, ErrorResponse, IDisposable, ReplyResponse } from '@opensumi/ide-core-common';
|
|
3
|
-
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
4
3
|
import { EOL, ICodeEditor, IPosition, ITextModel, Position, Selection } from '@opensumi/ide-monaco';
|
|
5
4
|
import { ContentWidgetPositionPreference } from '@opensumi/ide-monaco/lib/browser/monaco-exports/editor';
|
|
6
5
|
import { empty, getLeadingWhitespace } from '@opensumi/ide-utils/lib/strings';
|
|
@@ -15,12 +14,7 @@ import {
|
|
|
15
14
|
|
|
16
15
|
import { EResultKind } from '../inline-chat/inline-chat.service';
|
|
17
16
|
import { AIInlineContentWidget } from '../inline-chat/inline-content-widget';
|
|
18
|
-
import {
|
|
19
|
-
BaseInlineStreamDiffHandler,
|
|
20
|
-
EComputerMode,
|
|
21
|
-
InlineStreamDiffHandler,
|
|
22
|
-
ReverseInlineStreamDiffHandler,
|
|
23
|
-
} from '../inline-stream-diff/inline-stream-diff.handler';
|
|
17
|
+
import { EComputerMode, InlineStreamDiffHandler } from '../inline-stream-diff/inline-stream-diff.handler';
|
|
24
18
|
|
|
25
19
|
import { InlineDiffWidget } from './inline-diff-widget';
|
|
26
20
|
|
|
@@ -35,11 +29,6 @@ export interface IDiffPreviewerOptions {
|
|
|
35
29
|
* 默认情况下,removed widget 会在 `runWhenIdle` 内被添加,如果需要立即添加,可以设置为 true
|
|
36
30
|
*/
|
|
37
31
|
renderRemovedWidgetImmediately?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 是否为回退模式,即 setValue 内容作为 original,编辑器 getValue 内容作为 modified
|
|
41
|
-
*/
|
|
42
|
-
reverse?: boolean;
|
|
43
32
|
}
|
|
44
33
|
|
|
45
34
|
export interface IInlineDiffPreviewerNode extends IDisposable {
|
|
@@ -52,8 +41,6 @@ export abstract class BaseInlineDiffPreviewer<N extends IInlineDiffPreviewerNode
|
|
|
52
41
|
@Autowired(INJECTOR_TOKEN)
|
|
53
42
|
protected readonly injector: Injector;
|
|
54
43
|
|
|
55
|
-
@Autowired(WorkbenchEditorService)
|
|
56
|
-
protected readonly editorService: WorkbenchEditorService;
|
|
57
44
|
protected inlineContentWidget: AIInlineContentWidget | null = null;
|
|
58
45
|
protected selection: Selection;
|
|
59
46
|
protected model: ITextModel;
|
|
@@ -137,7 +124,7 @@ export abstract class BaseInlineDiffPreviewer<N extends IInlineDiffPreviewerNode
|
|
|
137
124
|
return Disposable.NULL;
|
|
138
125
|
}
|
|
139
126
|
|
|
140
|
-
protected abstract createNode(
|
|
127
|
+
protected abstract createNode(): N;
|
|
141
128
|
abstract onData(data: ReplyResponse): void;
|
|
142
129
|
abstract handleAction(action: EResultKind): void;
|
|
143
130
|
abstract getPosition(): IPosition;
|
|
@@ -149,7 +136,7 @@ export abstract class BaseInlineDiffPreviewer<N extends IInlineDiffPreviewerNode
|
|
|
149
136
|
},
|
|
150
137
|
): void {
|
|
151
138
|
this.selection = selection;
|
|
152
|
-
this.node = this.createNode(
|
|
139
|
+
this.node = this.createNode();
|
|
153
140
|
this.node.setPreviewerOptions(options);
|
|
154
141
|
}
|
|
155
142
|
|
|
@@ -324,8 +311,8 @@ export class SideBySideInlineDiffWidget extends BaseInlineDiffPreviewer<InlineDi
|
|
|
324
311
|
}
|
|
325
312
|
|
|
326
313
|
@Injectable({ multiple: true })
|
|
327
|
-
export class LiveInlineDiffPreviewer extends BaseInlineDiffPreviewer<
|
|
328
|
-
private listenNode(node:
|
|
314
|
+
export class LiveInlineDiffPreviewer extends BaseInlineDiffPreviewer<InlineStreamDiffHandler> {
|
|
315
|
+
private listenNode(node: InlineStreamDiffHandler): void {
|
|
329
316
|
node.addDispose(node.onDidEditChange(() => this.layout()));
|
|
330
317
|
node.addDispose(
|
|
331
318
|
node.onPartialEditWidgetListChange((widgets) => {
|
|
@@ -344,13 +331,8 @@ export class LiveInlineDiffPreviewer extends BaseInlineDiffPreviewer<BaseInlineS
|
|
|
344
331
|
this.addDispose(node);
|
|
345
332
|
}
|
|
346
333
|
|
|
347
|
-
createNode(
|
|
348
|
-
|
|
349
|
-
if (reverse) {
|
|
350
|
-
node = this.injector.get(ReverseInlineStreamDiffHandler, [this.monacoEditor]);
|
|
351
|
-
} else {
|
|
352
|
-
node = this.injector.get(InlineStreamDiffHandler, [this.monacoEditor]);
|
|
353
|
-
}
|
|
334
|
+
createNode(): InlineStreamDiffHandler {
|
|
335
|
+
const node = this.injector.get(InlineStreamDiffHandler, [this.monacoEditor]);
|
|
354
336
|
node.initialize(this.selection);
|
|
355
337
|
this.listenNode(node);
|
|
356
338
|
return node;
|
|
@@ -22,33 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
.inlineDiffManager {
|
|
24
24
|
display: flex;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
padding: 12px 16px;
|
|
26
|
+
justify-content: center;
|
|
27
27
|
position: absolute;
|
|
28
|
-
bottom:
|
|
28
|
+
bottom: 0;
|
|
29
29
|
left: 50%;
|
|
30
30
|
transform: translateX(-50%);
|
|
31
|
-
|
|
31
|
+
gap: 12px;
|
|
32
32
|
z-index: 999;
|
|
33
|
-
> div {
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
}
|
|
37
|
-
.mid {
|
|
38
|
-
border-right: 1px solid var(--design-borderColor);
|
|
39
|
-
}
|
|
40
|
-
:global(.codicon) {
|
|
41
|
-
font-size: 20px;
|
|
42
|
-
padding: 6px;
|
|
43
|
-
color: var(--kt-primaryButton-foreground);
|
|
44
|
-
background-color: var(--kt-primaryButton-hoverBackground);
|
|
45
|
-
&:hover {
|
|
46
|
-
background-color: var(--kt-primaryButton-background);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
.disabled {
|
|
51
|
-
// color: var(--kt-button-disableForeground) !important;
|
|
52
|
-
background-color: var(--kt-button-disableBackground) !important;
|
|
53
|
-
cursor: not-allowed;
|
|
54
33
|
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
AINativeSettingSectionsId,
|
|
4
4
|
ChatResponse,
|
|
5
5
|
Disposable,
|
|
6
|
-
DisposableCollection,
|
|
7
6
|
Emitter,
|
|
8
7
|
Event,
|
|
9
8
|
IDisposable,
|
|
@@ -24,7 +23,7 @@ import { BaseAIMonacoEditorController } from '../../contrib/base';
|
|
|
24
23
|
import { EInlineDiffPreviewMode } from '../../preferences/schema';
|
|
25
24
|
import { InlineChatController } from '../inline-chat/inline-chat-controller';
|
|
26
25
|
import { EResultKind } from '../inline-chat/inline-chat.service';
|
|
27
|
-
import {
|
|
26
|
+
import { InlineStreamDiffHandler } from '../inline-stream-diff/inline-stream-diff.handler';
|
|
28
27
|
|
|
29
28
|
import {
|
|
30
29
|
BaseInlineDiffPreviewer,
|
|
@@ -34,7 +33,7 @@ import {
|
|
|
34
33
|
} from './inline-diff-previewer';
|
|
35
34
|
import { InlineDiffWidget } from './inline-diff-widget';
|
|
36
35
|
|
|
37
|
-
type IInlineDiffPreviewer = BaseInlineDiffPreviewer<InlineDiffWidget |
|
|
36
|
+
type IInlineDiffPreviewer = BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler>;
|
|
38
37
|
|
|
39
38
|
export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
40
39
|
public static readonly ID = 'editor.contrib.ai.inline.diff';
|
|
@@ -119,26 +118,28 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
119
118
|
chatResponse?: ChatResponse | InlineChatController;
|
|
120
119
|
previewerOptions?: IDiffPreviewerOptions;
|
|
121
120
|
},
|
|
122
|
-
): BaseInlineDiffPreviewer<InlineDiffWidget |
|
|
121
|
+
): BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> {
|
|
123
122
|
const { crossSelection, chatResponse } = options;
|
|
124
123
|
|
|
125
124
|
const disposable = new Disposable();
|
|
126
125
|
|
|
127
126
|
const previewer = this.createDiffPreviewer(monacoEditor, crossSelection, options.previewerOptions);
|
|
127
|
+
transaction((tx) => {
|
|
128
|
+
this.currentPreviewer.set(previewer, tx);
|
|
129
|
+
this.previewerStore.set(previewer.modelId, previewer);
|
|
130
|
+
});
|
|
128
131
|
|
|
129
132
|
const onFinish = () => {
|
|
130
133
|
previewer.layout();
|
|
131
134
|
disposable.dispose();
|
|
132
135
|
};
|
|
133
136
|
|
|
134
|
-
const previewerDisposable = new DisposableCollection();
|
|
135
|
-
|
|
136
137
|
disposable.addDispose(
|
|
137
138
|
previewer.onReady(() => {
|
|
138
139
|
if (InlineChatController.is(chatResponse)) {
|
|
139
140
|
const controller = chatResponse as InlineChatController;
|
|
140
141
|
|
|
141
|
-
|
|
142
|
+
disposable.addDispose([
|
|
142
143
|
controller.onData((data) => {
|
|
143
144
|
if (ReplyResponse.is(data)) {
|
|
144
145
|
this.renderDiff(previewer, data);
|
|
@@ -166,10 +167,6 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
166
167
|
}),
|
|
167
168
|
);
|
|
168
169
|
|
|
169
|
-
previewer.onDispose(() => {
|
|
170
|
-
previewerDisposable.dispose();
|
|
171
|
-
});
|
|
172
|
-
disposable.addDispose(previewerDisposable);
|
|
173
170
|
previewer.layout();
|
|
174
171
|
return previewer;
|
|
175
172
|
}
|
|
@@ -199,11 +196,6 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
199
196
|
}),
|
|
200
197
|
);
|
|
201
198
|
|
|
202
|
-
transaction((tx) => {
|
|
203
|
-
this.currentPreviewer.set(previewer, tx);
|
|
204
|
-
this.previewerStore.set(previewer.modelId, previewer);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
199
|
return previewer;
|
|
208
200
|
}
|
|
209
201
|
|