@codingame/monaco-vscode-chat-service-override 11.1.2 → 12.0.1

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 (110) hide show
  1. package/index.d.ts +2 -1
  2. package/index.js +64 -1
  3. package/package.json +32 -13
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +21 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +73 -60
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +3 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +73 -81
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +9 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +73 -112
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +12 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +253 -101
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.d.ts +1 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +8 -8
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.d.ts +1 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.d.ts +1 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +16 -14
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +23 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +30 -11
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.d.ts +1 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +12 -12
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.d.ts +1 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +22 -20
  24. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +2 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +23 -20
  26. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +52 -0
  27. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +50 -47
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.d.ts +1 -0
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +124 -95
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +17 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +6 -3
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.d.ts +12 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.js +30 -0
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +69 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +203 -182
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +103 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +458 -165
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +42 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +14 -10
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +26 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/{chatParticipantContributions.js → chatParticipant.contribution.js} +101 -92
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +42 -0
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +164 -25
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +26 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +6 -5
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +30 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +10 -7
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +17 -0
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +941 -0
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +26 -0
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -6
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +54 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +32 -15
  54. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +9 -0
  55. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js +1 -0
  56. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.d.ts +1 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +8 -6
  58. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +26 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +16 -19
  60. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +15 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +108 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +7 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +3 -8
  64. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +1 -1
  65. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +31 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +70 -49
  67. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +6 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.d.ts +7 -0
  69. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/{chatViewsWelcomeContributions.js → chatViewsWelcomeHandler.js} +13 -13
  70. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +44 -0
  71. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +3 -1
  72. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +22 -0
  73. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +1 -0
  74. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +80 -0
  75. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +152 -104
  76. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.d.ts +8 -0
  77. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +2 -1
  78. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +41 -0
  79. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +2 -1
  80. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +31 -0
  81. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +6 -4
  82. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.d.ts +13 -0
  83. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +1 -0
  84. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +24 -0
  85. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +23 -21
  86. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.d.ts +1 -0
  87. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +1 -0
  88. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +39 -0
  89. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +20 -19
  90. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.service.d.ts +7 -0
  91. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.d.ts +1 -0
  92. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +30 -33
  93. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +10 -0
  94. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +6 -4
  95. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +10 -0
  96. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +9 -7
  97. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +44 -0
  98. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +247 -83
  99. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.d.ts +8 -0
  100. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +5 -4
  101. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +29 -0
  102. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +35 -35
  103. package/chat.js +0 -59
  104. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +0 -8
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +0 -326
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +0 -76
  107. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +0 -110
  108. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +0 -287
  109. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +0 -130
  110. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -172
@@ -1,11 +1,12 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { delta, compareBy } from 'vscode/vscode/vs/base/common/arrays';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
3
+ import { coalesce, delta, compareBy } from 'vscode/vscode/vs/base/common/arrays';
3
4
  import { AsyncIterableSource } from 'vscode/vscode/vs/base/common/async';
4
5
  import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
5
6
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
6
7
  import { BugIndicatingError } from 'vscode/vscode/vs/base/common/errors';
7
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
8
- import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
8
+ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
9
+ import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
9
10
  import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
10
11
  import { observableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
11
12
  import 'vscode/vscode/vs/base/common/observableInternal/autorun';
@@ -13,30 +14,34 @@ import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived
13
14
  import { runOnChange, ValueWithChangeEventFromObservable } from 'vscode/vscode/vs/base/common/observableInternal/utils';
14
15
  import { compare } from 'vscode/vscode/vs/base/common/strings';
15
16
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
17
+ import { isString } from 'vscode/vscode/vs/base/common/types';
16
18
  import { URI } from 'vscode/vscode/vs/base/common/uri';
17
19
  import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
18
20
  import { localize, localize2 } from 'vscode/vscode/vs/nls';
19
21
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
20
- import { EditorActivation } from 'vscode/vscode/vs/platform/editor/common/editor';
21
22
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
22
23
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
23
24
  import { bindContextKey } from 'vscode/vscode/vs/platform/observable/common/platformObservableUtils';
25
+ import { ProgressLocation } from 'vscode/vscode/vs/platform/progress/common/progress';
24
26
  import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
27
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
28
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
25
29
  import { IWorkbenchAssignmentService } from 'vscode/vscode/vs/workbench/services/assignment/common/assignmentService.service';
26
30
  import { IDecorationsService } from 'vscode/vscode/vs/workbench/services/decorations/common/decorations.service';
27
- import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
28
31
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
29
- import { MultiDiffEditorInput } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
30
- import { MultiDiffEditorItem } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
32
+ import { ILifecycleService } from 'vscode/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';
31
34
  import { IMultiDiffSourceResolverService } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.service';
32
- import { ICodeMapperService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatCodeMapperService.service';
33
- import { CONTEXT_CHAT_EDITING_CAN_UNDO, CONTEXT_CHAT_EDITING_CAN_REDO } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
34
- import { defaultChatEditingMaxFileLimit, applyingChatEditsFailedContextKey, decidedChatEditingResourceContextKey, hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, inChatEditingSessionContextKey, applyingChatEditsContextKey, chatEditingMaxFileAssignmentName, CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME, chatEditingResourceContextKey } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-search-terminal-common/vscode/vs/workbench/contrib/chat/common/chatEditingService';
35
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
36
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
37
+ import { ChatContextKeys } from 'vscode/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 'vscode/vscode/vs/workbench/contrib/chat/common/chatEditingService';
35
39
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
36
40
  import { ChatEditingSession } from './chatEditingSession.js';
37
- import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from './chatEditingTextModelContentProviders.js';
41
+ import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders';
38
42
 
39
43
  var ChatEditingMultiDiffSourceResolver_1;
44
+ const STORAGE_KEY_EDITING_SESSION = 'chat.editingSession';
40
45
  let ChatEditingService = class ChatEditingService extends Disposable {
41
46
  get currentAutoApplyOperation() {
42
47
  return this._currentAutoApplyOperationObs.get();
@@ -53,25 +58,25 @@ let ChatEditingService = class ChatEditingService extends Disposable {
53
58
  get editingSessionFileLimit() {
54
59
  return this._editingSessionFileLimit ?? defaultChatEditingMaxFileLimit;
55
60
  }
56
- constructor(_editorGroupsService, _instantiationService, multiDiffSourceResolverService, textModelService, contextKeyService, _chatService, _progressService, _codeMapperService, _editorService, decorationsService, _fileService, _workbenchAssignmentService) {
61
+ constructor(_instantiationService, multiDiffSourceResolverService, textModelService, contextKeyService, _chatService, _progressService, _editorService, decorationsService, _fileService, lifecycleService, _workbenchAssignmentService, storageService) {
57
62
  super();
58
- this._editorGroupsService = _editorGroupsService;
59
63
  this._instantiationService = _instantiationService;
60
64
  this._chatService = _chatService;
61
65
  this._progressService = _progressService;
62
- this._codeMapperService = _codeMapperService;
63
66
  this._editorService = _editorService;
64
67
  this._fileService = _fileService;
68
+ this.lifecycleService = lifecycleService;
65
69
  this._workbenchAssignmentService = _workbenchAssignmentService;
66
70
  this._currentSessionObs = observableValue(this, null);
67
- this._currentSessionDisposables = this._register(( (new DisposableStore())));
71
+ this._currentSessionDisposables = this._register(( new DisposableStore()));
68
72
  this._currentAutoApplyOperationObs = observableValue(this, null);
69
- this._onDidCreateEditingSession = this._register(( (new Emitter())));
70
- this._onDidChangeEditingSession = this._register(( (new Emitter())));
73
+ this._onDidCreateEditingSession = this._register(( new Emitter()));
74
+ this._onDidChangeEditingSession = this._register(( new Emitter()));
71
75
  this.onDidChangeEditingSession = this._onDidChangeEditingSession.event;
76
+ this._chatRelatedFilesProviders = ( new Map());
72
77
  this._applyingChatEditsFailedContextKey = applyingChatEditsFailedContextKey.bindTo(contextKeyService);
73
78
  this._applyingChatEditsFailedContextKey.set(false);
74
- this._register(decorationsService.registerDecorationsProvider(( (new ChatDecorationsProvider(this._currentSessionObs)))));
79
+ this._register(decorationsService.registerDecorationsProvider(_instantiationService.createInstance(ChatDecorationsProvider, this._currentSessionObs)));
75
80
  this._register(multiDiffSourceResolverService.registerResolver(_instantiationService.createInstance(ChatEditingMultiDiffSourceResolver, this._currentSessionObs)));
76
81
  textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this._currentSessionObs));
77
82
  textModelService.registerTextModelContentProvider(ChatEditingSnapshotTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this._currentSessionObs));
@@ -81,10 +86,8 @@ let ChatEditingService = class ChatEditingService extends Disposable {
81
86
  return;
82
87
  }
83
88
  const entries = currentSession.entries.read(reader);
84
- const decidedEntries = entries.filter(entry => entry.state.read(reader) !== 0 );
85
- return (
86
- (decidedEntries.map(entry => entry.entryId))
87
- );
89
+ const decidedEntries = entries.filter(entry => entry.state.read(reader) !== WorkingSetEntryState.Modified);
90
+ return ( decidedEntries.map(entry => entry.entryId));
88
91
  }));
89
92
  this._register(bindContextKey(hasUndecidedChatEditingResourceContextKey, contextKeyService, (reader) => {
90
93
  const currentSession = this._currentSessionObs.read(reader);
@@ -92,7 +95,7 @@ let ChatEditingService = class ChatEditingService extends Disposable {
92
95
  return;
93
96
  }
94
97
  const entries = currentSession.entries.read(reader);
95
- const decidedEntries = entries.filter(entry => entry.state.read(reader) === 0 );
98
+ const decidedEntries = entries.filter(entry => entry.state.read(reader) === WorkingSetEntryState.Modified);
96
99
  return decidedEntries.length > 0;
97
100
  }));
98
101
  this._register(bindContextKey(hasAppliedChatEditsContextKey, contextKeyService, (reader) => {
@@ -109,10 +112,10 @@ let ChatEditingService = class ChatEditingService extends Disposable {
109
112
  this._register(bindContextKey(applyingChatEditsContextKey, contextKeyService, (reader) => {
110
113
  return this._currentAutoApplyOperationObs.read(reader) !== null;
111
114
  }));
112
- this._register(bindContextKey(CONTEXT_CHAT_EDITING_CAN_UNDO, contextKeyService, (r) => {
115
+ this._register(bindContextKey(ChatContextKeys.chatEditingCanUndo, contextKeyService, (r) => {
113
116
  return this._currentSessionObs.read(r)?.canUndo.read(r) || false;
114
117
  }));
115
- this._register(bindContextKey(CONTEXT_CHAT_EDITING_CAN_REDO, contextKeyService, (r) => {
118
+ this._register(bindContextKey(ChatContextKeys.chatEditingCanRedo, contextKeyService, (r) => {
116
119
  return this._currentSessionObs.read(r)?.canRedo.read(r) || false;
117
120
  }));
118
121
  this._register(this._chatService.onDidDisposeSession((e) => {
@@ -121,56 +124,56 @@ let ChatEditingService = class ChatEditingService extends Disposable {
121
124
  void this._currentSessionObs.get()?.stop();
122
125
  }
123
126
  }));
127
+ this._register(this.lifecycleService.onWillShutdown((e) => {
128
+ const session = this._currentSessionObs.get();
129
+ if (session) {
130
+ storageService.store(STORAGE_KEY_EDITING_SESSION, session.chatSessionId, StorageScope.WORKSPACE, StorageTarget.MACHINE);
131
+ e.join(session.storeState(), { id: 'join.chatEditingSession', label: ( localize(4381, "Saving chat edits history")) });
132
+ }
133
+ }));
124
134
  this._editingSessionFileLimitPromise = this._workbenchAssignmentService.getTreatment(chatEditingMaxFileAssignmentName).then(value => {
125
135
  this._editingSessionFileLimit = value ?? defaultChatEditingMaxFileLimit;
126
136
  return this._editingSessionFileLimit;
127
137
  });
128
- }
129
- getSnapshotUri(id, uri) {
130
- const session = this._currentSessionObs.get();
131
- if (!session) {
132
- return undefined;
138
+ 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
+ });
133
144
  }
134
- return session.getSnapshot(id, uri)?.snapshotUri;
135
145
  }
136
- getEditingSession(resource) {
137
- const session = this.currentEditingSession;
138
- if (!session) {
139
- return null;
146
+ async getOrRestoreEditingSession() {
147
+ if (this._restoringEditingSession) {
148
+ await this._restoringEditingSession;
140
149
  }
141
- const entries = session.entries.get();
142
- for (const entry of entries) {
143
- if (( (entry.modifiedURI.toString())) === ( (resource.toString()))) {
144
- return session;
145
- }
146
- }
147
- return null;
150
+ return this.currentEditingSessionObs.get();
148
151
  }
149
152
  dispose() {
150
153
  this._currentSessionObs.get()?.dispose();
151
154
  super.dispose();
152
155
  }
153
- async startOrContinueEditingSession(chatSessionId, options) {
156
+ async startOrContinueEditingSession(chatSessionId) {
157
+ await this._restoringEditingSession;
154
158
  const session = this._currentSessionObs.get();
155
159
  if (session) {
156
- if (session.chatSessionId !== chatSessionId) {
157
- throw ( (new BugIndicatingError('Cannot start new session while another session is active')));
160
+ if (session.chatSessionId === chatSessionId) {
161
+ return session;
162
+ }
163
+ else if (session.chatSessionId !== chatSessionId) {
164
+ await session.stop(true);
158
165
  }
159
166
  }
160
- return this._createEditingSession(chatSessionId, options);
167
+ return this._createEditingSession(chatSessionId);
161
168
  }
162
- async _createEditingSession(chatSessionId, options) {
169
+ async _createEditingSession(chatSessionId) {
163
170
  if (this._currentSessionObs.get()) {
164
- throw ( (new BugIndicatingError('Cannot have more than one active editing session')));
171
+ throw ( new BugIndicatingError('Cannot have more than one active editing session'));
165
172
  }
166
173
  this._currentSessionDisposables.clear();
167
- this._currentSessionDisposables.add(this.installAutoApplyObserver(chatSessionId));
168
- const input = MultiDiffEditorInput.fromResourceMultiDiffEditorInput({
169
- multiDiffSource: ChatEditingMultiDiffSourceResolver.getMultiDiffSourceUri(),
170
- label: ( localize(3216, "Suggested Edits"))
171
- }, this._instantiationService);
172
- const editorPane = options?.silent ? undefined : await this._editorGroupsService.activeGroup.openEditor(input, { pinned: true, activation: EditorActivation.ACTIVATE });
173
- const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, editorPane, this._editingSessionFileLimitPromise);
174
+ const session = this._instantiationService.createInstance(ChatEditingSession, chatSessionId, this._editingSessionFileLimitPromise);
175
+ await session.init();
176
+ this._currentSessionDisposables.add(this.installAutoApplyObserver(session));
174
177
  this._currentSessionDisposables.add(session.onDidDispose(() => {
175
178
  this._currentSessionDisposables.clear();
176
179
  this._currentSessionObs.set(null, undefined);
@@ -184,43 +187,29 @@ let ChatEditingService = class ChatEditingService extends Disposable {
184
187
  this._onDidChangeEditingSession.fire();
185
188
  return session;
186
189
  }
187
- triggerEditComputation(responseModel) {
188
- return this._continueEditingSession(async (builder, token) => {
189
- const codeMapperResponse = {
190
- textEdit: (resource, edits) => builder.textEdits(resource, edits, responseModel),
191
- };
192
- await this._codeMapperService.mapCodeFromResponse(responseModel, codeMapperResponse, token);
193
- }, { silent: true });
194
- }
195
- createSnapshot(requestId) {
196
- this._currentSessionObs.get()?.createSnapshot(requestId);
197
- }
198
- async restoreSnapshot(requestId) {
199
- await this._currentSessionObs.get()?.restoreSnapshot(requestId);
200
- }
201
- installAutoApplyObserver(sessionId) {
202
- const chatModel = this._chatService.getSession(sessionId);
190
+ installAutoApplyObserver(session) {
191
+ const chatModel = this._chatService.getOrRestoreSession(session.chatSessionId);
203
192
  if (!chatModel) {
204
- throw ( (new Error(`Edit session was created for a non-existing chat session: ${sessionId}`)));
193
+ throw ( new Error(
194
+ `Edit session was created for a non-existing chat session: ${session.chatSessionId}`
195
+ ));
205
196
  }
206
- const observerDisposables = ( (new DisposableStore()));
197
+ const observerDisposables = ( new DisposableStore());
207
198
  let editsSource;
208
- const editsSeen = ( (new ResourceMap()));
209
- const editedFilesExist = ( (new ResourceMap()));
199
+ let editsPromise;
200
+ const editsSeen = ( new ResourceMap());
201
+ const editedFilesExist = ( new ResourceMap());
210
202
  const onResponseComplete = (responseModel) => {
211
- if (responseModel.result?.errorDetails) {
212
- this.restoreSnapshot(responseModel.requestId);
203
+ if (responseModel.result?.errorDetails && !responseModel.result.errorDetails.responseIsIncomplete) {
204
+ session.restoreSnapshot(responseModel.requestId);
213
205
  this._applyingChatEditsFailedContextKey.set(true);
214
206
  }
215
- else if (responseModel.result?.metadata?.autoApplyEdits) {
216
- this.triggerEditComputation(responseModel);
217
- }
218
207
  editsSource?.resolve();
219
208
  editsSource = undefined;
220
209
  editsSeen.clear();
221
210
  editedFilesExist.clear();
222
211
  };
223
- const handleResponseParts = (responseModel) => {
212
+ const handleResponseParts = async (responseModel) => {
224
213
  for (const part of responseModel.response.value) {
225
214
  if (part.kind === 'codeblockUri' || part.kind === 'textEditGroup') {
226
215
  if (!editedFilesExist.get(part.uri)) {
@@ -240,35 +229,47 @@ let ChatEditingService = class ChatEditingService extends Disposable {
240
229
  const allEdits = part.kind === 'textEditGroup' ? part.edits : [];
241
230
  const newEdits = allEdits.slice(entry.seen);
242
231
  entry.seen += newEdits.length;
243
- editsSource ??= ( (new AsyncIterableSource()));
244
- editsSource.emitOne({ uri: part.uri, edits: newEdits, kind: 'textEditGroup' });
232
+ if (newEdits.length > 0 || entry.seen === 0) {
233
+ editsSource ??= ( new AsyncIterableSource());
234
+ editsSource.emitOne({ uri: part.uri, edits: newEdits, kind: 'textEditGroup', done: part.kind === 'textEditGroup' && part.done });
235
+ }
245
236
  if (first) {
246
- this._continueEditingSession(async (builder, token) => {
237
+ await editsPromise;
238
+ editsPromise = this._continueEditingSession(session, async (builder, token) => {
247
239
  for await (const item of editsSource.asyncIterable) {
248
240
  if (token.isCancellationRequested) {
249
241
  break;
250
242
  }
251
- for (const group of item.edits) {
252
- builder.textEdits(item.uri, group, responseModel);
243
+ if (item.edits.length === 0) {
244
+ builder.textEdits(item.uri, [], item.done ?? false, responseModel);
245
+ continue;
246
+ }
247
+ for (let i = 0; i < item.edits.length; i++) {
248
+ const group = item.edits[i];
249
+ const isLastGroup = i === item.edits.length - 1;
250
+ builder.textEdits(item.uri, group, isLastGroup && (item.done ?? false), responseModel);
253
251
  }
254
252
  }
255
- }, { silent: true });
253
+ }).finally(() => {
254
+ editsPromise = undefined;
255
+ });
256
256
  }
257
257
  }
258
258
  }
259
259
  };
260
- observerDisposables.add(chatModel.onDidChange(e => {
260
+ observerDisposables.add(chatModel.onDidChange(async (e) => {
261
261
  if (e.kind === 'addRequest') {
262
+ session.createSnapshot(e.request.id);
262
263
  this._applyingChatEditsFailedContextKey.set(false);
263
264
  const responseModel = e.request.response;
264
265
  if (responseModel) {
265
266
  if (responseModel.isComplete) {
266
- handleResponseParts(responseModel);
267
+ await handleResponseParts(responseModel);
267
268
  onResponseComplete(responseModel);
268
269
  }
269
270
  else {
270
- const disposable = responseModel.onDidChange(() => {
271
- handleResponseParts(responseModel);
271
+ const disposable = responseModel.onDidChange(async () => {
272
+ await handleResponseParts(responseModel);
272
273
  if (responseModel.isComplete) {
273
274
  onResponseComplete(responseModel);
274
275
  disposable.dispose();
@@ -284,43 +285,25 @@ let ChatEditingService = class ChatEditingService extends Disposable {
284
285
  observerDisposables.add(chatModel.onDidDispose(() => observerDisposables.dispose()));
285
286
  return observerDisposables;
286
287
  }
287
- async _continueEditingSession(builder, options) {
288
- const session = this._currentSessionObs.get();
289
- if (!session) {
290
- throw ( (new BugIndicatingError('Cannot continue missing session')));
291
- }
292
- if (session.state.get() === 1 ) {
293
- throw ( (new BugIndicatingError('Cannot continue session that is still streaming')));
294
- }
295
- let editorPane;
296
- if (!options?.silent && session.isVisible) {
297
- const groupedEditors = this._findGroupedEditors();
298
- if (groupedEditors.length !== 1) {
299
- throw ( (new Error(`Unexpected number of editors: ${groupedEditors.length}`)));
300
- }
301
- const [group, editor] = groupedEditors[0];
302
- editorPane = await group.openEditor(editor, { pinned: true, activation: EditorActivation.ACTIVATE });
288
+ async _continueEditingSession(session, builder) {
289
+ if (session.state.get() === ChatEditingSessionState.StreamingEdits) {
290
+ throw ( new BugIndicatingError('Cannot continue session that is still streaming'));
303
291
  }
304
292
  const stream = {
305
- textEdits: (resource, textEdits, responseModel) => {
306
- session.acceptTextEdits(resource, textEdits, responseModel);
293
+ textEdits: (resource, textEdits, isDone, responseModel) => {
294
+ session.acceptTextEdits(resource, textEdits, isDone, responseModel);
307
295
  }
308
296
  };
309
297
  session.acceptStreamingEditsStart();
310
- const cancellationTokenSource = ( (new CancellationTokenSource()));
298
+ const cancellationTokenSource = ( new CancellationTokenSource());
311
299
  this._currentAutoApplyOperationObs.set(cancellationTokenSource, undefined);
312
300
  try {
313
- if (editorPane) {
314
- await editorPane?.showWhile(builder(stream, cancellationTokenSource.token));
315
- }
316
- else {
317
- await this._progressService.withProgress({
318
- location: 10 ,
319
- title: ( localize2(3217, 'Generating edits...')).value,
320
- }, async () => {
321
- await builder(stream, cancellationTokenSource.token);
322
- }, () => cancellationTokenSource.cancel());
323
- }
301
+ await this._progressService.withProgress({
302
+ location: ProgressLocation.Window,
303
+ title: ( localize2(4382, 'Generating edits...')).value,
304
+ }, async () => {
305
+ await builder(stream, cancellationTokenSource.token);
306
+ }, () => cancellationTokenSource.cancel());
324
307
  }
325
308
  finally {
326
309
  cancellationTokenSource.dispose();
@@ -328,34 +311,58 @@ let ChatEditingService = class ChatEditingService extends Disposable {
328
311
  session.resolve();
329
312
  }
330
313
  }
331
- _findGroupedEditors() {
332
- const editors = [];
333
- for (const group of this._editorGroupsService.groups) {
334
- for (const editor of group.editors) {
335
- if (editor.resource?.scheme === ChatEditingMultiDiffSourceResolver.scheme) {
336
- editors.push([group, editor]);
337
- }
314
+ hasRelatedFilesProviders() {
315
+ return this._chatRelatedFilesProviders.size > 0;
316
+ }
317
+ registerRelatedFilesProvider(handle, provider) {
318
+ this._chatRelatedFilesProviders.set(handle, provider);
319
+ return toDisposable(() => {
320
+ this._chatRelatedFilesProviders.delete(handle);
321
+ });
322
+ }
323
+ async getRelatedFiles(chatSessionId, prompt, token) {
324
+ const currentSession = this._currentSessionObs.get();
325
+ if (!currentSession || chatSessionId !== currentSession.chatSessionId) {
326
+ return undefined;
327
+ }
328
+ const userAddedWorkingSetEntries = [];
329
+ for (const [uri, metadata] of currentSession.workingSet) {
330
+ if (metadata.state !== WorkingSetEntryState.Suggested) {
331
+ userAddedWorkingSetEntries.push(uri);
338
332
  }
339
333
  }
340
- return editors;
334
+ const providers = Array.from(( this._chatRelatedFilesProviders.values()));
335
+ const result = await Promise.all(( providers.map(async (provider) => {
336
+ try {
337
+ const relatedFiles = await provider.provideRelatedFiles({ prompt, files: userAddedWorkingSetEntries }, token);
338
+ if (relatedFiles?.length) {
339
+ return { group: provider.description, files: relatedFiles };
340
+ }
341
+ return undefined;
342
+ }
343
+ catch (e) {
344
+ return undefined;
345
+ }
346
+ })));
347
+ return coalesce(result);
341
348
  }
342
349
  };
343
- ChatEditingService = ( (__decorate([
344
- ( (__param(0, IEditorGroupsService))),
345
- ( (__param(1, IInstantiationService))),
346
- ( (__param(2, IMultiDiffSourceResolverService))),
347
- ( (__param(3, ITextModelService))),
348
- ( (__param(4, IContextKeyService))),
349
- ( (__param(5, IChatService))),
350
- ( (__param(6, IProgressService))),
351
- ( (__param(7, ICodeMapperService))),
352
- ( (__param(8, IEditorService))),
353
- ( (__param(9, IDecorationsService))),
354
- ( (__param(10, IFileService))),
355
- ( (__param(11, IWorkbenchAssignmentService)))
356
- ], ChatEditingService)));
350
+ ChatEditingService = ( __decorate([
351
+ ( __param(0, IInstantiationService)),
352
+ ( __param(1, IMultiDiffSourceResolverService)),
353
+ ( __param(2, ITextModelService)),
354
+ ( __param(3, IContextKeyService)),
355
+ ( __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))
363
+ ], ChatEditingService));
357
364
  function observeArrayChanges(obs, compare, store) {
358
- const emitter = store.add(( (new Emitter())));
365
+ const emitter = store.add(( new Emitter()));
359
366
  store.add(runOnChange(obs, (newArr, oldArr) => {
360
367
  const change = delta(oldArr || [], newArr, compare);
361
368
  const changedElements = [].concat(change.added).concat(change.removed);
@@ -363,48 +370,66 @@ function observeArrayChanges(obs, compare, store) {
363
370
  }));
364
371
  return emitter.event;
365
372
  }
366
- class ChatDecorationsProvider extends Disposable {
367
- constructor(_session) {
373
+ let ChatDecorationsProvider = class ChatDecorationsProvider extends Disposable {
374
+ constructor(_session, _chatAgentService) {
368
375
  super();
369
376
  this._session = _session;
370
- this.label = ( localize(3218, "Chat Editing"));
371
- this._currentlyEditingUris = derived(this, (r) => {
377
+ this._chatAgentService = _chatAgentService;
378
+ this.label = ( localize(4383, "Chat Editing"));
379
+ this._currentEntries = derived(this, (r) => {
372
380
  const session = this._session.read(r);
373
381
  if (!session) {
374
382
  return [];
375
383
  }
376
384
  const state = session.state.read(r);
377
- if (state === 3 ) {
385
+ if (state === ChatEditingSessionState.Disposed) {
378
386
  return [];
379
387
  }
380
- return (
381
- (session.entries.read(r).filter(entry => entry.isCurrentlyBeingModified.read(r)).map(entry => entry.modifiedURI))
382
- );
388
+ return session.entries.read(r);
383
389
  });
384
- this.onDidChange = observeArrayChanges(this._currentlyEditingUris, compareBy(uri => ( (uri.toString())), compare), this._store);
390
+ this._currentlyEditingUris = derived(this, (r) => {
391
+ const uri = this._currentEntries.read(r);
392
+ return ( uri.filter(entry => entry.isCurrentlyBeingModified.read(r)).map(entry => entry.modifiedURI));
393
+ });
394
+ this._modifiedUris = derived(this, (r) => {
395
+ const uri = this._currentEntries.read(r);
396
+ return ( uri.filter(entry => !entry.isCurrentlyBeingModified.read(r) && entry.state.read(r) === WorkingSetEntryState.Modified).map(entry => entry.modifiedURI));
397
+ });
398
+ this.onDidChange = Event.any(observeArrayChanges(this._currentlyEditingUris, compareBy(uri => ( uri.toString()), compare), this._store), observeArrayChanges(this._modifiedUris, compareBy(uri => ( uri.toString()), compare), this._store));
385
399
  }
386
400
  provideDecorations(uri, _token) {
387
- const isCurrentlyBeingModified = ( (this._currentlyEditingUris.get().some(e => ( (e.toString())) === ( (uri.toString())))));
388
- if (!isCurrentlyBeingModified) {
389
- return undefined;
401
+ const isCurrentlyBeingModified = ( this._currentlyEditingUris.get().some(e => ( e.toString()) === ( uri.toString())));
402
+ if (isCurrentlyBeingModified) {
403
+ return {
404
+ weight: 1000,
405
+ letter: ThemeIcon.modify(Codicon.loading, 'spin'),
406
+ bubble: false
407
+ };
390
408
  }
391
- return {
392
- weight: 1000,
393
- letter: ThemeIcon.modify(Codicon.loading, 'spin'),
394
- bubble: false
395
- };
409
+ const isModified = ( this._modifiedUris.get().some(e => ( e.toString()) === ( uri.toString())));
410
+ if (isModified) {
411
+ const defaultAgentName = this._chatAgentService.getDefaultAgent(ChatAgentLocation.EditingSession)?.fullName;
412
+ return {
413
+ weight: 1000,
414
+ letter: Codicon.diffModified,
415
+ tooltip: defaultAgentName ? ( localize(4384, "Pending changes from {0}", defaultAgentName)) : ( localize(4385, "Pending changes from chat")),
416
+ bubble: true
417
+ };
418
+ }
419
+ return undefined;
396
420
  }
397
- }
421
+ };
422
+ ChatDecorationsProvider = ( __decorate([
423
+ ( __param(1, IChatAgentService))
424
+ ], ChatDecorationsProvider));
398
425
  let ChatEditingMultiDiffSourceResolver = class ChatEditingMultiDiffSourceResolver {
399
426
  static { ChatEditingMultiDiffSourceResolver_1 = this; }
400
427
  static { this.scheme = CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME; }
401
428
  static getMultiDiffSourceUri() {
402
- return (
403
- (URI.from({
404
- scheme: ChatEditingMultiDiffSourceResolver_1.scheme,
405
- path: '',
406
- }))
407
- );
429
+ return ( URI.from({
430
+ scheme: ChatEditingMultiDiffSourceResolver_1.scheme,
431
+ path: '',
432
+ }));
408
433
  }
409
434
  constructor(_currentSession, _instantiationService) {
410
435
  this._currentSession = _currentSession;
@@ -417,9 +442,9 @@ let ChatEditingMultiDiffSourceResolver = class ChatEditingMultiDiffSourceResolve
417
442
  return this._instantiationService.createInstance(ChatEditingMultiDiffSource, this._currentSession);
418
443
  }
419
444
  };
420
- ChatEditingMultiDiffSourceResolver = ChatEditingMultiDiffSourceResolver_1 = ( (__decorate([
421
- ( (__param(1, IInstantiationService)))
422
- ], ChatEditingMultiDiffSourceResolver)));
445
+ ChatEditingMultiDiffSourceResolver = ChatEditingMultiDiffSourceResolver_1 = ( __decorate([
446
+ ( __param(1, IInstantiationService))
447
+ ], ChatEditingMultiDiffSourceResolver));
423
448
  class ChatEditingMultiDiffSource {
424
449
  constructor(_currentSession) {
425
450
  this._currentSession = _currentSession;
@@ -429,17 +454,13 @@ class ChatEditingMultiDiffSource {
429
454
  return [];
430
455
  }
431
456
  const entries = currentSession.entries.read(reader);
432
- return (
433
- (entries.map((entry) => {
434
- return (
435
- (new MultiDiffEditorItem(entry.originalURI, entry.modifiedURI, undefined, {
436
- [chatEditingResourceContextKey.key]: entry.entryId,
437
- }))
438
- );
439
- }))
440
- );
457
+ return ( entries.map((entry) => {
458
+ return ( new MultiDiffEditorItem(entry.originalURI, entry.modifiedURI, undefined, {
459
+ [chatEditingResourceContextKey.key]: entry.entryId,
460
+ }));
461
+ }));
441
462
  });
442
- this.resources = ( (new ValueWithChangeEventFromObservable(this._resources)));
463
+ this.resources = ( new ValueWithChangeEventFromObservable(this._resources));
443
464
  this.contextKeys = {
444
465
  [inChatEditingSessionContextKey.key]: true
445
466
  };