@codingame/monaco-vscode-chat-service-override 14.0.6 → 15.0.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/index.js +14 -8
- package/package.json +20 -20
- package/vscode/src/vs/base/common/objectCache.d.ts +1 -1
- package/vscode/src/vs/base/common/objectCache.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +43 -42
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +40 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +142 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +25 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +252 -260
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +8 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +12 -41
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +7 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +31 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +151 -69
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.js +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +379 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/{chatEditingService.d.ts → chatEditingServiceImpl.d.ts} +12 -28
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +423 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +6 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +38 -38
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +16 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +93 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +21 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +101 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +146 -126
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +39 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +386 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +8 -91
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +7 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +45 -45
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +11 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +82 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +22 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.d.ts +16 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +67 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +24 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +78 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +13 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +12 -10
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +26 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +85 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +33 -27
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +0 -10
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +4 -6
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +15 -23
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +175 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +6 -7
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +101 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +12 -12
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +31 -36
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +0 -505
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +0 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +0 -871
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +0 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +0 -245
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +0 -39
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +0 -314
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { coalesce, delta, compareBy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
4
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
5
|
+
import { ErrorNoTelemetry } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
6
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
7
|
+
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
8
|
+
import { Disposable, dispose, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
9
|
+
import { LinkedList } from '@codingame/monaco-vscode-api/vscode/vs/base/common/linkedList';
|
|
10
|
+
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
11
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
12
|
+
import { compare } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
13
|
+
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
14
|
+
import { isString, assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
15
|
+
import { TextEdit } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
16
|
+
import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
|
|
17
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
18
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
19
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
20
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
21
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
22
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
23
|
+
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
24
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
25
|
+
import { IDecorationsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/decorations/common/decorations.service';
|
|
26
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
27
|
+
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
28
|
+
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
29
|
+
import { MultiDiffEditorItem } from '@codingame/monaco-vscode-1bb39316-6fbf-572e-ab6a-818a2496c14f-common/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
|
|
30
|
+
import { IMultiDiffSourceResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.service';
|
|
31
|
+
import { CellUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
32
|
+
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
33
|
+
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
34
|
+
import { chatEditingSnapshotScheme, chatEditingAgentSupportsReadonlyReferencesContextKey, ChatEditingSessionState, WorkingSetEntryState, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingResourceContextKey, inChatEditingSessionContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
|
|
35
|
+
import { isCellTextEditOperation } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
36
|
+
import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
|
|
37
|
+
import { AbstractChatEditingModifiedFileEntry } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry';
|
|
38
|
+
import { ChatEditingSession } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession';
|
|
39
|
+
import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders';
|
|
40
|
+
import { observableValueOpts } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/api';
|
|
41
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
42
|
+
import { runOnChange, ValueWithChangeEventFromObservable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
43
|
+
|
|
44
|
+
const STORAGE_KEY_EDITING_SESSION = 'chat.editingSession';
|
|
45
|
+
let ChatEditingService = class ChatEditingService extends Disposable {
|
|
46
|
+
constructor(_instantiationService, multiDiffSourceResolverService, textModelService, contextKeyService, _chatService, _editorService, decorationsService, _fileService, lifecycleService, storageService, logService, extensionService, productService) {
|
|
47
|
+
super();
|
|
48
|
+
this._instantiationService = _instantiationService;
|
|
49
|
+
this._chatService = _chatService;
|
|
50
|
+
this._editorService = _editorService;
|
|
51
|
+
this._fileService = _fileService;
|
|
52
|
+
this.lifecycleService = lifecycleService;
|
|
53
|
+
this._sessionsObs = observableValueOpts({ equalsFn: (a, b) => false }, ( new LinkedList()));
|
|
54
|
+
this.editingSessionsObs = derived(r => {
|
|
55
|
+
const result = Array.from(this._sessionsObs.read(r));
|
|
56
|
+
return result;
|
|
57
|
+
});
|
|
58
|
+
this._chatRelatedFilesProviders = ( new Map());
|
|
59
|
+
this._register(decorationsService.registerDecorationsProvider(_instantiationService.createInstance(ChatDecorationsProvider, this.editingSessionsObs)));
|
|
60
|
+
this._register(multiDiffSourceResolverService.registerResolver(_instantiationService.createInstance(ChatEditingMultiDiffSourceResolver, this.editingSessionsObs)));
|
|
61
|
+
this._register(textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this)));
|
|
62
|
+
this._register(textModelService.registerTextModelContentProvider(chatEditingSnapshotScheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this)));
|
|
63
|
+
this._register(this._chatService.onDidDisposeSession((e) => {
|
|
64
|
+
if (e.reason === 'cleared') {
|
|
65
|
+
this.getEditingSession(e.sessionId)?.stop();
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
const readonlyEnabledContextKey = chatEditingAgentSupportsReadonlyReferencesContextKey.bindTo(contextKeyService);
|
|
69
|
+
const setReadonlyFilesEnabled = () => {
|
|
70
|
+
const enabled = productService.quality !== 'stable' && ( extensionService.extensions.some(e => e.enabledApiProposals?.includes('chatReadonlyPromptReference')));
|
|
71
|
+
readonlyEnabledContextKey.set(enabled);
|
|
72
|
+
};
|
|
73
|
+
setReadonlyFilesEnabled();
|
|
74
|
+
this._register(extensionService.onDidRegisterExtensions(setReadonlyFilesEnabled));
|
|
75
|
+
this._register(extensionService.onDidChangeExtensions(setReadonlyFilesEnabled));
|
|
76
|
+
let storageTask;
|
|
77
|
+
this._register(storageService.onWillSaveState(() => {
|
|
78
|
+
const sessionIds = [];
|
|
79
|
+
const tasks = [];
|
|
80
|
+
for (const session of this.editingSessionsObs.get()) {
|
|
81
|
+
if (!session.isGlobalEditingSession) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
sessionIds.push(session.chatSessionId);
|
|
85
|
+
tasks.push(session.storeState());
|
|
86
|
+
}
|
|
87
|
+
if (sessionIds.length) {
|
|
88
|
+
storageService.store(STORAGE_KEY_EDITING_SESSION, sessionIds.join(), StorageScope.WORKSPACE, StorageTarget.MACHINE);
|
|
89
|
+
}
|
|
90
|
+
storageTask = Promise.resolve(storageTask)
|
|
91
|
+
.then(() => Promise.all(tasks))
|
|
92
|
+
.finally(() => storageTask = undefined);
|
|
93
|
+
}));
|
|
94
|
+
this._register(this.lifecycleService.onWillShutdown(e => {
|
|
95
|
+
if (!storageTask) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
e.join(storageTask, {
|
|
99
|
+
id: 'join.chatEditingSession',
|
|
100
|
+
label: ( localize(4580, "Saving chat edits history"))
|
|
101
|
+
});
|
|
102
|
+
}));
|
|
103
|
+
const rawSessionsToRestore = storageService.get(STORAGE_KEY_EDITING_SESSION, StorageScope.WORKSPACE);
|
|
104
|
+
if (isString(rawSessionsToRestore)) {
|
|
105
|
+
const sessionIds = rawSessionsToRestore.split(',');
|
|
106
|
+
const tasks = [];
|
|
107
|
+
for (const sessionId of sessionIds) {
|
|
108
|
+
const chatModel = _chatService.getOrRestoreSession(sessionId);
|
|
109
|
+
if (!chatModel) {
|
|
110
|
+
logService.error(`Edit session session to restore is a non-existing chat session: ${rawSessionsToRestore}`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
tasks.push(this.startOrContinueGlobalEditingSession(chatModel.sessionId));
|
|
114
|
+
}
|
|
115
|
+
this._restoringEditingSession = Promise.all(tasks).finally(() => {
|
|
116
|
+
this._restoringEditingSession = undefined;
|
|
117
|
+
});
|
|
118
|
+
storageService.remove(STORAGE_KEY_EDITING_SESSION, StorageScope.WORKSPACE);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
dispose() {
|
|
122
|
+
dispose(this._sessionsObs.get());
|
|
123
|
+
super.dispose();
|
|
124
|
+
}
|
|
125
|
+
async startOrContinueGlobalEditingSession(chatSessionId) {
|
|
126
|
+
await this._restoringEditingSession;
|
|
127
|
+
const session = this.getEditingSession(chatSessionId);
|
|
128
|
+
if (session) {
|
|
129
|
+
return session;
|
|
130
|
+
}
|
|
131
|
+
return this.createEditingSession(chatSessionId, true);
|
|
132
|
+
}
|
|
133
|
+
_lookupEntry(uri) {
|
|
134
|
+
for (const item of Iterable.concat(this.editingSessionsObs.get())) {
|
|
135
|
+
const candidate = item.getEntry(uri);
|
|
136
|
+
if (candidate instanceof AbstractChatEditingModifiedFileEntry) {
|
|
137
|
+
return candidate.acquire();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
getEditingSession(chatSessionId) {
|
|
143
|
+
return this.editingSessionsObs.get()
|
|
144
|
+
.find(candidate => candidate.chatSessionId === chatSessionId);
|
|
145
|
+
}
|
|
146
|
+
async createEditingSession(chatSessionId, global = false) {
|
|
147
|
+
assertType(this.getEditingSession(chatSessionId) === undefined, 'CANNOT have more than one editing session per chat session');
|
|
148
|
+
const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, global, this._lookupEntry.bind(this));
|
|
149
|
+
await session.init();
|
|
150
|
+
const list = this._sessionsObs.get();
|
|
151
|
+
const removeSession = list.unshift(session);
|
|
152
|
+
const store = ( new DisposableStore());
|
|
153
|
+
this._store.add(store);
|
|
154
|
+
store.add(this.installAutoApplyObserver(session));
|
|
155
|
+
store.add(session.onDidDispose(e => {
|
|
156
|
+
removeSession();
|
|
157
|
+
this._sessionsObs.set(list, undefined);
|
|
158
|
+
this._store.delete(store);
|
|
159
|
+
}));
|
|
160
|
+
this._sessionsObs.set(list, undefined);
|
|
161
|
+
return session;
|
|
162
|
+
}
|
|
163
|
+
installAutoApplyObserver(session) {
|
|
164
|
+
const chatModel = this._chatService.getOrRestoreSession(session.chatSessionId);
|
|
165
|
+
if (!chatModel) {
|
|
166
|
+
throw ( new ErrorNoTelemetry(
|
|
167
|
+
`Edit session was created for a non-existing chat session: ${session.chatSessionId}`
|
|
168
|
+
));
|
|
169
|
+
}
|
|
170
|
+
const observerDisposables = ( new DisposableStore());
|
|
171
|
+
observerDisposables.add(chatModel.onDidChange(async (e) => {
|
|
172
|
+
if (e.kind !== 'addRequest') {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
session.createSnapshot(e.request.id, undefined);
|
|
176
|
+
const responseModel = e.request.response;
|
|
177
|
+
if (responseModel) {
|
|
178
|
+
this.observerEditsInResponse(e.request.id, responseModel, session, observerDisposables);
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
observerDisposables.add(chatModel.onDidDispose(() => observerDisposables.dispose()));
|
|
182
|
+
return observerDisposables;
|
|
183
|
+
}
|
|
184
|
+
observerEditsInResponse(requestId, responseModel, session, observerDisposables) {
|
|
185
|
+
const editsSeen = [];
|
|
186
|
+
const editedFilesExist = ( new ResourceMap());
|
|
187
|
+
const ensureEditorOpen = (partUri) => {
|
|
188
|
+
const uri = CellUri.parse(partUri)?.notebook ?? partUri;
|
|
189
|
+
if (( editedFilesExist.has(uri))) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
editedFilesExist.set(uri, this._fileService.exists(uri).then((e) => {
|
|
193
|
+
if (!e) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const activeUri = this._editorService.activeEditorPane?.input.resource;
|
|
197
|
+
const inactive = activeUri && ( session.workingSet.has(activeUri));
|
|
198
|
+
this._editorService.openEditor({ resource: uri, options: { inactive, preserveFocus: true, pinned: true } });
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
const onResponseComplete = () => {
|
|
202
|
+
for (const remaining of editsSeen) {
|
|
203
|
+
remaining?.streaming.complete();
|
|
204
|
+
}
|
|
205
|
+
if (responseModel.result?.errorDetails && !responseModel.result.errorDetails.responseIsIncomplete) {
|
|
206
|
+
session.restoreSnapshot(responseModel.requestId, undefined);
|
|
207
|
+
}
|
|
208
|
+
editsSeen.length = 0;
|
|
209
|
+
editedFilesExist.clear();
|
|
210
|
+
};
|
|
211
|
+
const handleResponseParts = async () => {
|
|
212
|
+
if (responseModel.isCanceled) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
let undoStop;
|
|
216
|
+
for (let i = 0; i < responseModel.response.value.length; i++) {
|
|
217
|
+
const part = responseModel.response.value[i];
|
|
218
|
+
if (part.kind === 'undoStop') {
|
|
219
|
+
undoStop = part.id;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (part.kind !== 'textEditGroup' && part.kind !== 'notebookEditGroup') {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
ensureEditorOpen(part.uri);
|
|
226
|
+
let entry = editsSeen[i];
|
|
227
|
+
if (!entry) {
|
|
228
|
+
entry = { seen: 0, streaming: session.startStreamingEdits(CellUri.parse(part.uri)?.notebook ?? part.uri, responseModel, undoStop) };
|
|
229
|
+
editsSeen[i] = entry;
|
|
230
|
+
}
|
|
231
|
+
const isFirst = entry.seen === 0;
|
|
232
|
+
const newEdits = part.edits.slice(entry.seen).flat();
|
|
233
|
+
entry.seen = part.edits.length;
|
|
234
|
+
if (newEdits.length > 0 || isFirst) {
|
|
235
|
+
if (part.kind === 'notebookEditGroup') {
|
|
236
|
+
newEdits.forEach(edit => {
|
|
237
|
+
if (TextEdit.isTextEdit(edit)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
else if (isCellTextEditOperation(edit)) {
|
|
241
|
+
entry.streaming.pushNotebookCellText(edit.uri, [edit.edit]);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
entry.streaming.pushNotebook([edit]);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else if (part.kind === 'textEditGroup') {
|
|
249
|
+
entry.streaming.pushText(newEdits);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (part.done) {
|
|
253
|
+
entry.streaming.complete();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
if (responseModel.isComplete) {
|
|
258
|
+
handleResponseParts().then(() => {
|
|
259
|
+
onResponseComplete();
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const disposable = observerDisposables.add(responseModel.onDidChange(e2 => {
|
|
264
|
+
if (e2.reason === 'undoStop') {
|
|
265
|
+
session.createSnapshot(requestId, e2.id);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
handleResponseParts().then(() => {
|
|
269
|
+
if (responseModel.isComplete) {
|
|
270
|
+
onResponseComplete();
|
|
271
|
+
observerDisposables.delete(disposable);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
hasRelatedFilesProviders() {
|
|
279
|
+
return this._chatRelatedFilesProviders.size > 0;
|
|
280
|
+
}
|
|
281
|
+
registerRelatedFilesProvider(handle, provider) {
|
|
282
|
+
this._chatRelatedFilesProviders.set(handle, provider);
|
|
283
|
+
return toDisposable(() => {
|
|
284
|
+
this._chatRelatedFilesProviders.delete(handle);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
async getRelatedFiles(chatSessionId, prompt, files, token) {
|
|
288
|
+
const providers = Array.from(( this._chatRelatedFilesProviders.values()));
|
|
289
|
+
const result = await Promise.all(( providers.map(async (provider) => {
|
|
290
|
+
try {
|
|
291
|
+
const relatedFiles = await provider.provideRelatedFiles({ prompt, files }, token);
|
|
292
|
+
if (relatedFiles?.length) {
|
|
293
|
+
return { group: provider.description, files: relatedFiles };
|
|
294
|
+
}
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
catch (e) {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
})));
|
|
301
|
+
return coalesce(result);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
ChatEditingService = ( __decorate([
|
|
305
|
+
( __param(0, IInstantiationService)),
|
|
306
|
+
( __param(1, IMultiDiffSourceResolverService)),
|
|
307
|
+
( __param(2, ITextModelService)),
|
|
308
|
+
( __param(3, IContextKeyService)),
|
|
309
|
+
( __param(4, IChatService)),
|
|
310
|
+
( __param(5, IEditorService)),
|
|
311
|
+
( __param(6, IDecorationsService)),
|
|
312
|
+
( __param(7, IFileService)),
|
|
313
|
+
( __param(8, ILifecycleService)),
|
|
314
|
+
( __param(9, IStorageService)),
|
|
315
|
+
( __param(10, ILogService)),
|
|
316
|
+
( __param(11, IExtensionService)),
|
|
317
|
+
( __param(12, IProductService))
|
|
318
|
+
], ChatEditingService));
|
|
319
|
+
function observeArrayChanges(obs, compare, store) {
|
|
320
|
+
const emitter = store.add(( new Emitter()));
|
|
321
|
+
store.add(runOnChange(obs, (newArr, oldArr) => {
|
|
322
|
+
const change = delta(oldArr || [], newArr, compare);
|
|
323
|
+
const changedElements = [].concat(change.added).concat(change.removed);
|
|
324
|
+
emitter.fire(changedElements);
|
|
325
|
+
}));
|
|
326
|
+
return emitter.event;
|
|
327
|
+
}
|
|
328
|
+
let ChatDecorationsProvider = class ChatDecorationsProvider extends Disposable {
|
|
329
|
+
constructor(_sessions, _chatAgentService) {
|
|
330
|
+
super();
|
|
331
|
+
this._sessions = _sessions;
|
|
332
|
+
this._chatAgentService = _chatAgentService;
|
|
333
|
+
this.label = ( localize(4581, "Chat Editing"));
|
|
334
|
+
this._currentEntries = derived(this, (r) => {
|
|
335
|
+
const sessions = this._sessions.read(r);
|
|
336
|
+
if (!sessions) {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
const result = [];
|
|
340
|
+
for (const session of sessions) {
|
|
341
|
+
if (session.state.read(r) !== ChatEditingSessionState.Disposed) {
|
|
342
|
+
const entries = session.entries.read(r);
|
|
343
|
+
result.push(...entries);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return result;
|
|
347
|
+
});
|
|
348
|
+
this._currentlyEditingUris = derived(this, (r) => {
|
|
349
|
+
const uri = this._currentEntries.read(r);
|
|
350
|
+
return ( uri.filter(entry => entry.isCurrentlyBeingModifiedBy.read(r)).map(entry => entry.modifiedURI));
|
|
351
|
+
});
|
|
352
|
+
this._modifiedUris = derived(this, (r) => {
|
|
353
|
+
const uri = this._currentEntries.read(r);
|
|
354
|
+
return ( uri.filter(entry => !entry.isCurrentlyBeingModifiedBy.read(r) && entry.state.read(r) === WorkingSetEntryState.Modified).map(entry => entry.modifiedURI));
|
|
355
|
+
});
|
|
356
|
+
this.onDidChange = Event.any(observeArrayChanges(this._currentlyEditingUris, compareBy(uri => ( uri.toString()), compare), this._store), observeArrayChanges(this._modifiedUris, compareBy(uri => ( uri.toString()), compare), this._store));
|
|
357
|
+
}
|
|
358
|
+
provideDecorations(uri, _token) {
|
|
359
|
+
const isCurrentlyBeingModified = ( this._currentlyEditingUris.get().some(e => ( e.toString()) === ( uri.toString())));
|
|
360
|
+
if (isCurrentlyBeingModified) {
|
|
361
|
+
return {
|
|
362
|
+
weight: 1000,
|
|
363
|
+
letter: ThemeIcon.modify(Codicon.loading, 'spin'),
|
|
364
|
+
bubble: false
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const isModified = ( this._modifiedUris.get().some(e => ( e.toString()) === ( uri.toString())));
|
|
368
|
+
if (isModified) {
|
|
369
|
+
const defaultAgentName = this._chatAgentService.getDefaultAgent(ChatAgentLocation.EditingSession)?.fullName;
|
|
370
|
+
return {
|
|
371
|
+
weight: 1000,
|
|
372
|
+
letter: Codicon.diffModified,
|
|
373
|
+
tooltip: defaultAgentName ? ( localize(4582, "Pending changes from {0}", defaultAgentName)) : ( localize(4583, "Pending changes from chat")),
|
|
374
|
+
bubble: true
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
ChatDecorationsProvider = ( __decorate([
|
|
381
|
+
( __param(1, IChatAgentService))
|
|
382
|
+
], ChatDecorationsProvider));
|
|
383
|
+
let ChatEditingMultiDiffSourceResolver = class ChatEditingMultiDiffSourceResolver {
|
|
384
|
+
constructor(_editingSessionsObs, _instantiationService) {
|
|
385
|
+
this._editingSessionsObs = _editingSessionsObs;
|
|
386
|
+
this._instantiationService = _instantiationService;
|
|
387
|
+
}
|
|
388
|
+
canHandleUri(uri) {
|
|
389
|
+
return uri.scheme === CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME;
|
|
390
|
+
}
|
|
391
|
+
async resolveDiffSource(uri) {
|
|
392
|
+
const thisSession = derived(this, r => {
|
|
393
|
+
return this._editingSessionsObs.read(r).find(candidate => candidate.chatSessionId === uri.authority);
|
|
394
|
+
});
|
|
395
|
+
return this._instantiationService.createInstance(ChatEditingMultiDiffSource, thisSession);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
ChatEditingMultiDiffSourceResolver = ( __decorate([
|
|
399
|
+
( __param(1, IInstantiationService))
|
|
400
|
+
], ChatEditingMultiDiffSourceResolver));
|
|
401
|
+
class ChatEditingMultiDiffSource {
|
|
402
|
+
constructor(_currentSession) {
|
|
403
|
+
this._currentSession = _currentSession;
|
|
404
|
+
this._resources = derived(this, (reader) => {
|
|
405
|
+
const currentSession = this._currentSession.read(reader);
|
|
406
|
+
if (!currentSession) {
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
409
|
+
const entries = currentSession.entries.read(reader);
|
|
410
|
+
return ( entries.map((entry) => {
|
|
411
|
+
return ( new MultiDiffEditorItem(entry.originalURI, entry.modifiedURI, undefined, {
|
|
412
|
+
[chatEditingResourceContextKey.key]: entry.entryId,
|
|
413
|
+
}));
|
|
414
|
+
}));
|
|
415
|
+
});
|
|
416
|
+
this.resources = ( new ValueWithChangeEventFromObservable(this._resources));
|
|
417
|
+
this.contextKeys = {
|
|
418
|
+
[inChatEditingSessionContextKey.key]: true
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export { ChatEditingMultiDiffSourceResolver, ChatEditingService };
|
|
@@ -7,10 +7,10 @@ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
7
7
|
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
8
8
|
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
9
9
|
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
|
10
|
-
import { EditorPane } from "@codingame/monaco-vscode-
|
|
10
|
+
import { EditorPane } from "@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/browser/parts/editor/editorPane";
|
|
11
11
|
import { IEditorOpenContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
|
|
12
|
-
import { ChatEditorInput } from "@codingame/monaco-vscode-
|
|
13
|
-
import { IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-
|
|
12
|
+
import { ChatEditorInput } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput";
|
|
13
|
+
import { IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
|
|
14
14
|
import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
|
|
15
15
|
export interface IChatEditorOptions extends IEditorOptions {
|
|
16
16
|
target?: {
|
|
@@ -18,13 +18,13 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/misc
|
|
|
18
18
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
19
19
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
|
|
20
20
|
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
21
|
-
import { EditorPane } from '@codingame/monaco-vscode-
|
|
22
|
-
import { Memento } from '@codingame/monaco-vscode-
|
|
23
|
-
import { clearChatEditor } from '@codingame/monaco-vscode-
|
|
24
|
-
import { ChatEditorInput } from '@codingame/monaco-vscode-
|
|
25
|
-
import { ChatWidget } from '@codingame/monaco-vscode-
|
|
21
|
+
import { EditorPane } from '@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
22
|
+
import { Memento } from '@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/common/memento';
|
|
23
|
+
import { clearChatEditor } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
|
|
24
|
+
import { ChatEditorInput } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
|
|
25
|
+
import { ChatWidget } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
26
26
|
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
27
|
-
import { CHAT_PROVIDER_ID } from '@codingame/monaco-vscode-
|
|
27
|
+
import { CHAT_PROVIDER_ID } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
|
|
28
28
|
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
|
|
29
29
|
|
|
30
30
|
let ChatEditor = class ChatEditor extends EditorPane {
|
|
@@ -47,7 +47,6 @@ let ChatEditor = class ChatEditor extends EditorPane {
|
|
|
47
47
|
const scopedInstantiationService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService]))));
|
|
48
48
|
this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, ChatAgentLocation.Panel, undefined, {
|
|
49
49
|
supportsFileReferences: true,
|
|
50
|
-
enableImplicitContext: true
|
|
51
50
|
}, {
|
|
52
51
|
listForeground: editorForeground,
|
|
53
52
|
listBackground: editorBackground,
|