@codingame/monaco-vscode-a793b3ee-7ba9-5176-a019-30ec806fdd95-common 20.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 (18) hide show
  1. package/empty.js +1 -0
  2. package/package.json +50 -0
  3. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.d.ts +159 -0
  4. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +1318 -0
  5. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.d.ts +172 -0
  6. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +482 -0
  7. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +86 -0
  8. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +377 -0
  9. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.d.ts +70 -0
  10. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +456 -0
  11. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.d.ts +40 -0
  12. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.js +276 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.d.ts +22 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +318 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.d.ts +18 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +59 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.d.ts +69 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +318 -0
@@ -0,0 +1,86 @@
1
+ import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
+ import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
3
+ import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
4
+ import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
5
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
6
+ import { IActiveCodeEditor, ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
7
+ import { Range } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range";
8
+ import { ILanguageService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service";
9
+ import { IValidEditOperation } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
10
+ import { IEditorWorkerService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker.service";
11
+ import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
12
+ import { ITextModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service";
13
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
14
+ import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
15
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
16
+ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
17
+ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
18
+ import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
19
+ import { ITextFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service";
20
+ import { IChatWidgetService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service";
21
+ import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
22
+ import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service";
23
+ import { Session, StashedSession } from "./inlineChatSession.js";
24
+ import { IInlineChatSession2, IInlineChatSessionEndEvent, IInlineChatSessionEvent, ISessionKeyComputer } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService";
25
+ import { IInlineChatSessionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service";
26
+ export declare class InlineChatError extends Error {
27
+ static readonly code = "InlineChatError";
28
+ constructor(message: string);
29
+ }
30
+ export declare class InlineChatSessionServiceImpl implements IInlineChatSessionService {
31
+ private readonly _telemetryService;
32
+ private readonly _modelService;
33
+ private readonly _textModelService;
34
+ private readonly _editorWorkerService;
35
+ private readonly _logService;
36
+ private readonly _instaService;
37
+ private readonly _editorService;
38
+ private readonly _textFileService;
39
+ private readonly _languageService;
40
+ private readonly _chatService;
41
+ private readonly _chatAgentService;
42
+ private readonly _chatWidgetService;
43
+ private readonly _configurationService;
44
+ _serviceBrand: undefined;
45
+ private readonly _store;
46
+ private readonly _onWillStartSession;
47
+ readonly onWillStartSession: Event<IActiveCodeEditor>;
48
+ private readonly _onDidMoveSession;
49
+ readonly onDidMoveSession: Event<IInlineChatSessionEvent>;
50
+ private readonly _onDidEndSession;
51
+ readonly onDidEndSession: Event<IInlineChatSessionEndEvent>;
52
+ private readonly _onDidStashSession;
53
+ readonly onDidStashSession: Event<IInlineChatSessionEvent>;
54
+ private readonly _sessions;
55
+ private readonly _keyComputers;
56
+ readonly hideOnRequest: IObservable<boolean>;
57
+ constructor(_telemetryService: ITelemetryService, _modelService: IModelService, _textModelService: ITextModelService, _editorWorkerService: IEditorWorkerService, _logService: ILogService, _instaService: IInstantiationService, _editorService: IEditorService, _textFileService: ITextFileService, _languageService: ILanguageService, _chatService: IChatService, _chatAgentService: IChatAgentService, _chatWidgetService: IChatWidgetService, _configurationService: IConfigurationService);
58
+ dispose(): void;
59
+ createSession(editor: IActiveCodeEditor, options: {
60
+ headless?: boolean;
61
+ wholeRange?: Range;
62
+ session?: Session;
63
+ }, token: CancellationToken): Promise<Session | undefined>;
64
+ moveSession(session: Session, target: ICodeEditor): void;
65
+ releaseSession(session: Session): void;
66
+ private _releaseSession;
67
+ stashSession(session: Session, editor: ICodeEditor, undoCancelEdits: IValidEditOperation[]): StashedSession;
68
+ getCodeEditor(session: Session): ICodeEditor;
69
+ getSession(editor: ICodeEditor, uri: URI): Session | undefined;
70
+ private _key;
71
+ registerSessionKeyComputer(scheme: string, value: ISessionKeyComputer): IDisposable;
72
+ private readonly _sessions2;
73
+ private readonly _onDidChangeSessions;
74
+ readonly onDidChangeSessions: Event<this>;
75
+ createSession2(editor: ICodeEditor, uri: URI, token: CancellationToken): Promise<IInlineChatSession2>;
76
+ getSession2(uri: URI): IInlineChatSession2 | undefined;
77
+ }
78
+ export declare class InlineChatEnabler {
79
+ static Id: string;
80
+ private readonly _ctxHasProvider;
81
+ private readonly _ctxHasProvider2;
82
+ private readonly _ctxPossible;
83
+ private readonly _store;
84
+ constructor(contextKeyService: IContextKeyService, chatAgentService: IChatAgentService, editorService: IEditorService, configService: IConfigurationService);
85
+ dispose(): void;
86
+ }
@@ -0,0 +1,377 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
4
+ import { DisposableStore, toDisposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
5
+ import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
6
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
7
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
8
+ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
9
+ import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
10
+ import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
11
+ import { isCodeEditor, isDiffEditor, isCompositeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
12
+ import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
13
+ import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
14
+ import { createTextBufferFactoryFromSnapshot } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
15
+ import { IEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker.service';
16
+ import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
17
+ import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
18
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
19
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.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 { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
23
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
24
+ import { DEFAULT_EDITOR_ASSOCIATION } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
25
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
26
+ import { ITextFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service';
27
+ import { UntitledTextEditorInput } from '@codingame/monaco-vscode-ac93482b-2178-52df-a200-ba0d1a4963fb-common/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput';
28
+ import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
29
+ import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
30
+ import { ModifiedFileEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
31
+ import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
32
+ import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
33
+ import { InlineChatConfigKeys, CTX_INLINE_CHAT_HAS_AGENT, CTX_INLINE_CHAT_HAS_AGENT2, CTX_INLINE_CHAT_POSSIBLE } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
34
+ import { Session, SessionWholeRange, HunkData, StashedSession } from './inlineChatSession.js';
35
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
36
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
37
+
38
+ class InlineChatError extends Error {
39
+ static { this.code = 'InlineChatError'; }
40
+ constructor(message) {
41
+ super(message);
42
+ this.name = InlineChatError.code;
43
+ }
44
+ }
45
+ let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
46
+ constructor(_telemetryService, _modelService, _textModelService, _editorWorkerService, _logService, _instaService, _editorService, _textFileService, _languageService, _chatService, _chatAgentService, _chatWidgetService, _configurationService) {
47
+ this._telemetryService = _telemetryService;
48
+ this._modelService = _modelService;
49
+ this._textModelService = _textModelService;
50
+ this._editorWorkerService = _editorWorkerService;
51
+ this._logService = _logService;
52
+ this._instaService = _instaService;
53
+ this._editorService = _editorService;
54
+ this._textFileService = _textFileService;
55
+ this._languageService = _languageService;
56
+ this._chatService = _chatService;
57
+ this._chatAgentService = _chatAgentService;
58
+ this._chatWidgetService = _chatWidgetService;
59
+ this._configurationService = _configurationService;
60
+ this._store = ( new DisposableStore());
61
+ this._onWillStartSession = this._store.add(( new Emitter()));
62
+ this.onWillStartSession = this._onWillStartSession.event;
63
+ this._onDidMoveSession = this._store.add(( new Emitter()));
64
+ this.onDidMoveSession = this._onDidMoveSession.event;
65
+ this._onDidEndSession = this._store.add(( new Emitter()));
66
+ this.onDidEndSession = this._onDidEndSession.event;
67
+ this._onDidStashSession = this._store.add(( new Emitter()));
68
+ this.onDidStashSession = this._onDidStashSession.event;
69
+ this._sessions = ( new Map());
70
+ this._keyComputers = ( new Map());
71
+ this._sessions2 = ( new ResourceMap());
72
+ this._onDidChangeSessions = this._store.add(( new Emitter()));
73
+ this.onDidChangeSessions = this._onDidChangeSessions.event;
74
+ const v2 = observableConfigValue(InlineChatConfigKeys.EnableV2, false, this._configurationService);
75
+ this.hideOnRequest = ( observableConfigValue(InlineChatConfigKeys.HideOnRequest, false, this._configurationService)
76
+ .map((value, r) => v2.read(r) && value));
77
+ }
78
+ dispose() {
79
+ this._store.dispose();
80
+ this._sessions.forEach(x => x.store.dispose());
81
+ this._sessions.clear();
82
+ }
83
+ async createSession(editor, options, token) {
84
+ const agent = this._chatAgentService.getDefaultAgent(ChatAgentLocation.Editor);
85
+ if (!agent) {
86
+ this._logService.trace('[IE] NO agent found');
87
+ return undefined;
88
+ }
89
+ this._onWillStartSession.fire(editor);
90
+ const textModel = editor.getModel();
91
+ const selection = editor.getSelection();
92
+ const store = ( new DisposableStore());
93
+ this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${agent.extensionId}`);
94
+ const chatModel = options.session?.chatModel ?? this._chatService.startSession(ChatAgentLocation.Editor, token);
95
+ if (!chatModel) {
96
+ this._logService.trace('[IE] NO chatModel found');
97
+ return undefined;
98
+ }
99
+ store.add(toDisposable(() => {
100
+ const doesOtherSessionUseChatModel = ( [...( this._sessions.values())].some(data => data.session !== session && data.session.chatModel === chatModel));
101
+ if (!doesOtherSessionUseChatModel) {
102
+ this._chatService.clearSession(chatModel.sessionId);
103
+ chatModel.dispose();
104
+ }
105
+ }));
106
+ const lastResponseListener = store.add(( new MutableDisposable()));
107
+ store.add(chatModel.onDidChange(e => {
108
+ if (e.kind !== 'addRequest' || !e.request.response) {
109
+ return;
110
+ }
111
+ const { response } = e.request;
112
+ session.markModelVersion(e.request);
113
+ lastResponseListener.value = response.onDidChange(() => {
114
+ if (!response.isComplete) {
115
+ return;
116
+ }
117
+ lastResponseListener.clear();
118
+ for (const part of response.response.value) {
119
+ if (part.kind !== 'textEditGroup' || part.uri.scheme !== Schemas.untitled || isEqual(part.uri, session.textModelN.uri)) {
120
+ continue;
121
+ }
122
+ const langSelection = this._languageService.createByFilepathOrFirstLine(part.uri, undefined);
123
+ const untitledTextModel = this._textFileService.untitled.create({
124
+ associatedResource: part.uri,
125
+ languageId: langSelection.languageId
126
+ });
127
+ untitledTextModel.resolve();
128
+ this._textModelService.createModelReference(part.uri).then(ref => {
129
+ store.add(ref);
130
+ });
131
+ }
132
+ });
133
+ }));
134
+ store.add(this._chatAgentService.onDidChangeAgents(e => {
135
+ if (e === undefined && (!this._chatAgentService.getAgent(agent.id) || !( this._chatAgentService.getActivatedAgents().map(agent => agent.id)).includes(agent.id))) {
136
+ this._logService.trace(`[IE] provider GONE for ${editor.getId()}, ${agent.extensionId}`);
137
+ this._releaseSession(session, true);
138
+ }
139
+ }));
140
+ const id = generateUuid();
141
+ const targetUri = textModel.uri;
142
+ store.add((await this._textModelService.createModelReference(textModel.uri)));
143
+ const textModelN = textModel;
144
+ const textModel0 = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.vscode, authority: 'inline-chat', path: '', query: ( ( new URLSearchParams({ id, 'textModel0': '' })).toString()) }), true));
145
+ if (targetUri.scheme === Schemas.untitled) {
146
+ store.add(this._editorService.onDidCloseEditor(() => {
147
+ if (!this._editorService.isOpened({ resource: targetUri, typeId: UntitledTextEditorInput.ID, editorId: DEFAULT_EDITOR_ASSOCIATION.id })) {
148
+ this._releaseSession(session, true);
149
+ }
150
+ }));
151
+ }
152
+ let wholeRange = options.wholeRange;
153
+ if (!wholeRange) {
154
+ wholeRange = ( new Range(
155
+ selection.selectionStartLineNumber,
156
+ selection.selectionStartColumn,
157
+ selection.positionLineNumber,
158
+ selection.positionColumn
159
+ ));
160
+ }
161
+ if (token.isCancellationRequested) {
162
+ store.dispose();
163
+ return undefined;
164
+ }
165
+ const session = ( new Session(
166
+ options.headless ?? false,
167
+ targetUri,
168
+ textModel0,
169
+ textModelN,
170
+ agent,
171
+ store.add(( new SessionWholeRange(textModelN, wholeRange))),
172
+ store.add(( new HunkData(this._editorWorkerService, textModel0, textModelN))),
173
+ chatModel,
174
+ options.session?.versionsByRequest
175
+ ));
176
+ const key = this._key(editor, session.targetUri);
177
+ if (( this._sessions.has(key))) {
178
+ store.dispose();
179
+ throw ( new Error(`Session already stored for ${key}`));
180
+ }
181
+ this._sessions.set(key, { session, editor, store });
182
+ return session;
183
+ }
184
+ moveSession(session, target) {
185
+ const newKey = this._key(target, session.targetUri);
186
+ const existing = this._sessions.get(newKey);
187
+ if (existing) {
188
+ if (existing.session !== session) {
189
+ throw ( new Error(`Cannot move session because the target editor already/still has one`));
190
+ }
191
+ else {
192
+ return;
193
+ }
194
+ }
195
+ let found = false;
196
+ for (const [oldKey, data] of this._sessions) {
197
+ if (data.session === session) {
198
+ found = true;
199
+ this._sessions.delete(oldKey);
200
+ this._sessions.set(newKey, { ...data, editor: target });
201
+ this._logService.trace(`[IE] did MOVE session for ${data.editor.getId()} to NEW EDITOR ${target.getId()}, ${session.agent.extensionId}`);
202
+ this._onDidMoveSession.fire({ session, editor: target });
203
+ break;
204
+ }
205
+ }
206
+ if (!found) {
207
+ throw ( new Error(`Cannot move session because it is not stored`));
208
+ }
209
+ }
210
+ releaseSession(session) {
211
+ this._releaseSession(session, false);
212
+ }
213
+ _releaseSession(session, byServer) {
214
+ let tuple;
215
+ for (const candidate of this._sessions) {
216
+ if (candidate[1].session === session) {
217
+ tuple = candidate;
218
+ break;
219
+ }
220
+ }
221
+ if (!tuple) {
222
+ return;
223
+ }
224
+ this._telemetryService.publicLog2('interactiveEditor/session', session.asTelemetryData());
225
+ const [key, value] = tuple;
226
+ this._sessions.delete(key);
227
+ this._logService.trace(`[IE] did RELEASED session for ${value.editor.getId()}, ${session.agent.extensionId}`);
228
+ this._onDidEndSession.fire({ editor: value.editor, session, endedByExternalCause: byServer });
229
+ value.store.dispose();
230
+ }
231
+ stashSession(session, editor, undoCancelEdits) {
232
+ const result = this._instaService.createInstance(StashedSession, editor, session, undoCancelEdits);
233
+ this._onDidStashSession.fire({ editor, session });
234
+ this._logService.trace(`[IE] did STASH session for ${editor.getId()}, ${session.agent.extensionId}`);
235
+ return result;
236
+ }
237
+ getCodeEditor(session) {
238
+ for (const [, data] of this._sessions) {
239
+ if (data.session === session) {
240
+ return data.editor;
241
+ }
242
+ }
243
+ throw ( new Error('session not found'));
244
+ }
245
+ getSession(editor, uri) {
246
+ const key = this._key(editor, uri);
247
+ return this._sessions.get(key)?.session;
248
+ }
249
+ _key(editor, uri) {
250
+ const item = this._keyComputers.get(uri.scheme);
251
+ return item
252
+ ? item.getComparisonKey(editor, uri)
253
+ : `${editor.getId()}@${( uri.toString())}`;
254
+ }
255
+ registerSessionKeyComputer(scheme, value) {
256
+ this._keyComputers.set(scheme, value);
257
+ return toDisposable(() => this._keyComputers.delete(scheme));
258
+ }
259
+ async createSession2(editor, uri, token) {
260
+ assertType(editor.hasModel());
261
+ if (( this._sessions2.has(uri))) {
262
+ throw ( new Error('Session already exists'));
263
+ }
264
+ this._onWillStartSession.fire(editor);
265
+ const chatModel = this._chatService.startSession(ChatAgentLocation.Panel, token, false);
266
+ const editingSession = await chatModel.editingSessionObs?.promise;
267
+ const widget = this._chatWidgetService.getWidgetBySessionId(chatModel.sessionId);
268
+ await widget?.attachmentModel.addFile(uri);
269
+ const store = ( new DisposableStore());
270
+ store.add(toDisposable(() => {
271
+ this._chatService.cancelCurrentRequestForSession(chatModel.sessionId);
272
+ editingSession.reject();
273
+ this._sessions2.delete(uri);
274
+ this._onDidChangeSessions.fire(this);
275
+ }));
276
+ store.add(chatModel);
277
+ store.add(autorun(r => {
278
+ const entries = editingSession.entries.read(r);
279
+ if (entries.length === 0) {
280
+ return;
281
+ }
282
+ const allSettled = entries.every(entry => {
283
+ const state = entry.state.read(r);
284
+ return (state === ModifiedFileEntryState.Accepted || state === ModifiedFileEntryState.Rejected)
285
+ && !entry.isCurrentlyBeingModifiedBy.read(r);
286
+ });
287
+ if (allSettled && !chatModel.requestInProgress) {
288
+ store.dispose();
289
+ }
290
+ }));
291
+ const result = {
292
+ uri,
293
+ initialPosition: editor.getPosition().delta(-1),
294
+ chatModel,
295
+ editingSession,
296
+ dispose: store.dispose.bind(store)
297
+ };
298
+ this._sessions2.set(uri, result);
299
+ this._onDidChangeSessions.fire(this);
300
+ return result;
301
+ }
302
+ getSession2(uri) {
303
+ let result = this._sessions2.get(uri);
304
+ if (!result) {
305
+ for (const [_, candidate] of this._sessions2) {
306
+ const entry = candidate.editingSession.getEntry(uri);
307
+ if (entry) {
308
+ result = candidate;
309
+ break;
310
+ }
311
+ }
312
+ }
313
+ return result;
314
+ }
315
+ };
316
+ InlineChatSessionServiceImpl = ( __decorate([
317
+ ( __param(0, ITelemetryService)),
318
+ ( __param(1, IModelService)),
319
+ ( __param(2, ITextModelService)),
320
+ ( __param(3, IEditorWorkerService)),
321
+ ( __param(4, ILogService)),
322
+ ( __param(5, IInstantiationService)),
323
+ ( __param(6, IEditorService)),
324
+ ( __param(7, ITextFileService)),
325
+ ( __param(8, ILanguageService)),
326
+ ( __param(9, IChatService)),
327
+ ( __param(10, IChatAgentService)),
328
+ ( __param(11, IChatWidgetService)),
329
+ ( __param(12, IConfigurationService))
330
+ ], InlineChatSessionServiceImpl));
331
+ let InlineChatEnabler = class InlineChatEnabler {
332
+ static { this.Id = 'inlineChat.enabler'; }
333
+ constructor(contextKeyService, chatAgentService, editorService, configService) {
334
+ this._store = ( new DisposableStore());
335
+ this._ctxHasProvider = CTX_INLINE_CHAT_HAS_AGENT.bindTo(contextKeyService);
336
+ this._ctxHasProvider2 = CTX_INLINE_CHAT_HAS_AGENT2.bindTo(contextKeyService);
337
+ this._ctxPossible = CTX_INLINE_CHAT_POSSIBLE.bindTo(contextKeyService);
338
+ const agentObs = observableFromEvent(this, chatAgentService.onDidChangeAgents, () => chatAgentService.getDefaultAgent(ChatAgentLocation.Editor));
339
+ const inlineChat2Obs = observableConfigValue(InlineChatConfigKeys.EnableV2, false, configService);
340
+ this._store.add(autorun(r => {
341
+ const v2 = inlineChat2Obs.read(r);
342
+ const agent = agentObs.read(r);
343
+ if (!agent) {
344
+ this._ctxHasProvider.reset();
345
+ this._ctxHasProvider2.reset();
346
+ }
347
+ else if (v2) {
348
+ this._ctxHasProvider.reset();
349
+ this._ctxHasProvider2.set(true);
350
+ }
351
+ else {
352
+ this._ctxHasProvider.set(true);
353
+ this._ctxHasProvider2.reset();
354
+ }
355
+ }));
356
+ const updateEditor = () => {
357
+ const ctrl = editorService.activeEditorPane?.getControl();
358
+ const isCodeEditorLike = isCodeEditor(ctrl) || isDiffEditor(ctrl) || isCompositeEditor(ctrl);
359
+ this._ctxPossible.set(isCodeEditorLike);
360
+ };
361
+ this._store.add(editorService.onDidActiveEditorChange(updateEditor));
362
+ updateEditor();
363
+ }
364
+ dispose() {
365
+ this._ctxPossible.reset();
366
+ this._ctxHasProvider.reset();
367
+ this._store.dispose();
368
+ }
369
+ };
370
+ InlineChatEnabler = ( __decorate([
371
+ ( __param(0, IContextKeyService)),
372
+ ( __param(1, IChatAgentService)),
373
+ ( __param(2, IEditorService)),
374
+ ( __param(3, IConfigurationService))
375
+ ], InlineChatEnabler));
376
+
377
+ export { InlineChatEnabler, InlineChatError, InlineChatSessionServiceImpl };
@@ -0,0 +1,70 @@
1
+ import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
+ import { Emitter, Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
3
+ import { DisposableStore } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
4
+ import { ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
5
+ import { ISingleEditOperation } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/editOperation";
6
+ import { Position } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position";
7
+ import { IModelDeltaDecoration, IValidEditOperation } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
8
+ import { IEditorWorkerService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker.service";
9
+ import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
10
+ import { HunkInformation, Session } from "./inlineChatSession.js";
11
+ import { InlineChatZoneWidget } from "./inlineChatZoneWidget.js";
12
+ import { IAccessibilityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service";
13
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
14
+ import { ITextFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service";
15
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
16
+ import { IMenuService } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions.service";
17
+ export interface IEditObserver {
18
+ start(): void;
19
+ stop(): void;
20
+ }
21
+ export declare enum HunkAction {
22
+ Accept = 0,
23
+ Discard = 1,
24
+ MoveNext = 2,
25
+ MovePrev = 3,
26
+ ToggleDiff = 4
27
+ }
28
+ export declare class LiveStrategy {
29
+ protected readonly _session: Session;
30
+ protected readonly _editor: ICodeEditor;
31
+ protected readonly _zone: InlineChatZoneWidget;
32
+ private readonly _showOverlayToolbar;
33
+ protected readonly _editorWorkerService: IEditorWorkerService;
34
+ private readonly _accessibilityService;
35
+ private readonly _configService;
36
+ private readonly _menuService;
37
+ private readonly _contextService;
38
+ private readonly _textFileService;
39
+ protected readonly _instaService: IInstantiationService;
40
+ private readonly _decoInsertedText;
41
+ private readonly _decoInsertedTextRange;
42
+ protected readonly _store: DisposableStore;
43
+ protected readonly _onDidAccept: Emitter<void>;
44
+ protected readonly _onDidDiscard: Emitter<void>;
45
+ private readonly _ctxCurrentChangeHasDiff;
46
+ private readonly _ctxCurrentChangeShowsDiff;
47
+ private readonly _progressiveEditingDecorations;
48
+ private readonly _lensActionsFactory;
49
+ private _editCount;
50
+ private readonly _hunkData;
51
+ readonly onDidAccept: Event<void>;
52
+ readonly onDidDiscard: Event<void>;
53
+ constructor(_session: Session, _editor: ICodeEditor, _zone: InlineChatZoneWidget, _showOverlayToolbar: boolean, contextKeyService: IContextKeyService, _editorWorkerService: IEditorWorkerService, _accessibilityService: IAccessibilityService, _configService: IConfigurationService, _menuService: IMenuService, _contextService: IContextKeyService, _textFileService: ITextFileService, _instaService: IInstantiationService);
54
+ dispose(): void;
55
+ private _resetDiff;
56
+ apply(): Promise<void>;
57
+ cancel(): IValidEditOperation[];
58
+ makeChanges(edits: ISingleEditOperation[], obs: IEditObserver, undoStopBefore: boolean): Promise<void>;
59
+ makeProgressiveChanges(edits: ISingleEditOperation[], obs: IEditObserver, opts: ProgressingEditsOptions, undoStopBefore: boolean): Promise<void>;
60
+ private _makeChanges;
61
+ performHunkAction(hunk: HunkInformation | undefined, action: HunkAction): void;
62
+ private _findDisplayData;
63
+ renderChanges(): Promise<Position | undefined>;
64
+ getWholeRangeDecoration(): IModelDeltaDecoration[];
65
+ private _doApplyChanges;
66
+ }
67
+ export interface ProgressingEditsOptions {
68
+ duration: number;
69
+ token: CancellationToken;
70
+ }