@codingame/monaco-vscode-chat-service-override 8.0.4 → 9.0.2

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 (33) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +24 -24
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +2 -2
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +73 -22
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +47 -36
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +5 -4
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +5 -4
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +27 -21
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +10 -3
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +2 -2
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +179 -35
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +2 -9
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -4
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +14 -7
  19. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +0 -5
  20. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +37 -9
  21. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +6 -2
  22. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
  23. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +253 -67
  24. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +16 -0
  25. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +2 -2
  26. package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +59 -18
  27. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +51 -20
  28. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +28 -49
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +130 -0
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +10 -2
  32. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +2 -2
  33. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +0 -258
@@ -1,27 +1,46 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
2
3
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
4
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
4
- import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
5
7
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
6
8
 
7
- let LanguageModelToolsService = class LanguageModelToolsService {
8
- constructor(_extensionService) {
9
+ let LanguageModelToolsService = class LanguageModelToolsService extends Disposable {
10
+ constructor(_extensionService, _contextKeyService) {
11
+ super();
9
12
  this._extensionService = _extensionService;
13
+ this._contextKeyService = _contextKeyService;
10
14
  this._onDidChangeTools = ( new Emitter());
11
15
  this.onDidChangeTools = this._onDidChangeTools.event;
16
+ this._onDidChangeToolsScheduler = ( new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750));
12
17
  this._tools = ( new Map());
18
+ this._toolContextKeys = ( new Set());
19
+ this._register(this._contextKeyService.onDidChangeContext(e => {
20
+ if (e.affectsSome(this._toolContextKeys)) {
21
+ this._onDidChangeToolsScheduler.schedule();
22
+ }
23
+ }));
13
24
  }
14
25
  registerToolData(toolData) {
15
- if (( this._tools.has(toolData.name))) {
16
- throw ( new Error(`Tool "${toolData.name}" is already registered.`));
26
+ if (( this._tools.has(toolData.id))) {
27
+ throw ( new Error(`Tool "${toolData.id}" is already registered.`));
17
28
  }
18
- this._tools.set(toolData.name, { data: toolData });
19
- this._onDidChangeTools.fire({ added: toolData });
29
+ this._tools.set(toolData.id, { data: toolData });
30
+ this._onDidChangeToolsScheduler.schedule();
31
+ toolData.when?.keys().forEach(key => this._toolContextKeys.add(key));
20
32
  return toDisposable(() => {
21
- this._tools.delete(toolData.name);
22
- this._onDidChangeTools.fire({ removed: toolData.name });
33
+ this._tools.delete(toolData.id);
34
+ this._refreshAllToolContextKeys();
35
+ this._onDidChangeToolsScheduler.schedule();
23
36
  });
24
37
  }
38
+ _refreshAllToolContextKeys() {
39
+ this._toolContextKeys.clear();
40
+ for (const tool of ( this._tools.values())) {
41
+ tool.data.when?.keys().forEach(key => this._toolContextKeys.add(key));
42
+ }
43
+ }
25
44
  registerToolImplementation(name, tool) {
26
45
  const entry = this._tools.get(name);
27
46
  if (!entry) {
@@ -36,25 +55,47 @@ let LanguageModelToolsService = class LanguageModelToolsService {
36
55
  });
37
56
  }
38
57
  getTools() {
39
- return ( Iterable.map(( this._tools.values()), i => i.data));
58
+ const toolDatas = ( Iterable.map(( this._tools.values()), i => i.data));
59
+ return Iterable.filter(toolDatas, toolData => !toolData.when || this._contextKeyService.contextMatchesRules(toolData.when));
60
+ }
61
+ getTool(id) {
62
+ return this._getToolEntry(id)?.data;
63
+ }
64
+ _getToolEntry(id) {
65
+ const entry = this._tools.get(id);
66
+ if (entry && (!entry.data.when || this._contextKeyService.contextMatchesRules(entry.data.when))) {
67
+ return entry;
68
+ }
69
+ else {
70
+ return undefined;
71
+ }
72
+ }
73
+ getToolByName(name) {
74
+ for (const toolData of this.getTools()) {
75
+ if (toolData.name === name) {
76
+ return toolData;
77
+ }
78
+ }
79
+ return undefined;
40
80
  }
41
- async invokeTool(name, parameters, token) {
42
- let tool = this._tools.get(name);
81
+ async invokeTool(dto, countTokens, token) {
82
+ let tool = this._tools.get(dto.toolId);
43
83
  if (!tool) {
44
- throw ( new Error(`Tool ${name} was not contributed`));
84
+ throw ( new Error(`Tool ${dto.toolId} was not contributed`));
45
85
  }
46
86
  if (!tool.impl) {
47
- await this._extensionService.activateByEvent(`onLanguageModelTool:${name}`);
48
- tool = this._tools.get(name);
87
+ await this._extensionService.activateByEvent(`onLanguageModelTool:${dto.toolId}`);
88
+ tool = this._tools.get(dto.toolId);
49
89
  if (!tool?.impl) {
50
- throw ( new Error(`Tool ${name} does not have an implementation registered.`));
90
+ throw ( new Error(`Tool ${dto.toolId} does not have an implementation registered.`));
51
91
  }
52
92
  }
53
- return tool.impl.invoke(parameters, token);
93
+ return tool.impl.invoke(dto, countTokens, token);
54
94
  }
55
95
  };
56
96
  LanguageModelToolsService = ( __decorate([
57
- ( __param(0, IExtensionService))
97
+ ( __param(0, IExtensionService)),
98
+ ( __param(1, IContextKeyService))
58
99
  ], LanguageModelToolsService));
59
100
 
60
101
  export { LanguageModelToolsService };
@@ -3,6 +3,7 @@ import { DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
3
3
  import { joinPath } from 'vscode/vscode/vs/base/common/resources';
4
4
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
5
5
  import { localize } from 'vscode/vscode/vs/nls';
6
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
6
7
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
7
8
  import { ILanguageModelToolsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
8
9
  import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
@@ -11,48 +12,62 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
11
12
  extensionPoint: 'languageModelTools',
12
13
  activationEventsGenerator: (contributions, result) => {
13
14
  for (const contrib of contributions) {
14
- result.push(`onLanguageModelTool:${contrib.name}`);
15
+ result.push(`onLanguageModelTool:${contrib.id}`);
15
16
  }
16
17
  },
17
18
  jsonSchema: {
18
- description: ( localize(7168, 'Contributes a tool that can be invoked by a language model.')),
19
+ description: ( localize(7163, 'Contributes a tool that can be invoked by a language model.')),
19
20
  type: 'array',
20
21
  items: {
21
22
  additionalProperties: false,
22
23
  type: 'object',
23
24
  defaultSnippets: [{ body: { name: '', description: '' } }],
24
- required: ['name', 'description'],
25
+ required: ['id', 'modelDescription'],
25
26
  properties: {
26
- name: {
27
- description: ( localize(7169, "A name for this tool which must be unique across all tools.")),
28
- type: 'string'
27
+ id: {
28
+ description: ( localize(7164, "A unique id for this tool.")),
29
+ type: 'string',
30
+ pattern: '^[\\w-]+$'
29
31
  },
30
- description: {
31
- description: ( localize(7170, "A description of this tool that may be passed to a language model.")),
32
- type: 'string'
32
+ name: {
33
+ description: ( localize(
34
+ 7165,
35
+ "If {0} is enabled for this tool, the user may use '#' with this name to invoke the tool in a query. Otherwise, the name is not required. Name must not contain whitespace.",
36
+ '`canBeInvokedManually`'
37
+ )),
38
+ type: 'string',
39
+ pattern: '^[\\w-]+$'
33
40
  },
34
41
  displayName: {
35
42
  description: ( localize(
36
- 7171,
43
+ 7166,
37
44
  "A human-readable name for this tool that may be used to describe it in the UI."
38
45
  )),
39
46
  type: 'string'
40
47
  },
48
+ userDescription: {
49
+ description: ( localize(7167, "A description of this tool that may be shown to the user.")),
50
+ type: 'string'
51
+ },
52
+ modelDescription: {
53
+ description: ( localize(7168, "A description of this tool that may be passed to a language model.")),
54
+ type: 'string'
55
+ },
41
56
  parametersSchema: {
42
- description: ( localize(7172, "A JSON schema for the parameters this tool accepts.")),
57
+ description: ( localize(7169, "A JSON schema for the parameters this tool accepts.")),
43
58
  type: 'object',
44
59
  $ref: 'http://json-schema.org/draft-07/schema#'
45
60
  },
46
61
  canBeInvokedManually: {
47
62
  description: ( localize(
48
- 7173,
63
+ 7170,
49
64
  "Whether this tool can be invoked manually by the user through the chat UX."
50
65
  )),
51
66
  type: 'boolean'
52
67
  },
53
68
  icon: {
54
69
  description: ( localize(
55
- 7174,
70
+ 7171,
56
71
  "An icon that represents this tool. Either a file path, an object with file paths for dark and light themes, or a theme icon reference, like `\\$(zap)`"
57
72
  )),
58
73
  anyOf: [{
@@ -62,15 +77,22 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
62
77
  type: 'object',
63
78
  properties: {
64
79
  light: {
65
- description: ( localize(7175, 'Icon path when a light theme is used')),
80
+ description: ( localize(7172, 'Icon path when a light theme is used')),
66
81
  type: 'string'
67
82
  },
68
83
  dark: {
69
- description: ( localize(7176, 'Icon path when a dark theme is used')),
84
+ description: ( localize(7173, 'Icon path when a dark theme is used')),
70
85
  type: 'string'
71
86
  }
72
87
  }
73
88
  }]
89
+ },
90
+ when: {
91
+ markdownDescription: ( localize(
92
+ 7174,
93
+ "Condition which must be true for this tool to be enabled. Note that a tool may still be invoked by another extension even when its `when` condition is false."
94
+ )),
95
+ type: 'string'
74
96
  }
75
97
  }
76
98
  }
@@ -86,8 +108,16 @@ let LanguageModelToolsExtensionPointHandler = class LanguageModelToolsExtensionP
86
108
  languageModelToolsExtensionPoint.setHandler((extensions, delta) => {
87
109
  for (const extension of delta.added) {
88
110
  for (const rawTool of extension.value) {
89
- if (!rawTool.name || !rawTool.description) {
90
- logService.warn(`Invalid tool contribution from ${extension.description.identifier.value}: ${JSON.stringify(rawTool)}`);
111
+ if (!rawTool.id || !rawTool.modelDescription) {
112
+ logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool without name and modelDescription: ${JSON.stringify(rawTool)}`);
113
+ continue;
114
+ }
115
+ if (!rawTool.id.match(/^[\w-]+$/)) {
116
+ logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool with invalid id: ${rawTool.id}. The id must match /^[\\w-]+$/.`);
117
+ continue;
118
+ }
119
+ if (rawTool.canBeInvokedManually && !rawTool.name) {
120
+ logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool with 'canBeInvokedManually' set without a name: ${JSON.stringify(rawTool)}`);
91
121
  continue;
92
122
  }
93
123
  const rawIcon = rawTool.icon;
@@ -106,15 +136,16 @@ let LanguageModelToolsExtensionPointHandler = class LanguageModelToolsExtensionP
106
136
  }
107
137
  const tool = {
108
138
  ...rawTool,
109
- icon
139
+ icon,
140
+ when: rawTool.when ? ContextKeyExpr.deserialize(rawTool.when) : undefined,
110
141
  };
111
142
  const disposable = languageModelToolsService.registerToolData(tool);
112
- this._registrationDisposables.set(toToolKey(extension.description.identifier, rawTool.name), disposable);
143
+ this._registrationDisposables.set(toToolKey(extension.description.identifier, rawTool.id), disposable);
113
144
  }
114
145
  }
115
146
  for (const extension of delta.removed) {
116
147
  for (const tool of extension.value) {
117
- this._registrationDisposables.deleteAndDispose(toToolKey(extension.description.identifier, tool.name));
148
+ this._registrationDisposables.deleteAndDispose(toToolKey(extension.description.identifier, tool.id));
118
149
  }
119
150
  }
120
151
  });
@@ -20,7 +20,7 @@ var PhraseTextType;
20
20
  const VoiceChatInProgress = ( (new RawContextKey(
21
21
  'voiceChatInProgress',
22
22
  false,
23
- { type: 'boolean', description: ( localize(7155, "A speech-to-text session is in progress for chat.")) }
23
+ { type: 'boolean', description: ( localize(7175, "A speech-to-text session is in progress for chat.")) }
24
24
  )));
25
25
  let VoiceChatService = class VoiceChatService extends Disposable {
26
26
  static { VoiceChatService_1 = this; }
@@ -1,9 +1,8 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
1
  import { registerEditorContribution, EditorContributionInstantiation } from 'vscode/vscode/vs/editor/browser/editorExtensions';
3
- import { MenuRegistry, registerAction2, MenuId, isIMenuItem } from 'vscode/vscode/vs/platform/actions/common/actions';
2
+ import { registerAction2, MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
4
3
  import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
5
- import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, DiscardAction, RerunAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges, CopyRecordings } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
6
- import { INLINE_CHAT_ID, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_CONFIG_TXT_BTNS, MENU_INLINE_CHAT_CONTENT_STATUS, MENU_INLINE_CHAT_WIDGET_STATUS, InlineChatConfigKeys, MENU_INLINE_CHAT_EXECUTE } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
4
+ import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, DiscardAction, RerunAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
5
+ import { INLINE_CHAT_ID, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_EDITING, MENU_INLINE_CHAT_CONTENT_STATUS, MENU_INLINE_CHAT_WIDGET_STATUS } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
6
  import 'vscode/vscode/vs/platform/instantiation/common/extensions';
8
7
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
9
8
  import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
@@ -18,33 +17,49 @@ import { SubmitAction, CancelAction } from 'vscode/vscode/vs/workbench/contrib/c
18
17
  import { localize } from 'vscode/vscode/vs/nls';
19
18
  import { CONTEXT_CHAT_INPUT_HAS_TEXT } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
20
19
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
21
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
22
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
23
20
  import { InlineChatAccessibilityHelp } from './inlineChatAccessibilityHelp.js';
21
+ import { InlineChatExansionContextKey, InlineChatExpandLineAction } from './inlineChatCurrentLine.js';
24
22
 
25
23
  registerEditorContribution(INLINE_CHAT_ID, InlineChatController, EditorContributionInstantiation.Eager);
26
- const sendActionMenuItem = {
24
+ registerEditorContribution(InlineChatExansionContextKey.Id, InlineChatExansionContextKey, EditorContributionInstantiation.BeforeFirstInteraction);
25
+ registerAction2(InlineChatExpandLineAction);
26
+ const editActionMenuItem = {
27
27
  group: '0_main',
28
28
  order: 0,
29
29
  command: {
30
30
  id: SubmitAction.ID,
31
- title: ( localize(3072, "Send")),
31
+ title: ( localize(3076, "Edit Code")),
32
32
  },
33
33
  when: ( (ContextKeyExpr.and(
34
34
  CONTEXT_CHAT_INPUT_HAS_TEXT,
35
35
  (CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.toNegated()),
36
- CTX_INLINE_CHAT_CONFIG_TXT_BTNS
36
+ CTX_INLINE_CHAT_EDITING
37
37
  ))),
38
38
  };
39
- MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_CONTENT_STATUS, sendActionMenuItem);
40
- MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, sendActionMenuItem);
39
+ const generateActionMenuItem = {
40
+ group: '0_main',
41
+ order: 0,
42
+ command: {
43
+ id: SubmitAction.ID,
44
+ title: ( localize(3077, "Generate")),
45
+ },
46
+ when: ( (ContextKeyExpr.and(
47
+ CONTEXT_CHAT_INPUT_HAS_TEXT,
48
+ (CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.toNegated()),
49
+ (CTX_INLINE_CHAT_EDITING.toNegated())
50
+ ))),
51
+ };
52
+ MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_CONTENT_STATUS, editActionMenuItem);
53
+ MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_CONTENT_STATUS, generateActionMenuItem);
54
+ MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, editActionMenuItem);
55
+ MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, generateActionMenuItem);
41
56
  const cancelActionMenuItem = {
42
57
  group: '0_main',
43
58
  order: 0,
44
59
  command: {
45
60
  id: CancelAction.ID,
46
- title: ( localize(3073, "Stop Request")),
47
- shortTitle: ( localize(3074, "Stop")),
61
+ title: ( localize(3078, "Stop Request")),
62
+ shortTitle: ( localize(3079, "Stop")),
48
63
  },
49
64
  when: ( (ContextKeyExpr.and(CTX_INLINE_CHAT_REQUEST_IN_PROGRESS))),
50
65
  };
@@ -64,44 +79,8 @@ registerAction2(FocusInlineChat);
64
79
  registerAction2(ViewInChatAction);
65
80
  registerAction2(ToggleDiffForChange);
66
81
  registerAction2(AcceptChanges);
67
- registerAction2(CopyRecordings);
68
82
  const workbenchContributionsRegistry = ( (Registry.as(Extensions.Workbench)));
69
83
  workbenchContributionsRegistry.registerWorkbenchContribution(InlineChatNotebookContribution, LifecyclePhase.Restored);
70
84
  registerWorkbenchContribution2(InlineChatEnabler.Id, InlineChatEnabler, WorkbenchPhase.AfterRestored);
71
85
  AccessibleViewRegistry.register(( (new InlineChatAccessibleView())));
72
86
  AccessibleViewRegistry.register(( (new InlineChatAccessibilityHelp())));
73
- let MenuCopier = class MenuCopier {
74
- static { this.Id = 'inlineChat.menuCopier'; }
75
- constructor(configService) {
76
- const store = ( (new DisposableStore()));
77
- function updateMenu() {
78
- store.clear();
79
- for (const item of MenuRegistry.getMenuItems(MenuId.ChatExecute)) {
80
- if (configService.getValue(InlineChatConfigKeys.ExpTextButtons) && isIMenuItem(item) && (item.command.id === SubmitAction.ID || item.command.id === CancelAction.ID)) {
81
- continue;
82
- }
83
- store.add(MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_EXECUTE, item));
84
- }
85
- }
86
- updateMenu();
87
- const listener = MenuRegistry.onDidChangeMenu(e => {
88
- if (( (e.has(MenuId.ChatExecute)))) {
89
- updateMenu();
90
- }
91
- });
92
- const listener2 = configService.onDidChangeConfiguration(e => {
93
- if (e.affectsConfiguration(InlineChatConfigKeys.ExpTextButtons)) {
94
- updateMenu();
95
- }
96
- });
97
- this.dispose = () => {
98
- listener.dispose();
99
- listener2.dispose();
100
- store.dispose();
101
- };
102
- }
103
- };
104
- MenuCopier = ( (__decorate([
105
- ( (__param(0, IConfigurationService)))
106
- ], MenuCopier)));
107
- registerWorkbenchContribution2(MenuCopier.Id, MenuCopier, WorkbenchPhase.AfterRestored);
@@ -0,0 +1,130 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { DisposableStore, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { CursorChangeReason } from 'vscode/vscode/vs/editor/common/cursorEvents';
4
+ import { localize, localize2 } from 'vscode/vscode/vs/nls';
5
+ import { RawContextKey, ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
6
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
7
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
8
+ import { InlineChatController, State } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
9
+ import { CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
10
+ import { EditorAction2 } from 'vscode/vscode/vs/editor/browser/editorExtensions';
11
+ import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
12
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
13
+ import { Position } from 'vscode/vscode/vs/editor/common/core/position';
14
+ import { AbstractInlineChatAction } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
15
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
16
+
17
+ const CTX_INLINE_CHAT_EXPANSION = ( (new RawContextKey('inlineChatExpansion', false, ( localize(
18
+ 7200,
19
+ "Whether the inline chat expansion is enabled when at the end of a just-typed line"
20
+ )))));
21
+ let InlineChatExansionContextKey = class InlineChatExansionContextKey {
22
+ static { this.Id = 'editor.inlineChatExpansion'; }
23
+ constructor(editor, contextKeyService, chatAgentService) {
24
+ this._store = ( (new DisposableStore()));
25
+ this._editorListener = this._store.add(( (new MutableDisposable())));
26
+ this._ctxInlineChatExpansion = CTX_INLINE_CHAT_EXPANSION.bindTo(contextKeyService);
27
+ const update = () => {
28
+ if (editor.hasModel() && chatAgentService.getAgents().length > 0) {
29
+ this._install(editor);
30
+ }
31
+ else {
32
+ this._uninstall();
33
+ }
34
+ };
35
+ this._store.add(chatAgentService.onDidChangeAgents(update));
36
+ this._store.add(editor.onDidChangeModel(update));
37
+ update();
38
+ }
39
+ dispose() {
40
+ this._ctxInlineChatExpansion.reset();
41
+ this._store.dispose();
42
+ }
43
+ _install(editor) {
44
+ const store = ( (new DisposableStore()));
45
+ this._editorListener.value = store;
46
+ const model = editor.getModel();
47
+ const lastChangeEnds = [];
48
+ store.add(editor.onDidChangeCursorPosition(e => {
49
+ let enabled = false;
50
+ if (e.reason === CursorChangeReason.NotSet) {
51
+ const position = editor.getPosition();
52
+ const positionOffset = model.getOffsetAt(position);
53
+ const lineLength = model.getLineLength(position.lineNumber);
54
+ const firstNonWhitespace = model.getLineFirstNonWhitespaceColumn(position.lineNumber);
55
+ if (firstNonWhitespace !== 0 && position.column > lineLength && lastChangeEnds.includes(positionOffset)) {
56
+ enabled = true;
57
+ }
58
+ }
59
+ lastChangeEnds.length = 0;
60
+ this._ctxInlineChatExpansion.set(enabled);
61
+ }));
62
+ store.add(editor.onDidChangeModelContent(e => {
63
+ lastChangeEnds.length = 0;
64
+ for (const change of e.changes) {
65
+ const changeEnd = change.rangeOffset + change.text.length;
66
+ lastChangeEnds.push(changeEnd);
67
+ }
68
+ queueMicrotask(() => {
69
+ if (lastChangeEnds.length > 0) {
70
+ this._ctxInlineChatExpansion.set(false);
71
+ }
72
+ });
73
+ }));
74
+ }
75
+ _uninstall() {
76
+ this._editorListener.clear();
77
+ }
78
+ };
79
+ InlineChatExansionContextKey = ( (__decorate([
80
+ ( (__param(1, IContextKeyService))),
81
+ ( (__param(2, IChatAgentService)))
82
+ ], InlineChatExansionContextKey)));
83
+ class InlineChatExpandLineAction extends EditorAction2 {
84
+ constructor() {
85
+ super({
86
+ id: 'inlineChat.startWithCurrentLine',
87
+ category: AbstractInlineChatAction.category,
88
+ title: ( localize2(7201, "Start in Editor with Current Line")),
89
+ f1: true,
90
+ precondition: ( (ContextKeyExpr.and(
91
+ (CTX_INLINE_CHAT_VISIBLE.negate()),
92
+ CTX_INLINE_CHAT_HAS_AGENT,
93
+ EditorContextKeys.writable
94
+ ))),
95
+ });
96
+ }
97
+ async runEditorCommand(_accessor, editor) {
98
+ const ctrl = InlineChatController.get(editor);
99
+ if (!ctrl || !editor.hasModel()) {
100
+ return;
101
+ }
102
+ const model = editor.getModel();
103
+ const lineNumber = editor.getSelection().positionLineNumber;
104
+ const lineContent = model.getLineContent(lineNumber);
105
+ const startColumn = model.getLineFirstNonWhitespaceColumn(lineNumber);
106
+ const endColumn = model.getLineMaxColumn(lineNumber);
107
+ let undoEdits = [];
108
+ model.pushEditOperations(null, [EditOperation.replace(( (new Range(lineNumber, startColumn, lineNumber, endColumn))), '')], (edits) => {
109
+ undoEdits = edits;
110
+ return null;
111
+ });
112
+ let lastState;
113
+ const d = ctrl.onDidEnterState(e => lastState = e);
114
+ try {
115
+ await ctrl.run({
116
+ autoSend: true,
117
+ message: lineContent.trim(),
118
+ position: ( (new Position(lineNumber, startColumn)))
119
+ });
120
+ }
121
+ finally {
122
+ d.dispose();
123
+ }
124
+ if (lastState === State.CANCEL) {
125
+ model.pushEditOperations(null, undoEdits, () => null);
126
+ }
127
+ }
128
+ }
129
+
130
+ export { CTX_INLINE_CHAT_EXPANSION, InlineChatExansionContextKey, InlineChatExpandLineAction };
@@ -7,9 +7,12 @@ import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineC
7
7
  import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
8
8
  import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
9
9
  import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
10
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
11
+ import { NotebookTextDiffEditor } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor';
12
+ import { NotebookMultiTextDiffEditor } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor';
10
13
 
11
14
  let InlineChatNotebookContribution = class InlineChatNotebookContribution {
12
- constructor(sessionService, notebookEditorService) {
15
+ constructor(sessionService, editorService, notebookEditorService) {
13
16
  this._store = ( new DisposableStore());
14
17
  this._store.add(sessionService.registerSessionKeyComputer(Schemas.vscodeNotebookCell, {
15
18
  getComparisonKey: (editor, uri) => {
@@ -32,6 +35,10 @@ let InlineChatNotebookContribution = class InlineChatNotebookContribution {
32
35
  if (fallback) {
33
36
  return fallback;
34
37
  }
38
+ const activeEditor = editorService.activeEditorPane;
39
+ if (activeEditor && (activeEditor.getId() === NotebookTextDiffEditor.ID || activeEditor.getId() === NotebookMultiTextDiffEditor.ID)) {
40
+ return `<notebook>${editor.getId()}#${uri}`;
41
+ }
35
42
  throw illegalState('Expected notebook editor');
36
43
  }
37
44
  }));
@@ -66,7 +73,8 @@ let InlineChatNotebookContribution = class InlineChatNotebookContribution {
66
73
  };
67
74
  InlineChatNotebookContribution = ( __decorate([
68
75
  ( __param(0, IInlineChatSessionService)),
69
- ( __param(1, INotebookEditorService))
76
+ ( __param(1, IEditorService)),
77
+ ( __param(2, INotebookEditorService))
70
78
  ], InlineChatNotebookContribution));
71
79
 
72
80
  export { InlineChatNotebookContribution };
@@ -103,9 +103,9 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
103
103
  }
104
104
  progress.report({
105
105
  message: sessions.size === 1
106
- ? ( localize(3055, "Waiting for Inline Chat changes to be Accepted or Discarded..."))
106
+ ? ( localize(3058, "Waiting for Inline Chat changes to be Accepted or Discarded..."))
107
107
  : ( localize(
108
- 3056,
108
+ 3059,
109
109
  "Waiting for Inline Chat changes in {0} editors to be Accepted or Discarded...",
110
110
  sessions.size
111
111
  ))