@codingame/monaco-vscode-chat-service-override 2.2.2 → 3.1.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 (24) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +45 -53
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +11 -17
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +11 -17
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +20 -27
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +29 -41
  8. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +25 -9
  9. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +10 -10
  10. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +10 -10
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -4
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +2 -2
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -26
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +10 -1
  15. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +1 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +71 -112
  17. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +6 -1
  18. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +101 -73
  19. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
  20. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +94 -24
  21. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +4 -4
  22. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +37 -24
  23. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +4 -6
  24. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions2.js +0 -94
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Action } from 'vscode/vscode/vs/base/common/actions';
2
3
  import { CancellationToken, CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
3
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
+ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
4
5
  import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
5
6
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
6
7
  import { Disposable, DisposableMap, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
@@ -8,20 +9,21 @@ import { revive } from 'vscode/vscode/vs/base/common/marshalling';
8
9
  import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
9
10
  import { URI } from 'vscode/vscode/vs/base/common/uri';
10
11
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
11
- import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
12
+ import { CommandsRegistry, ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
12
13
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
13
14
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
14
15
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
16
+ import { Severity, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
15
17
  import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
16
18
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
17
19
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
18
20
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
19
21
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
20
22
  import { CONTEXT_PROVIDER_EXISTS } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
21
- import { ChatModel, ChatWelcomeMessageModel, ChatModelInitState } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
22
- import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
23
+ import { ChatModel, ChatWelcomeMessageModel, ChatModelInitState, getHistoryEntriesFromModel, updateRanges } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
24
+ import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, getPromptText } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
23
25
  import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
24
- import { InteractiveSessionVoteDirection, ChatAgentCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
26
+ import { InteractiveSessionVoteDirection, ChatCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
25
27
  import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands';
26
28
  import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables';
27
29
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
@@ -34,7 +36,7 @@ let ChatService = class ChatService extends Disposable {
34
36
  get transferredSessionData() {
35
37
  return this._transferredSessionData;
36
38
  }
37
- constructor(storageService, logService, extensionService, instantiationService, telemetryService, contextKeyService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService) {
39
+ constructor(storageService, logService, extensionService, instantiationService, telemetryService, contextKeyService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService, notificationService, commandService) {
38
40
  super();
39
41
  this.storageService = storageService;
40
42
  this.logService = logService;
@@ -46,17 +48,20 @@ let ChatService = class ChatService extends Disposable {
46
48
  this.chatSlashCommandService = chatSlashCommandService;
47
49
  this.chatVariablesService = chatVariablesService;
48
50
  this.chatAgentService = chatAgentService;
51
+ this.notificationService = notificationService;
52
+ this.commandService = commandService;
49
53
  this._providers = ( new Map());
50
54
  this._sessionModels = this._register(( new DisposableMap()));
51
55
  this._pendingRequests = this._register(( new DisposableMap()));
52
56
  this._onDidPerformUserAction = this._register(( new Emitter()));
53
57
  this.onDidPerformUserAction = this._onDidPerformUserAction.event;
54
- this._onDidSubmitAgent = this._register(( new Emitter()));
55
- this.onDidSubmitAgent = this._onDidSubmitAgent.event;
56
58
  this._onDidDisposeSession = this._register(( new Emitter()));
57
59
  this.onDidDisposeSession = this._onDidDisposeSession.event;
58
60
  this._onDidRegisterProvider = this._register(( new Emitter()));
59
61
  this.onDidRegisterProvider = this._onDidRegisterProvider.event;
62
+ this._onDidUnregisterProvider = this._register(( new Emitter()));
63
+ this.onDidUnregisterProvider = this._onDidUnregisterProvider.event;
64
+ this._sessionFollowupCancelTokens = this._register(( new DisposableMap()));
60
65
  this._hasProvider = CONTEXT_PROVIDER_EXISTS.bindTo(this.contextKeyService);
61
66
  const sessionData = storageService.get(serializedChatKey, 1 , '');
62
67
  if (sessionData) {
@@ -77,6 +82,11 @@ let ChatService = class ChatService extends Disposable {
77
82
  this._transferredSessionData = { sessionId: transferredChat.sessionId, inputValue: transferredData.inputValue };
78
83
  }
79
84
  this._register(storageService.onWillSaveState(() => this.saveState()));
85
+ this._register(Event.debounce(this.chatAgentService.onDidChangeAgents, () => { }, 500)(() => {
86
+ for (const model of ( this._sessionModels.values())) {
87
+ this.warmSlashCommandCache(model);
88
+ }
89
+ }));
80
90
  }
81
91
  saveState() {
82
92
  let allSessions = Array.from(( this._sessionModels.values()))
@@ -105,7 +115,7 @@ let ChatService = class ChatService extends Disposable {
105
115
  else if (action.action.kind === 'copy') {
106
116
  this.telemetryService.publicLog2('interactiveSessionCopy', {
107
117
  providerId: action.providerId,
108
- copyKind: action.action.copyKind === ChatAgentCopyKind.Action ? 'action' : 'toolbar'
118
+ copyKind: action.action.copyKind === ChatCopyKind.Action ? 'action' : 'toolbar'
109
119
  });
110
120
  }
111
121
  else if (action.action.kind === 'insert') {
@@ -115,8 +125,8 @@ let ChatService = class ChatService extends Disposable {
115
125
  });
116
126
  }
117
127
  else if (action.action.kind === 'command') {
118
- const command = CommandsRegistry.getCommand(action.action.command.commandId);
119
- const commandId = command ? action.action.command.commandId : 'INVALID';
128
+ const command = CommandsRegistry.getCommand(action.action.commandButton.command.id);
129
+ const commandId = command ? action.action.commandButton.command.id : 'INVALID';
120
130
  this.telemetryService.publicLog2('interactiveSessionCommand', {
121
131
  providerId: action.providerId,
122
132
  commandId
@@ -187,11 +197,10 @@ let ChatService = class ChatService extends Disposable {
187
197
  .filter(session => !( this._sessionModels.has(session.sessionId)))
188
198
  .filter(session => !session.isImported)
189
199
  .map(item => {
190
- const firstRequestMessage = item.requests[0]?.message;
200
+ const title = ChatModel.getDefaultTitle(item.requests);
191
201
  return {
192
202
  sessionId: item.sessionId,
193
- title: (typeof firstRequestMessage === 'string' ? firstRequestMessage :
194
- firstRequestMessage?.text) ?? '',
203
+ title
195
204
  };
196
205
  }));
197
206
  }
@@ -218,9 +227,14 @@ let ChatService = class ChatService extends Disposable {
218
227
  this.trace('reinitializeModel', `Start reinit`);
219
228
  this.initializeSession(model, CancellationToken.None);
220
229
  }
230
+ warmSlashCommandCache(model, agent) {
231
+ const agents = agent ? [agent] : this.chatAgentService.getAgents();
232
+ agents.forEach(agent => agent.provideSlashCommands(model, [], CancellationToken.None));
233
+ }
221
234
  async initializeSession(model, token) {
222
235
  try {
223
236
  this.trace('initializeSession', `Initialize session ${model.sessionId}`);
237
+ this.warmSlashCommandCache(model);
224
238
  model.startInitialize();
225
239
  await this.extensionService.activateByEvent(`onInteractiveSession:${model.providerId}`);
226
240
  const provider = this._providers.get(model.providerId);
@@ -238,8 +252,31 @@ let ChatService = class ChatService extends Disposable {
238
252
  throw new Error('Provider returned no session');
239
253
  }
240
254
  this.trace('startSession', `Provider returned session`);
241
- const welcomeMessage = model.welcomeMessage ? undefined : (await provider.provideWelcomeMessage?.(token)) ?? undefined;
242
- const welcomeModel = welcomeMessage && ( new ChatWelcomeMessageModel(model, ( welcomeMessage.map(item => typeof item === 'string' ? ( new MarkdownString(item)) : item)), (await provider.provideSampleQuestions?.(token)) ?? []));
255
+ const defaultAgent = this.chatAgentService.getDefaultAgent();
256
+ if (!defaultAgent) {
257
+ this.notificationService.notify({
258
+ severity: Severity.Error,
259
+ message: ( localizeWithPath(
260
+ 'vs/workbench/contrib/chat/common/chatServiceImpl',
261
+ 'chatFailErrorMessage',
262
+ "Chat failed to load. Please ensure that the GitHub Copilot Chat extension is up to date."
263
+ )),
264
+ actions: {
265
+ primary: [
266
+ ( new Action('showExtension', ( localizeWithPath(
267
+ 'vs/workbench/contrib/chat/common/chatServiceImpl',
268
+ 'action.showExtension',
269
+ "Show Extension"
270
+ )), undefined, true, () => {
271
+ return this.commandService.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['GitHub.copilot-chat']);
272
+ }))
273
+ ]
274
+ }
275
+ });
276
+ throw new Error('No default agent');
277
+ }
278
+ const welcomeMessage = model.welcomeMessage ? undefined : (await defaultAgent.provideWelcomeMessage?.(token)) ?? undefined;
279
+ const welcomeModel = welcomeMessage && ( new ChatWelcomeMessageModel(model, ( welcomeMessage.map(item => typeof item === 'string' ? ( new MarkdownString(item)) : item)), (await defaultAgent.provideSampleQuestions?.(token)) ?? []));
243
280
  model.initialize(session, welcomeModel);
244
281
  }
245
282
  catch (err) {
@@ -292,10 +329,23 @@ let ChatService = class ChatService extends Disposable {
292
329
  this.trace('sendRequest', `Session ${sessionId} already has a pending request`);
293
330
  return;
294
331
  }
295
- return { responseCompletePromise: this._sendRequestAsync(model, sessionId, provider, request) };
332
+ const parsedRequest = this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(sessionId, request);
333
+ const agent = parsedRequest.parts.find((r) => r instanceof ChatRequestAgentPart)?.agent ?? this.chatAgentService.getDefaultAgent();
334
+ const agentSlashCommandPart = parsedRequest.parts.find((r) => r instanceof ChatRequestAgentSubcommandPart);
335
+ return {
336
+ responseCompletePromise: this._sendRequestAsync(model, sessionId, provider, parsedRequest),
337
+ agent,
338
+ slashCommand: agentSlashCommandPart?.command,
339
+ };
296
340
  }
297
- async _sendRequestAsync(model, sessionId, provider, message) {
298
- const parsedRequest = await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(sessionId, message);
341
+ refreshFollowupsCancellationToken(sessionId) {
342
+ this._sessionFollowupCancelTokens.get(sessionId)?.cancel();
343
+ const newTokenSource = ( new CancellationTokenSource());
344
+ this._sessionFollowupCancelTokens.set(sessionId, newTokenSource);
345
+ return newTokenSource.token;
346
+ }
347
+ async _sendRequestAsync(model, sessionId, provider, parsedRequest) {
348
+ const followupsCancelToken = this.refreshFollowupsCancellationToken(sessionId);
299
349
  let request;
300
350
  const agentPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestAgentPart);
301
351
  const agentSlashCommandPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestAgentSubcommandPart);
@@ -334,50 +384,31 @@ let ChatService = class ChatService extends Disposable {
334
384
  model.cancelRequest(request);
335
385
  });
336
386
  try {
337
- if (agentPart && agentSlashCommandPart?.command) {
338
- this._onDidSubmitAgent.fire({ agent: agentPart.agent, slashCommand: agentSlashCommandPart.command, sessionId: model.sessionId });
339
- }
340
- let rawResponse;
387
+ let rawResult;
341
388
  let agentOrCommandFollowups = undefined;
342
389
  const defaultAgent = this.chatAgentService.getDefaultAgent();
343
390
  if (agentPart || (defaultAgent && !commandPart)) {
344
391
  const agent = (agentPart?.agent ?? defaultAgent);
345
- const history = [];
346
- for (const request of model.getRequests()) {
347
- if (!request.response) {
348
- continue;
349
- }
350
- const historyRequest = {
351
- sessionId,
352
- requestId: request.id,
353
- agentId: request.response.agent?.id ?? '',
354
- message: request.variableData.message,
355
- variables: request.variableData.variables,
356
- command: request.response.slashCommand?.name
357
- };
358
- history.push({ request: historyRequest, response: request.response.response.value, result: { errorDetails: request.response.errorDetails } });
359
- }
360
- const variableData = await this.chatVariablesService.resolveVariables(parsedRequest, model, token);
361
- request = model.addRequest(parsedRequest, variableData, agent, agentSlashCommandPart?.command);
392
+ const history = getHistoryEntriesFromModel(model);
393
+ const initVariableData = { variables: [] };
394
+ request = model.addRequest(parsedRequest, initVariableData, agent, agentSlashCommandPart?.command);
395
+ const variableData = await this.chatVariablesService.resolveVariables(parsedRequest, model, progressCallback, token);
396
+ request.variableData = variableData;
397
+ const promptTextResult = getPromptText(request.message);
362
398
  const requestProps = {
363
399
  sessionId,
364
400
  requestId: request.id,
365
401
  agentId: agent.id,
366
- message: variableData.message,
367
- variables: variableData.variables,
368
- command: agentSlashCommandPart?.command.name ?? '',
402
+ message: promptTextResult.message,
403
+ command: agentSlashCommandPart?.command.name,
404
+ variables: updateRanges(variableData, promptTextResult.diff)
369
405
  };
370
406
  const agentResult = await this.chatAgentService.invokeAgent(agent.id, requestProps, progressCallback, history, token);
371
- rawResponse = {
372
- session: model.session,
373
- errorDetails: agentResult.errorDetails,
374
- timings: agentResult.timings
375
- };
376
- agentOrCommandFollowups = agentResult?.followUp ? Promise.resolve(agentResult.followUp) :
377
- this.chatAgentService.getFollowups(agent.id, sessionId, CancellationToken.None);
407
+ rawResult = agentResult;
408
+ agentOrCommandFollowups = this.chatAgentService.getFollowups(agent.id, requestProps, agentResult, followupsCancelToken);
378
409
  }
379
410
  else if (commandPart && this.chatSlashCommandService.hasCommand(commandPart.slashCommand.command)) {
380
- request = model.addRequest(parsedRequest, { message, variables: {} });
411
+ request = model.addRequest(parsedRequest, { variables: [] });
381
412
  const history = [];
382
413
  for (const request of model.getRequests()) {
383
414
  if (!request.response) {
@@ -386,11 +417,12 @@ let ChatService = class ChatService extends Disposable {
386
417
  history.push({ role: 1 , content: request.message.text });
387
418
  history.push({ role: 2 , content: request.response.response.asString() });
388
419
  }
420
+ const message = parsedRequest.text;
389
421
  const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( new Progress(p => {
390
422
  progressCallback(p);
391
423
  })), history, token);
392
424
  agentOrCommandFollowups = Promise.resolve(commandResult?.followUp);
393
- rawResponse = { session: model.session };
425
+ rawResult = {};
394
426
  }
395
427
  else {
396
428
  throw new Error(`Cannot handle request`);
@@ -399,39 +431,36 @@ let ChatService = class ChatService extends Disposable {
399
431
  return;
400
432
  }
401
433
  else {
402
- if (!rawResponse) {
434
+ if (!rawResult) {
403
435
  this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
404
- rawResponse = { session: model.session, errorDetails: { message: ( localizeWithPath(
436
+ rawResult = { errorDetails: { message: ( localizeWithPath(
405
437
  'vs/workbench/contrib/chat/common/chatServiceImpl',
406
438
  'emptyResponse',
407
439
  "Provider returned null response"
408
440
  )) } };
409
441
  }
410
- const result = rawResponse.errorDetails?.responseIsFiltered ? 'filtered' :
411
- rawResponse.errorDetails && gotProgress ? 'errorWithOutput' :
412
- rawResponse.errorDetails ? 'error' :
442
+ const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
443
+ rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
444
+ rawResult.errorDetails ? 'error' :
413
445
  'success';
414
446
  this.telemetryService.publicLog2('interactiveSessionProviderInvoked', {
415
447
  providerId: provider.id,
416
- timeToFirstProgress: rawResponse.timings?.firstProgress,
417
- totalTime: rawResponse.timings?.totalElapsed,
448
+ timeToFirstProgress: rawResult.timings?.firstProgress,
449
+ totalTime: rawResult.timings?.totalElapsed,
418
450
  result,
419
451
  requestType,
420
452
  agent: agentPart?.agent.id ?? '',
421
453
  slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
422
454
  chatSessionId: model.sessionId
423
455
  });
424
- model.setResponse(request, rawResponse);
456
+ model.setResponse(request, rawResult);
425
457
  this.trace('sendRequest', `Provider returned response for session ${model.sessionId}`);
458
+ model.completeResponse(request);
426
459
  if (agentOrCommandFollowups) {
427
460
  agentOrCommandFollowups.then(followups => {
428
461
  model.setFollowups(request, followups);
429
- model.completeResponse(request, rawResponse?.errorDetails);
430
462
  });
431
463
  }
432
- else {
433
- model.completeResponse(request, rawResponse?.errorDetails);
434
- }
435
464
  }
436
465
  }
437
466
  finally {
@@ -472,9 +501,9 @@ let ChatService = class ChatService extends Disposable {
472
501
  }
473
502
  await model.waitForInitialization();
474
503
  const parsedRequest = typeof message === 'string' ?
475
- await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(sessionId, message) :
504
+ this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(sessionId, message) :
476
505
  message;
477
- const request = model.addRequest(parsedRequest, variableData || { message: parsedRequest.text, variables: {} });
506
+ const request = model.addRequest(parsedRequest, variableData || { variables: [] });
478
507
  if (typeof response.message === 'string') {
479
508
  model.acceptResponseProgress(request, { content: response.message, kind: 'content' });
480
509
  }
@@ -483,14 +512,11 @@ let ChatService = class ChatService extends Disposable {
483
512
  model.acceptResponseProgress(request, part, true);
484
513
  }
485
514
  }
486
- model.setResponse(request, {
487
- session: model.session,
488
- errorDetails: response.errorDetails,
489
- });
515
+ model.setResponse(request, response.result || {});
490
516
  if (response.followups !== undefined) {
491
517
  model.setFollowups(request, response.followups);
492
518
  }
493
- model.completeResponse(request, response.errorDetails);
519
+ model.completeResponse(request);
494
520
  }
495
521
  cancelCurrentRequestForSession(sessionId) {
496
522
  this.trace('cancelCurrentRequestForSession', `sessionId: ${sessionId}`);
@@ -528,6 +554,7 @@ let ChatService = class ChatService extends Disposable {
528
554
  Array.from(( this._sessionModels.values()))
529
555
  .filter(model => model.providerId === provider.id)
530
556
  .forEach(model => model.deinitialize());
557
+ this._onDidUnregisterProvider.fire({ providerId: provider.id });
531
558
  });
532
559
  }
533
560
  hasSessions(providerId) {
@@ -537,7 +564,6 @@ let ChatService = class ChatService extends Disposable {
537
564
  return ( Array.from(( this._providers.values())).map(provider => {
538
565
  return {
539
566
  id: provider.id,
540
- displayName: provider.displayName
541
567
  };
542
568
  }));
543
569
  }
@@ -567,7 +593,9 @@ ChatService = ( __decorate([
567
593
  ( __param(6, IWorkspaceContextService)),
568
594
  ( __param(7, IChatSlashCommandService)),
569
595
  ( __param(8, IChatVariablesService)),
570
- ( __param(9, IChatAgentService))
596
+ ( __param(9, IChatAgentService)),
597
+ ( __param(10, INotificationService)),
598
+ ( __param(11, ICommandService))
571
599
  ], ChatService));
572
600
 
573
601
  export { ChatService };
@@ -1,18 +1,16 @@
1
1
  import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
2
2
  import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
3
3
  import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
4
- import { InlineAccessibilityHelpContribution, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, MakeRequestAction, StopRequestAction, ReRunRequestAction, DiscardHunkAction, DiscardAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, CancelSessionAction, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, PreviousFromHistory, NextFromHistory, ViewInChatAction, ExpandMessageAction, ContractMessageAction, ToggleDiffForChange, FeebackHelpfulCommand, FeebackUnhelpfulCommand, ReportIssueForBugCommand, AcceptChanges, CopyRecordings } from './inlineChatActions.js';
4
+ import { InlineAccessibilityHelpContribution, StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, MakeRequestAction, StopRequestAction, ReRunRequestAction, DiscardHunkAction, DiscardAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, CancelSessionAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, PreviousFromHistory, NextFromHistory, ViewInChatAction, ExpandMessageAction, ContractMessageAction, ToggleDiffForChange, FeebackHelpfulCommand, FeebackUnhelpfulCommand, ReportIssueForBugCommand, AcceptChanges, CopyRecordings } from './inlineChatActions.js';
5
5
  import { INLINE_CHAT_ID, INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
6
6
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
7
7
  import { InlineChatNotebookContribution } from './inlineChatNotebook.js';
8
8
  import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
9
9
  import { InlineChatAccessibleViewContribution } from './inlineChatAccessibleView.js';
10
- import { StartSessionAction, HoldToSpeak } from './inlineChatActions2.js';
11
10
 
12
- registerAction2(StartSessionAction);
13
- registerAction2(HoldToSpeak);
14
11
  registerEditorContribution(INLINE_CHAT_ID, InlineChatController, 0 );
15
12
  registerEditorContribution(INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID, InlineAccessibilityHelpContribution, 3 );
13
+ registerAction2(StartSessionAction);
16
14
  registerAction2(CloseAction);
17
15
  registerAction2(ConfigureInlineChatAction);
18
16
  registerAction2(UnstashSessionAction);
@@ -24,6 +22,8 @@ registerAction2(DiscardAction);
24
22
  registerAction2(DiscardToClipboardAction);
25
23
  registerAction2(DiscardUndoToNewFileAction);
26
24
  registerAction2(CancelSessionAction);
25
+ registerAction2(MoveToNextHunk);
26
+ registerAction2(MoveToPreviousHunk);
27
27
  registerAction2(ArrowOutUpAction);
28
28
  registerAction2(ArrowOutDownAction);
29
29
  registerAction2(FocusInlineChat);
@@ -1,10 +1,11 @@
1
1
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
2
+ import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
2
3
  import { EditorAction2 } from 'vscode/vscode/vs/editor/browser/editorExtensions';
3
4
  import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/embeddedCodeEditorWidget';
4
5
  import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
5
- import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
6
+ import { InlineChatController, InlineChatRunOptions } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
6
7
  import { ACTION_ACCEPT_CHANGES, CTX_INLINE_CHAT_HAS_PROVIDER, MENU_INLINE_CHAT_WIDGET_STATUS, MENU_INLINE_CHAT_WIDGET_DISCARD, CTX_INLINE_CHAT_EDIT_MODE, CTX_INLINE_CHAT_RESPONSE_TYPES, CTX_INLINE_CHAT_HAS_STASHED_SESSION, CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EMPTY, CTX_INLINE_CHAT_FOCUSED, MENU_INLINE_CHAT_INPUT, CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST, ACTION_REGENERATE_RESPONSE, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, CTX_INLINE_CHAT_INNER_CURSOR_START, CTX_INLINE_CHAT_INNER_CURSOR_END, CTX_INLINE_CHAT_USER_DID_EDIT, CTX_INLINE_CHAT_DID_EDIT, CTX_INLINE_CHAT_CHANGE_HAS_DIFF, CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF, MENU_INLINE_CHAT_WIDGET_FEEDBACK, CTX_INLINE_CHAT_LAST_FEEDBACK, CTX_INLINE_CHAT_SUPPORT_ISSUE_REPORTING, MENU_INLINE_CHAT_WIDGET, CTX_INLINE_CHAT_DOCUMENT_CHANGED, ACTION_VIEW_IN_CHAT, MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE, CTX_INLINE_CHAT_MESSAGE_CROP_STATE, CTX_INLINE_CHAT_RESPONSE_FOCUSED } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
- import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
8
+ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
8
9
  import { MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
9
10
  import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
10
11
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
@@ -23,7 +24,7 @@ import { IPreferencesService } from 'vscode/vscode/vs/workbench/services/prefere
23
24
 
24
25
  CommandsRegistry.registerCommandAlias('interactiveEditor.start', 'inlineChat.start');
25
26
  CommandsRegistry.registerCommandAlias('interactive.acceptChanges', ACTION_ACCEPT_CHANGES);
26
- const LOCALIZED_START_INLINE_CHAT_STRING = ( localizeWithPath(
27
+ const LOCALIZED_START_INLINE_CHAT_STRING = ( localize2WithPath(
27
28
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
28
29
  'run',
29
30
  'Start Inline Chat'
@@ -33,15 +34,45 @@ const START_INLINE_CHAT = registerIcon('start-inline-chat', Codicon.sparkle, ( l
33
34
  'startInlineChat',
34
35
  'Icon which spawns the inline chat from the editor toolbar.'
35
36
  )));
37
+ class StartSessionAction extends EditorAction2 {
38
+ constructor() {
39
+ super({
40
+ id: 'inlineChat.start',
41
+ title: LOCALIZED_START_INLINE_CHAT_STRING,
42
+ category: AbstractInlineChatAction.category,
43
+ f1: true,
44
+ precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_PROVIDER, EditorContextKeys.writable)),
45
+ keybinding: {
46
+ when: EditorContextKeys.focus,
47
+ weight: 200 ,
48
+ primary: 2048 | 39 ,
49
+ secondary: [KeyChord(2048 | 41 , 39 )],
50
+ },
51
+ icon: START_INLINE_CHAT
52
+ });
53
+ }
54
+ runEditorCommand(accessor, editor, ..._args) {
55
+ const ctrl = InlineChatController.get(editor);
56
+ if (!ctrl) {
57
+ return;
58
+ }
59
+ let options;
60
+ const arg = _args[0];
61
+ if (arg && InlineChatRunOptions.isInteractiveEditorOptions(arg)) {
62
+ options = arg;
63
+ }
64
+ InlineChatController.get(editor)?.run({ ...options });
65
+ }
66
+ }
36
67
  class UnstashSessionAction extends EditorAction2 {
37
68
  constructor() {
38
69
  super({
39
70
  id: 'inlineChat.unstash',
40
- title: { value: ( localizeWithPath(
71
+ title: ( localize2WithPath(
41
72
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
42
73
  'unstash',
43
- 'Resume Last Dismissed Inline Chat'
44
- )), original: 'Resume Last Dismissed Inline Chat' },
74
+ "Resume Last Dismissed Inline Chat"
75
+ )),
45
76
  category: AbstractInlineChatAction.category,
46
77
  precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_STASHED_SESSION, EditorContextKeys.writable)),
47
78
  keybinding: {
@@ -64,11 +95,11 @@ class UnstashSessionAction extends EditorAction2 {
64
95
  }
65
96
  }
66
97
  class AbstractInlineChatAction extends EditorAction2 {
67
- static { this.category = { value: ( localizeWithPath(
98
+ static { this.category = ( localize2WithPath(
68
99
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
69
100
  'cat',
70
- 'Inline Chat'
71
- )), original: 'Inline Chat' }; }
101
+ "Inline Chat"
102
+ )); }
72
103
  constructor(desc) {
73
104
  super({
74
105
  ...desc,
@@ -225,11 +256,11 @@ class FocusInlineChat extends EditorAction2 {
225
256
  constructor() {
226
257
  super({
227
258
  id: 'inlineChat.focus',
228
- title: { value: ( localizeWithPath(
259
+ title: ( localize2WithPath(
229
260
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
230
261
  'focus',
231
- 'Focus Input'
232
- )), original: 'Focus Input' },
262
+ "Focus Input"
263
+ )),
233
264
  f1: true,
234
265
  category: AbstractInlineChatAction.category,
235
266
  precondition: ( ContextKeyExpr.and(EditorContextKeys.editorTextFocus, CTX_INLINE_CHAT_VISIBLE, ( CTX_INLINE_CHAT_FOCUSED.negate()), ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()))),
@@ -508,11 +539,11 @@ class AcceptChanges extends AbstractInlineChatAction {
508
539
  constructor() {
509
540
  super({
510
541
  id: ACTION_ACCEPT_CHANGES,
511
- title: { value: ( localizeWithPath(
542
+ title: ( localize2WithPath(
512
543
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
513
544
  'apply1',
514
- 'Accept Changes'
515
- )), original: 'Accept Changes' },
545
+ "Accept Changes"
546
+ )),
516
547
  shortTitle: ( localizeWithPath(
517
548
  'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
518
549
  'apply2',
@@ -616,19 +647,58 @@ class ConfigureInlineChatAction extends AbstractInlineChatAction {
616
647
  accessor.get(IPreferencesService).openSettings({ query: 'inlineChat' });
617
648
  }
618
649
  }
650
+ class MoveToNextHunk extends AbstractInlineChatAction {
651
+ constructor() {
652
+ super({
653
+ id: 'inlineChat.moveToNextHunk',
654
+ title: ( localize2WithPath(
655
+ 'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
656
+ 'moveToNextHunk',
657
+ 'Move to Next Change'
658
+ )),
659
+ precondition: CTX_INLINE_CHAT_VISIBLE,
660
+ f1: true,
661
+ keybinding: {
662
+ weight: 200 ,
663
+ primary: 65
664
+ }
665
+ });
666
+ }
667
+ runInlineChatCommand(accessor, ctrl, editor, ...args) {
668
+ ctrl.moveHunk(true);
669
+ }
670
+ }
671
+ class MoveToPreviousHunk extends AbstractInlineChatAction {
672
+ constructor() {
673
+ super({
674
+ id: 'inlineChat.moveToPreviousHunk',
675
+ title: ( localize2WithPath(
676
+ 'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
677
+ 'moveToPreviousHunk',
678
+ 'Move to Previous Change'
679
+ )),
680
+ f1: true,
681
+ precondition: CTX_INLINE_CHAT_VISIBLE,
682
+ keybinding: {
683
+ weight: 200 ,
684
+ primary: 1024 | 65
685
+ }
686
+ });
687
+ }
688
+ runInlineChatCommand(accessor, ctrl, editor, ...args) {
689
+ ctrl.moveHunk(false);
690
+ }
691
+ }
619
692
  class CopyRecordings extends AbstractInlineChatAction {
620
693
  constructor() {
621
694
  super({
622
695
  id: 'inlineChat.copyRecordings',
623
696
  f1: true,
624
- title: {
625
- value: ( localizeWithPath(
626
- 'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
627
- 'copyRecordings',
628
- '(Developer) Write Exchange to Clipboard'
629
- )),
630
- original: '(Developer) Write Exchange to Clipboard'
631
- }
697
+ title: ( localize2WithPath(
698
+ 'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
699
+ 'copyRecordings',
700
+ "(Developer) Write Exchange to Clipboard"
701
+ ))
632
702
  });
633
703
  }
634
704
  async runInlineChatCommand(accessor) {
@@ -741,4 +811,4 @@ class InlineAccessibilityHelpContribution extends Disposable {
741
811
  }
742
812
  }
743
813
 
744
- export { AbstractInlineChatAction, AcceptChanges, ArrowOutDownAction, ArrowOutUpAction, CancelSessionAction, CloseAction, ConfigureInlineChatAction, ContractMessageAction, CopyRecordings, DiscardAction, DiscardHunkAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, ExpandMessageAction, FeebackHelpfulCommand, FeebackUnhelpfulCommand, FocusInlineChat, InlineAccessibilityHelpContribution, LOCALIZED_START_INLINE_CHAT_STRING, MakeRequestAction, NextFromHistory, PreviousFromHistory, ReRunRequestAction, ReportIssueForBugCommand, START_INLINE_CHAT, StopRequestAction, ToggleDiffForChange, UnstashSessionAction, ViewInChatAction };
814
+ export { AbstractInlineChatAction, AcceptChanges, ArrowOutDownAction, ArrowOutUpAction, CancelSessionAction, CloseAction, ConfigureInlineChatAction, ContractMessageAction, CopyRecordings, DiscardAction, DiscardHunkAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, ExpandMessageAction, FeebackHelpfulCommand, FeebackUnhelpfulCommand, FocusInlineChat, InlineAccessibilityHelpContribution, LOCALIZED_START_INLINE_CHAT_STRING, MakeRequestAction, MoveToNextHunk, MoveToPreviousHunk, NextFromHistory, PreviousFromHistory, ReRunRequestAction, ReportIssueForBugCommand, START_INLINE_CHAT, StartSessionAction, StopRequestAction, ToggleDiffForChange, UnstashSessionAction, ViewInChatAction };
@@ -71,13 +71,13 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
71
71
  _installSaveParticpant() {
72
72
  const queue = ( new Queue());
73
73
  const d1 = this._textFileService.files.addSaveParticipant({
74
- participate: (model, context, progress, token) => {
75
- return queue.queue(() => this._participate(model.textEditorModel?.uri, context.reason, progress, token));
74
+ participate: (model, ctx, progress, token) => {
75
+ return queue.queue(() => this._participate(ctx.savedFrom ?? model.textEditorModel?.uri, ctx.reason, progress, token));
76
76
  }
77
77
  });
78
78
  const d2 = this._workingCopyFileService.addSaveParticipant({
79
- participate: (workingCopy, env, progress, token) => {
80
- return queue.queue(() => this._participate(workingCopy.resource, env.reason, progress, token));
79
+ participate: (workingCopy, ctx, progress, token) => {
80
+ return queue.queue(() => this._participate(ctx.savedFrom ?? workingCopy.resource, ctx.reason, progress, token));
81
81
  }
82
82
  });
83
83
  this._saveParticipant.value = combinedDisposable(d1, d2, queue);