@codingame/monaco-vscode-chat-service-override 13.1.7 → 14.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.
Files changed (78) hide show
  1. package/index.js +9 -9
  2. package/package.json +20 -20
  3. package/vscode/src/vs/base/common/objectCache.d.ts +13 -0
  4. package/vscode/src/vs/base/common/objectCache.js +39 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +12 -5
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +95 -23
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +10 -1
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +81 -19
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +144 -66
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +6 -3
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +17 -11
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +8 -7
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +10 -10
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +11 -8
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +168 -167
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +116 -54
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +11 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.js +34 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +11 -11
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +105 -70
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +17 -16
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +154 -83
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +0 -4
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +150 -130
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +13 -7
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +3 -3
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +11 -6
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +449 -229
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -2
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +2 -2
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +7 -6
  42. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
  43. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -2
  45. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +11 -9
  46. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +7 -1
  47. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +76 -13
  48. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +1 -1
  49. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
  50. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +5 -18
  51. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +4 -122
  52. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +3 -1
  53. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -4
  54. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -3
  55. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +42 -11
  56. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +13 -0
  57. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +49 -0
  58. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +14 -0
  59. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +69 -0
  60. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +10 -0
  61. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +24 -0
  62. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +73 -17
  63. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +11 -0
  64. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +22 -0
  65. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
  66. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  67. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +9 -6
  68. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +2 -2
  69. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +2 -2
  70. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +39 -0
  71. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +314 -0
  72. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +34 -19
  73. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +0 -3
  74. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -334
  75. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +0 -31
  76. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +0 -46
  77. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +0 -29
  78. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -168
@@ -4,43 +4,48 @@ import { coalesce, delta, compareBy } from '@codingame/monaco-vscode-api/vscode/
4
4
  import { AsyncIterableSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
5
5
  import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
6
6
  import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
7
- import { BugIndicatingError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
+ import { BugIndicatingError, ErrorNoTelemetry } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
8
8
  import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
9
+ import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
9
10
  import { Disposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
11
+ import { LinkedList } from '@codingame/monaco-vscode-api/vscode/vs/base/common/linkedList';
10
12
  import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
11
- import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
13
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
14
+ import { observableValueOpts } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/api';
12
15
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
16
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
13
17
  import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
14
18
  import { runOnChange, ValueWithChangeEventFromObservable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
15
19
  import { compare } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
16
20
  import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
17
21
  import { isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
18
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
19
22
  import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService';
20
- import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
23
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
21
24
  import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
22
25
  import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
23
26
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
27
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
24
28
  import { bindContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
25
- import { ProgressLocation } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress';
26
- import { IProgressService } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress.service';
29
+ import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
27
30
  import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
28
31
  import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
29
32
  import { IWorkbenchAssignmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service';
30
33
  import { IDecorationsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/decorations/common/decorations.service';
31
34
  import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
35
+ import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
32
36
  import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
33
- import { MultiDiffEditorItem } from '@codingame/monaco-vscode-9d05a43d-c330-5ff1-937e-fde4a3852931-common/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
37
+ import { MultiDiffEditorItem } from '@codingame/monaco-vscode-168b98e5-dc20-5807-b1f9-798f1f92b37f-common/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
34
38
  import { IMultiDiffSourceResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.service';
39
+ import { CellUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
35
40
  import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
36
41
  import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
37
42
  import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
38
- import { defaultChatEditingMaxFileLimit, applyingChatEditsFailedContextKey, decidedChatEditingResourceContextKey, WorkingSetEntryState, hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, inChatEditingSessionContextKey, applyingChatEditsContextKey, chatEditingMaxFileAssignmentName, ChatEditingSessionState, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingResourceContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
43
+ import { defaultChatEditingMaxFileLimit, applyingChatEditsFailedContextKey, decidedChatEditingResourceContextKey, WorkingSetEntryState, hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, inChatEditingSessionContextKey, applyingChatEditsContextKey, chatEditingAgentSupportsReadonlyReferencesContextKey, chatEditingMaxFileAssignmentName, ChatEditingSessionState, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingResourceContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
39
44
  import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
45
+ import { ChatEditingModifiedFileEntry } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry';
40
46
  import { ChatEditingSession } from './chatEditingSession.js';
41
- import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders';
47
+ import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders';
42
48
 
43
- var ChatEditingMultiDiffSourceResolver_1;
44
49
  const STORAGE_KEY_EDITING_SESSION = 'chat.editingSession';
45
50
  let ChatEditingService = class ChatEditingService extends Disposable {
46
51
  get currentAutoApplyOperation() {
@@ -52,34 +57,40 @@ let ChatEditingService = class ChatEditingService extends Disposable {
52
57
  get currentEditingSessionObs() {
53
58
  return this._currentSessionObs;
54
59
  }
55
- get onDidCreateEditingSession() {
56
- return this._onDidCreateEditingSession.event;
57
- }
58
60
  get editingSessionFileLimit() {
61
+ if (this._chatAgentService.toolsAgentModeEnabled) {
62
+ return Number.MAX_SAFE_INTEGER;
63
+ }
59
64
  return this._editingSessionFileLimit ?? defaultChatEditingMaxFileLimit;
60
65
  }
61
- constructor(_instantiationService, multiDiffSourceResolverService, textModelService, contextKeyService, _chatService, _progressService, _editorService, decorationsService, _fileService, lifecycleService, _workbenchAssignmentService, storageService) {
66
+ constructor(_instantiationService, multiDiffSourceResolverService, textModelService, contextKeyService, _chatService, _editorService, decorationsService, _fileService, lifecycleService, _workbenchAssignmentService, _chatAgentService, storageService, logService, extensionService, productService) {
62
67
  super();
63
68
  this._instantiationService = _instantiationService;
64
69
  this._chatService = _chatService;
65
- this._progressService = _progressService;
66
70
  this._editorService = _editorService;
67
71
  this._fileService = _fileService;
68
72
  this.lifecycleService = lifecycleService;
69
73
  this._workbenchAssignmentService = _workbenchAssignmentService;
74
+ this._chatAgentService = _chatAgentService;
70
75
  this._currentSessionObs = observableValue(this, null);
71
76
  this._currentSessionDisposables = this._register(( new DisposableStore()));
77
+ this._adhocSessionsObs = observableValueOpts({ equalsFn: (a, b) => false }, ( new LinkedList()));
78
+ this.editingSessionsObs = derived(r => {
79
+ const result = Array.from(this._adhocSessionsObs.read(r));
80
+ const globalSession = this._currentSessionObs.read(r);
81
+ if (globalSession) {
82
+ result.push(globalSession);
83
+ }
84
+ return result;
85
+ });
72
86
  this._currentAutoApplyOperationObs = observableValue(this, null);
73
- this._onDidCreateEditingSession = this._register(( new Emitter()));
74
- this._onDidChangeEditingSession = this._register(( new Emitter()));
75
- this.onDidChangeEditingSession = this._onDidChangeEditingSession.event;
76
87
  this._chatRelatedFilesProviders = ( new Map());
77
88
  this._applyingChatEditsFailedContextKey = applyingChatEditsFailedContextKey.bindTo(contextKeyService);
78
89
  this._applyingChatEditsFailedContextKey.set(false);
79
90
  this._register(decorationsService.registerDecorationsProvider(_instantiationService.createInstance(ChatDecorationsProvider, this._currentSessionObs)));
80
91
  this._register(multiDiffSourceResolverService.registerResolver(_instantiationService.createInstance(ChatEditingMultiDiffSourceResolver, this._currentSessionObs)));
81
- textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this._currentSessionObs));
82
- textModelService.registerTextModelContentProvider(ChatEditingSnapshotTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this._currentSessionObs));
92
+ this._register(textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this._currentSessionObs)));
93
+ this._register(textModelService.registerTextModelContentProvider(ChatEditingSnapshotTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this._currentSessionObs)));
83
94
  this._register(bindContextKey(decidedChatEditingResourceContextKey, contextKeyService, (reader) => {
84
95
  const currentSession = this._currentSessionObs.read(reader);
85
96
  if (!currentSession) {
@@ -90,13 +101,12 @@ let ChatEditingService = class ChatEditingService extends Disposable {
90
101
  return ( decidedEntries.map(entry => entry.entryId));
91
102
  }));
92
103
  this._register(bindContextKey(hasUndecidedChatEditingResourceContextKey, contextKeyService, (reader) => {
93
- const currentSession = this._currentSessionObs.read(reader);
94
- if (!currentSession) {
95
- return;
104
+ for (const session of this.editingSessionsObs.read(reader)) {
105
+ const entries = session.entries.read(reader);
106
+ const decidedEntries = entries.filter(entry => entry.state.read(reader) === WorkingSetEntryState.Modified);
107
+ return decidedEntries.length > 0;
96
108
  }
97
- const entries = currentSession.entries.read(reader);
98
- const decidedEntries = entries.filter(entry => entry.state.read(reader) === WorkingSetEntryState.Modified);
99
- return decidedEntries.length > 0;
109
+ return false;
100
110
  }));
101
111
  this._register(bindContextKey(hasAppliedChatEditsContextKey, contextKeyService, (reader) => {
102
112
  const currentSession = this._currentSessionObs.read(reader);
@@ -124,11 +134,19 @@ let ChatEditingService = class ChatEditingService extends Disposable {
124
134
  void this._currentSessionObs.get()?.stop();
125
135
  }
126
136
  }));
137
+ const readonlyEnabledContextKey = chatEditingAgentSupportsReadonlyReferencesContextKey.bindTo(contextKeyService);
138
+ const setReadonlyFilesEnabled = () => {
139
+ const enabled = productService.quality !== 'stable' && ( extensionService.extensions.some(e => e.enabledApiProposals?.includes('chatReadonlyPromptReference')));
140
+ readonlyEnabledContextKey.set(enabled);
141
+ };
142
+ setReadonlyFilesEnabled();
143
+ this._register(extensionService.onDidRegisterExtensions(setReadonlyFilesEnabled));
144
+ this._register(extensionService.onDidChangeExtensions(setReadonlyFilesEnabled));
127
145
  this._register(this.lifecycleService.onWillShutdown((e) => {
128
146
  const session = this._currentSessionObs.get();
129
147
  if (session) {
130
148
  storageService.store(STORAGE_KEY_EDITING_SESSION, session.chatSessionId, StorageScope.WORKSPACE, StorageTarget.MACHINE);
131
- e.join(session.storeState(), { id: 'join.chatEditingSession', label: ( localize(4399, "Saving chat edits history")) });
149
+ e.join(session.storeState(), { id: 'join.chatEditingSession', label: ( localize(4499, "Saving chat edits history")) });
132
150
  }
133
151
  }));
134
152
  this._editingSessionFileLimitPromise = this._workbenchAssignmentService.getTreatment(chatEditingMaxFileAssignmentName).then(value => {
@@ -136,11 +154,17 @@ let ChatEditingService = class ChatEditingService extends Disposable {
136
154
  return this._editingSessionFileLimit;
137
155
  });
138
156
  const sessionIdToRestore = storageService.get(STORAGE_KEY_EDITING_SESSION, StorageScope.WORKSPACE);
139
- if (isString(sessionIdToRestore) && this._chatService.getOrRestoreSession(sessionIdToRestore)) {
140
- this._restoringEditingSession = this.startOrContinueEditingSession(sessionIdToRestore);
141
- this._restoringEditingSession.finally(() => {
142
- this._restoringEditingSession = undefined;
143
- });
157
+ if (isString(sessionIdToRestore)) {
158
+ if (this._chatService.getOrRestoreSession(sessionIdToRestore)) {
159
+ this._restoringEditingSession = this.startOrContinueEditingSession(sessionIdToRestore);
160
+ this._restoringEditingSession.finally(() => {
161
+ this._restoringEditingSession = undefined;
162
+ });
163
+ }
164
+ else {
165
+ logService.error(`Edit session session to restore is a non-existing chat session: ${sessionIdToRestore}`);
166
+ }
167
+ storageService.remove(STORAGE_KEY_EDITING_SESSION, StorageScope.WORKSPACE);
144
168
  }
145
169
  }
146
170
  async getOrRestoreEditingSession() {
@@ -166,31 +190,51 @@ let ChatEditingService = class ChatEditingService extends Disposable {
166
190
  }
167
191
  return this._createEditingSession(chatSessionId);
168
192
  }
193
+ _lookupEntry(uri) {
194
+ for (const item of Iterable.concat(this.editingSessionsObs.get())) {
195
+ const candidate = item.getEntry(uri);
196
+ if (candidate instanceof ChatEditingModifiedFileEntry) {
197
+ return candidate.acquire();
198
+ }
199
+ }
200
+ return undefined;
201
+ }
169
202
  async _createEditingSession(chatSessionId) {
170
203
  if (this._currentSessionObs.get()) {
171
204
  throw ( new BugIndicatingError('Cannot have more than one active editing session'));
172
205
  }
173
206
  this._currentSessionDisposables.clear();
174
- const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, this._editingSessionFileLimitPromise);
207
+ const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, true, this._editingSessionFileLimitPromise, this._lookupEntry.bind(this));
175
208
  await session.init();
176
209
  this._currentSessionDisposables.add(this.installAutoApplyObserver(session));
177
210
  this._currentSessionDisposables.add(session.onDidDispose(() => {
178
211
  this._currentSessionDisposables.clear();
179
212
  this._currentSessionObs.set(null, undefined);
180
- this._onDidChangeEditingSession.fire();
181
- }));
182
- this._currentSessionDisposables.add(session.onDidChange(() => {
183
- this._onDidChangeEditingSession.fire();
184
213
  }));
185
214
  this._currentSessionObs.set(session, undefined);
186
- this._onDidCreateEditingSession.fire(session);
187
- this._onDidChangeEditingSession.fire();
215
+ return session;
216
+ }
217
+ async createAdhocEditingSession(chatSessionId) {
218
+ const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, false, this._editingSessionFileLimitPromise, this._lookupEntry.bind(this));
219
+ await session.init();
220
+ const list = this._adhocSessionsObs.get();
221
+ const removeSession = list.unshift(session);
222
+ const store = ( new DisposableStore());
223
+ this._store.add(store);
224
+ store.add(this.installAutoApplyObserver(session));
225
+ store.add(session.onDidDispose(e => {
226
+ removeSession();
227
+ this._adhocSessionsObs.set(list, undefined);
228
+ this._store.deleteAndLeak(store);
229
+ store.dispose();
230
+ }));
231
+ this._adhocSessionsObs.set(list, undefined);
188
232
  return session;
189
233
  }
190
234
  installAutoApplyObserver(session) {
191
235
  const chatModel = this._chatService.getOrRestoreSession(session.chatSessionId);
192
236
  if (!chatModel) {
193
- throw ( new Error(
237
+ throw ( new ErrorNoTelemetry(
194
238
  `Edit session was created for a non-existing chat session: ${session.chatSessionId}`
195
239
  ));
196
240
  }
@@ -213,9 +257,10 @@ let ChatEditingService = class ChatEditingService extends Disposable {
213
257
  for (const part of responseModel.response.value) {
214
258
  if (part.kind === 'codeblockUri' || part.kind === 'textEditGroup') {
215
259
  if (!editedFilesExist.get(part.uri)) {
216
- editedFilesExist.set(part.uri, this._fileService.exists(part.uri).then((e) => {
260
+ const uri = part.uri.scheme === Schemas.vscodeNotebookCell ? CellUri.parse(part.uri)?.notebook ?? part.uri : part.uri;
261
+ editedFilesExist.set(part.uri, this._fileService.exists(uri).then((e) => {
217
262
  if (e) {
218
- this._editorService.openEditor({ resource: part.uri, options: { inactive: true, preserveFocus: true, pinned: true } });
263
+ this._editorService.openEditor({ resource: uri, options: { inactive: true, preserveFocus: true, pinned: true } });
219
264
  }
220
265
  return e;
221
266
  }));
@@ -237,6 +282,9 @@ let ChatEditingService = class ChatEditingService extends Disposable {
237
282
  await editsPromise;
238
283
  editsPromise = this._continueEditingSession(session, async (builder, token) => {
239
284
  for await (const item of editsSource.asyncIterable) {
285
+ if (responseModel.isCanceled) {
286
+ break;
287
+ }
240
288
  if (token.isCancellationRequested) {
241
289
  break;
242
290
  }
@@ -274,9 +322,6 @@ let ChatEditingService = class ChatEditingService extends Disposable {
274
322
  onResponseComplete(responseModel);
275
323
  disposable.dispose();
276
324
  }
277
- else if (responseModel.isCanceled || responseModel.isStale) {
278
- disposable.dispose();
279
- }
280
325
  });
281
326
  }
282
327
  }
@@ -298,12 +343,7 @@ let ChatEditingService = class ChatEditingService extends Disposable {
298
343
  const cancellationTokenSource = ( new CancellationTokenSource());
299
344
  this._currentAutoApplyOperationObs.set(cancellationTokenSource, undefined);
300
345
  try {
301
- await this._progressService.withProgress({
302
- location: ProgressLocation.Window,
303
- title: ( localize2(4400, 'Generating edits...')).value,
304
- }, async () => {
305
- await builder(stream, cancellationTokenSource.token);
306
- }, () => cancellationTokenSource.cancel());
346
+ await builder(stream, cancellationTokenSource.token);
307
347
  }
308
348
  finally {
309
349
  cancellationTokenSource.dispose();
@@ -353,13 +393,16 @@ ChatEditingService = ( __decorate([
353
393
  ( __param(2, ITextModelService)),
354
394
  ( __param(3, IContextKeyService)),
355
395
  ( __param(4, IChatService)),
356
- ( __param(5, IProgressService)),
357
- ( __param(6, IEditorService)),
358
- ( __param(7, IDecorationsService)),
359
- ( __param(8, IFileService)),
360
- ( __param(9, ILifecycleService)),
361
- ( __param(10, IWorkbenchAssignmentService)),
362
- ( __param(11, IStorageService))
396
+ ( __param(5, IEditorService)),
397
+ ( __param(6, IDecorationsService)),
398
+ ( __param(7, IFileService)),
399
+ ( __param(8, ILifecycleService)),
400
+ ( __param(9, IWorkbenchAssignmentService)),
401
+ ( __param(10, IChatAgentService)),
402
+ ( __param(11, IStorageService)),
403
+ ( __param(12, ILogService)),
404
+ ( __param(13, IExtensionService)),
405
+ ( __param(14, IProductService))
363
406
  ], ChatEditingService));
364
407
  function observeArrayChanges(obs, compare, store) {
365
408
  const emitter = store.add(( new Emitter()));
@@ -375,7 +418,7 @@ let ChatDecorationsProvider = class ChatDecorationsProvider extends Disposable {
375
418
  super();
376
419
  this._session = _session;
377
420
  this._chatAgentService = _chatAgentService;
378
- this.label = ( localize(4401, "Chat Editing"));
421
+ this.label = ( localize(4500, "Chat Editing"));
379
422
  this._currentEntries = derived(this, (r) => {
380
423
  const session = this._session.read(r);
381
424
  if (!session) {
@@ -412,7 +455,7 @@ let ChatDecorationsProvider = class ChatDecorationsProvider extends Disposable {
412
455
  return {
413
456
  weight: 1000,
414
457
  letter: Codicon.diffModified,
415
- tooltip: defaultAgentName ? ( localize(4402, "Pending changes from {0}", defaultAgentName)) : ( localize(4403, "Pending changes from chat")),
458
+ tooltip: defaultAgentName ? ( localize(4501, "Pending changes from {0}", defaultAgentName)) : ( localize(4502, "Pending changes from chat")),
416
459
  bubble: true
417
460
  };
418
461
  }
@@ -423,26 +466,18 @@ ChatDecorationsProvider = ( __decorate([
423
466
  ( __param(1, IChatAgentService))
424
467
  ], ChatDecorationsProvider));
425
468
  let ChatEditingMultiDiffSourceResolver = class ChatEditingMultiDiffSourceResolver {
426
- static { ChatEditingMultiDiffSourceResolver_1 = this; }
427
- static { this.scheme = CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME; }
428
- static getMultiDiffSourceUri() {
429
- return ( URI.from({
430
- scheme: ChatEditingMultiDiffSourceResolver_1.scheme,
431
- path: '',
432
- }));
433
- }
434
469
  constructor(_currentSession, _instantiationService) {
435
470
  this._currentSession = _currentSession;
436
471
  this._instantiationService = _instantiationService;
437
472
  }
438
473
  canHandleUri(uri) {
439
- return uri.scheme === ChatEditingMultiDiffSourceResolver_1.scheme;
474
+ return uri.scheme === CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME;
440
475
  }
441
476
  async resolveDiffSource(uri) {
442
477
  return this._instantiationService.createInstance(ChatEditingMultiDiffSource, this._currentSession);
443
478
  }
444
479
  };
445
- ChatEditingMultiDiffSourceResolver = ChatEditingMultiDiffSourceResolver_1 = ( __decorate([
480
+ ChatEditingMultiDiffSourceResolver = ( __decorate([
446
481
  ( __param(1, IInstantiationService))
447
482
  ], ChatEditingMultiDiffSourceResolver));
448
483
  class ChatEditingMultiDiffSource {
@@ -8,21 +8,21 @@ import { ILanguageService } from "@codingame/monaco-vscode-api/vscode/vs/editor/
8
8
  import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
9
9
  import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model";
10
10
  import { ITextModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService";
11
- import { IFileDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service";
12
- import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
13
11
  import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
14
- import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
15
12
  import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
16
13
  import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
14
+ import { ITextFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service";
15
+ import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
17
16
  import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
18
17
  import { ChatEditingSessionChangeType, ChatEditingSessionState, IChatEditingSession, IModifiedFileEntry, WorkingSetDisplayMetadata, WorkingSetEntryRemovalReason, WorkingSetEntryState } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService";
19
- import { IChatResponseModel } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/chatModel";
20
- import { ChatEditingModifiedFileEntry, ISnapshotEntry } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry";
18
+ import { IChatResponseModel } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel";
21
19
  import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service";
22
- import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
20
+ import { ChatEditingModifiedFileEntry, ISnapshotEntry } from "@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry";
23
21
  export declare class ChatEditingSession extends Disposable implements IChatEditingSession {
24
22
  readonly chatSessionId: string;
23
+ readonly isGlobalEditingSession: boolean;
25
24
  private editingSessionFileLimitPromise;
25
+ private _lookupExternalEntry;
26
26
  private readonly _instantiationService;
27
27
  private readonly _modelService;
28
28
  private readonly _languageService;
@@ -30,17 +30,14 @@ export declare class ChatEditingSession extends Disposable implements IChatEditi
30
30
  readonly _bulkEditService: IBulkEditService;
31
31
  private readonly _editorGroupsService;
32
32
  private readonly _editorService;
33
- private readonly _workspaceContextService;
34
- private readonly _fileService;
35
- private readonly _dialogService;
36
- private readonly _chatAgentService;
37
33
  private readonly _chatService;
38
34
  private readonly _notebookService;
35
+ private readonly _textFileService;
36
+ private readonly _chatAgentService;
39
37
  private readonly _state;
40
38
  private readonly _linearHistory;
41
39
  private readonly _linearHistoryIndex;
42
40
  private readonly _initialFileContents;
43
- private readonly _filesToSkipCreating;
44
41
  private readonly _entriesObs;
45
42
  get entries(): IObservable<readonly ChatEditingModifiedFileEntry[]>;
46
43
  private readonly _sequencer;
@@ -49,19 +46,21 @@ export declare class ChatEditingSession extends Disposable implements IChatEditi
49
46
  private _removedTransientEntries;
50
47
  private _editorPane;
51
48
  get state(): IObservable<ChatEditingSessionState>;
52
- readonly canUndo: IObservable<boolean, unknown>;
53
- readonly canRedo: IObservable<boolean, unknown>;
54
- hiddenRequestIds: IObservable<string[], unknown>;
49
+ readonly canUndo: IObservable<boolean>;
50
+ readonly canRedo: IObservable<boolean>;
51
+ hiddenRequestIds: IObservable<string[]>;
55
52
  private readonly _onDidChange;
56
53
  get onDidChange(): import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<ChatEditingSessionChangeType>;
57
54
  private readonly _onDidDispose;
58
55
  get onDidDispose(): import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
59
- get isVisible(): boolean;
60
- constructor(chatSessionId: string, editingSessionFileLimitPromise: Promise<number>, _instantiationService: IInstantiationService, _modelService: IModelService, _languageService: ILanguageService, _textModelService: ITextModelService, _bulkEditService: IBulkEditService, _editorGroupsService: IEditorGroupsService, _editorService: IEditorService, _workspaceContextService: IWorkspaceContextService, _fileService: IFileService, _dialogService: IFileDialogService, _chatAgentService: IChatAgentService, _chatService: IChatService, _notebookService: INotebookService);
56
+ private _isToolsAgentSession;
57
+ get isToolsAgentSession(): boolean;
58
+ constructor(chatSessionId: string, isGlobalEditingSession: boolean, editingSessionFileLimitPromise: Promise<number>, _lookupExternalEntry: (uri: URI) => ChatEditingModifiedFileEntry | undefined, _instantiationService: IInstantiationService, _modelService: IModelService, _languageService: ILanguageService, _textModelService: ITextModelService, _bulkEditService: IBulkEditService, _editorGroupsService: IEditorGroupsService, _editorService: IEditorService, _chatService: IChatService, _notebookService: INotebookService, _textFileService: ITextFileService, _chatAgentService: IChatAgentService);
61
59
  init(): Promise<void>;
62
60
  getEntry(uri: URI): IModifiedFileEntry | undefined;
63
61
  readEntry(uri: URI, reader: IReader | undefined): IModifiedFileEntry | undefined;
64
62
  storeState(): Promise<void>;
63
+ private _triggerSaveParticipantsOnAccept;
65
64
  private _trackCurrentEditorsInWorkingSet;
66
65
  private _findSnapshot;
67
66
  createSnapshot(requestId: string | undefined): void;
@@ -73,6 +72,7 @@ export declare class ChatEditingSession extends Disposable implements IChatEditi
73
72
  restoreSnapshot(requestId: string | undefined): Promise<void>;
74
73
  private _restoreSnapshot;
75
74
  remove(reason: WorkingSetEntryRemovalReason, ...uris: URI[]): void;
75
+ markIsReadonly(resource: URI, isReadonly?: boolean): void;
76
76
  private _assertNotDisposed;
77
77
  accept(...uris: URI[]): Promise<void>;
78
78
  reject(...uris: URI[]): Promise<void>;
@@ -85,6 +85,7 @@ export declare class ChatEditingSession extends Disposable implements IChatEditi
85
85
  acceptStreamingEditsStart(): void;
86
86
  acceptTextEdits(resource: URI, textEdits: TextEdit[], isLastEdits: boolean, responseModel: IChatResponseModel): void;
87
87
  resolve(): void;
88
+ private _trackUntitledWorkingSetEntry;
88
89
  addFileToWorkingSet(resource: URI, description?: string, proposedState?: WorkingSetEntryState.Suggested): void;
89
90
  undoInteraction(): Promise<void>;
90
91
  redoInteraction(): Promise<void>;