@theia/ai-chat-ui 1.60.2 → 1.61.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 (79) hide show
  1. package/lib/browser/ai-chat-ui-contribution.d.ts +5 -1
  2. package/lib/browser/ai-chat-ui-contribution.d.ts.map +1 -1
  3. package/lib/browser/ai-chat-ui-contribution.js +102 -4
  4. package/lib/browser/ai-chat-ui-contribution.js.map +1 -1
  5. package/lib/browser/ai-chat-ui-frontend-module.d.ts.map +1 -1
  6. package/lib/browser/ai-chat-ui-frontend-module.js +30 -1
  7. package/lib/browser/ai-chat-ui-frontend-module.js.map +1 -1
  8. package/lib/browser/chat-input-agent-suggestions.d.ts +11 -0
  9. package/lib/browser/chat-input-agent-suggestions.d.ts.map +1 -0
  10. package/lib/browser/chat-input-agent-suggestions.js +76 -0
  11. package/lib/browser/chat-input-agent-suggestions.js.map +1 -0
  12. package/lib/browser/chat-input-widget.d.ts +17 -6
  13. package/lib/browser/chat-input-widget.d.ts.map +1 -1
  14. package/lib/browser/chat-input-widget.js +72 -22
  15. package/lib/browser/chat-input-widget.js.map +1 -1
  16. package/lib/browser/chat-node-toolbar-action-contribution.d.ts +8 -0
  17. package/lib/browser/chat-node-toolbar-action-contribution.d.ts.map +1 -1
  18. package/lib/browser/chat-node-toolbar-action-contribution.js +55 -1
  19. package/lib/browser/chat-node-toolbar-action-contribution.js.map +1 -1
  20. package/lib/browser/chat-progress-message.d.ts +7 -0
  21. package/lib/browser/chat-progress-message.d.ts.map +1 -0
  22. package/lib/browser/chat-progress-message.js +33 -0
  23. package/lib/browser/chat-progress-message.js.map +1 -0
  24. package/lib/browser/chat-response-renderer/code-part-renderer.js +1 -1
  25. package/lib/browser/chat-response-renderer/code-part-renderer.js.map +1 -1
  26. package/lib/browser/chat-response-renderer/index.d.ts +1 -0
  27. package/lib/browser/chat-response-renderer/index.d.ts.map +1 -1
  28. package/lib/browser/chat-response-renderer/index.js +1 -0
  29. package/lib/browser/chat-response-renderer/index.js.map +1 -1
  30. package/lib/browser/chat-response-renderer/markdown-part-renderer.d.ts +7 -1
  31. package/lib/browser/chat-response-renderer/markdown-part-renderer.d.ts.map +1 -1
  32. package/lib/browser/chat-response-renderer/markdown-part-renderer.js +14 -3
  33. package/lib/browser/chat-response-renderer/markdown-part-renderer.js.map +1 -1
  34. package/lib/browser/chat-response-renderer/progress-part-renderer.d.ts +9 -0
  35. package/lib/browser/chat-response-renderer/progress-part-renderer.d.ts.map +1 -0
  36. package/lib/browser/chat-response-renderer/progress-part-renderer.js +39 -0
  37. package/lib/browser/chat-response-renderer/progress-part-renderer.js.map +1 -0
  38. package/lib/browser/chat-tree-view/chat-view-tree-input-widget.d.ts +33 -0
  39. package/lib/browser/chat-tree-view/chat-view-tree-input-widget.d.ts.map +1 -0
  40. package/lib/browser/chat-tree-view/chat-view-tree-input-widget.js +79 -0
  41. package/lib/browser/chat-tree-view/chat-view-tree-input-widget.js.map +1 -0
  42. package/lib/browser/chat-tree-view/chat-view-tree-widget.d.ts +20 -4
  43. package/lib/browser/chat-tree-view/chat-view-tree-widget.d.ts.map +1 -1
  44. package/lib/browser/chat-tree-view/chat-view-tree-widget.js +184 -48
  45. package/lib/browser/chat-tree-view/chat-view-tree-widget.js.map +1 -1
  46. package/lib/browser/chat-view-commands.d.ts +3 -0
  47. package/lib/browser/chat-view-commands.d.ts.map +1 -1
  48. package/lib/browser/chat-view-commands.js +15 -0
  49. package/lib/browser/chat-view-commands.js.map +1 -1
  50. package/lib/browser/chat-view-contribution.d.ts +1 -0
  51. package/lib/browser/chat-view-contribution.d.ts.map +1 -1
  52. package/lib/browser/chat-view-contribution.js +16 -14
  53. package/lib/browser/chat-view-contribution.js.map +1 -1
  54. package/lib/browser/chat-view-language-contribution.d.ts +3 -3
  55. package/lib/browser/chat-view-language-contribution.d.ts.map +1 -1
  56. package/lib/browser/chat-view-language-contribution.js +9 -22
  57. package/lib/browser/chat-view-language-contribution.js.map +1 -1
  58. package/lib/browser/chat-view-widget.d.ts +6 -2
  59. package/lib/browser/chat-view-widget.d.ts.map +1 -1
  60. package/lib/browser/chat-view-widget.js +36 -19
  61. package/lib/browser/chat-view-widget.js.map +1 -1
  62. package/package.json +12 -12
  63. package/src/browser/ai-chat-ui-contribution.ts +93 -6
  64. package/src/browser/ai-chat-ui-frontend-module.ts +33 -3
  65. package/src/browser/chat-input-agent-suggestions.tsx +85 -0
  66. package/src/browser/chat-input-widget.tsx +122 -32
  67. package/src/browser/chat-node-toolbar-action-contribution.ts +40 -1
  68. package/src/browser/chat-progress-message.tsx +40 -0
  69. package/src/browser/chat-response-renderer/code-part-renderer.tsx +3 -3
  70. package/src/browser/chat-response-renderer/index.ts +1 -0
  71. package/src/browser/chat-response-renderer/markdown-part-renderer.tsx +19 -2
  72. package/src/browser/chat-response-renderer/progress-part-renderer.tsx +40 -0
  73. package/src/browser/chat-tree-view/chat-view-tree-input-widget.tsx +89 -0
  74. package/src/browser/chat-tree-view/chat-view-tree-widget.tsx +200 -37
  75. package/src/browser/chat-view-commands.ts +18 -0
  76. package/src/browser/chat-view-contribution.ts +20 -16
  77. package/src/browser/chat-view-language-contribution.ts +10 -24
  78. package/src/browser/chat-view-widget.tsx +18 -5
  79. package/src/browser/style/index.css +58 -4
@@ -14,15 +14,15 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
  import { ChatAgentService } from '@theia/ai-chat';
17
- import { AIContextVariable, AIVariableService } from '@theia/ai-core/lib/common';
17
+ import { AIVariableService } from '@theia/ai-core/lib/common';
18
18
  import { PromptText } from '@theia/ai-core/lib/common/prompt-text';
19
19
  import { ToolInvocationRegistry } from '@theia/ai-core/lib/common/tool-invocation-registry';
20
20
  import { MaybePromise, nls } from '@theia/core';
21
- import { ApplicationShell, FrontendApplication, FrontendApplicationContribution } from '@theia/core/lib/browser';
21
+ import { FrontendApplication, FrontendApplicationContribution } from '@theia/core/lib/browser';
22
22
  import { inject, injectable } from '@theia/core/shared/inversify';
23
23
  import * as monaco from '@theia/monaco-editor-core';
24
24
  import { ProviderResult } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
25
- import { ChatViewWidget } from './chat-view-widget';
25
+ import { AIChatFrontendContribution, VARIABLE_ADD_CONTEXT_COMMAND } from '@theia/ai-chat/lib/browser/ai-chat-frontend-contribution';
26
26
 
27
27
  export const CHAT_VIEW_LANGUAGE_ID = 'theia-ai-chat-view-language';
28
28
  export const SETTINGS_LANGUAGE_ID = 'theia-ai-chat-settings-language';
@@ -30,7 +30,6 @@ export const CHAT_VIEW_LANGUAGE_EXTENSION = 'aichatviewlanguage';
30
30
 
31
31
  const VARIABLE_RESOLUTION_CONTEXT = { context: 'chat-input-autocomplete' };
32
32
  const VARIABLE_ARGUMENT_PICKER_COMMAND = 'trigger-variable-argument-picker';
33
- const VARIABLE_ADD_CONTEXT_COMMAND = 'add-context-variable';
34
33
 
35
34
  interface CompletionSource<T> {
36
35
  triggerCharacter: string;
@@ -54,8 +53,8 @@ export class ChatViewLanguageContribution implements FrontendApplicationContribu
54
53
  @inject(ToolInvocationRegistry)
55
54
  protected readonly toolInvocationRegistry: ToolInvocationRegistry;
56
55
 
57
- @inject(ApplicationShell)
58
- protected readonly shell: ApplicationShell;
56
+ @inject(AIChatFrontendContribution)
57
+ protected readonly chatFrontendContribution: AIChatFrontendContribution;
59
58
 
60
59
  onStart(_app: FrontendApplication): MaybePromise<void> {
61
60
  monaco.languages.register({ id: CHAT_VIEW_LANGUAGE_ID, extensions: [CHAT_VIEW_LANGUAGE_EXTENSION] });
@@ -64,7 +63,6 @@ export class ChatViewLanguageContribution implements FrontendApplicationContribu
64
63
  this.registerCompletionProviders();
65
64
 
66
65
  monaco.editor.registerCommand(VARIABLE_ARGUMENT_PICKER_COMMAND, this.triggerVariableArgumentPicker.bind(this));
67
- monaco.editor.registerCommand(VARIABLE_ADD_CONTEXT_COMMAND, (_, ...args) => args.length > 1 ? this.addContextVariable(args[0], args[1]) : undefined);
68
66
  }
69
67
 
70
68
  protected registerCompletionProviders(): void {
@@ -205,12 +203,12 @@ export class ChatViewLanguageContribution implements FrontendApplicationContribu
205
203
  const items = await provider(model, position);
206
204
  if (items) {
207
205
  suggestions.push(...items.map(item => ({
208
- ...item,
209
206
  command: {
210
- title: nls.localize('theia/ai/chat-ui/addContextVariable', 'Add context variable'),
211
- id: VARIABLE_ADD_CONTEXT_COMMAND,
207
+ title: VARIABLE_ADD_CONTEXT_COMMAND.label!,
208
+ id: VARIABLE_ADD_CONTEXT_COMMAND.id,
212
209
  arguments: [variable.name, item.insertText]
213
- }
210
+ },
211
+ ...item,
214
212
  })));
215
213
  }
216
214
  }
@@ -262,22 +260,10 @@ export class ChatViewLanguageContribution implements FrontendApplicationContribu
262
260
  text: arg
263
261
  }]);
264
262
 
265
- await this.addContextVariable(variableName, arg);
263
+ await this.chatFrontendContribution.addContextVariable(variableName, arg);
266
264
  }
267
265
 
268
266
  protected getCharacterBeforePosition(model: monaco.editor.ITextModel, position: monaco.Position): string {
269
267
  return model.getLineContent(position.lineNumber)[position.column - 1 - 1];
270
268
  }
271
-
272
- protected async addContextVariable(variableName: string, arg: string | undefined): Promise<void> {
273
- const variable = this.variableService.getVariable(variableName);
274
- if (!variable || !AIContextVariable.is(variable)) {
275
- return;
276
- }
277
-
278
- const widget = this.shell.getWidgetById(ChatViewWidget.ID);
279
- if (widget instanceof ChatViewWidget) {
280
- widget.addContext({ variable, arg });
281
- }
282
- }
283
269
  }
@@ -22,6 +22,8 @@ import { AIChatInputWidget } from './chat-input-widget';
22
22
  import { ChatViewTreeWidget } from './chat-tree-view/chat-view-tree-widget';
23
23
  import { AIActivationService } from '@theia/ai-core/lib/browser/ai-activation-service';
24
24
  import { AIVariableResolutionRequest } from '@theia/ai-core';
25
+ import { ProgressBarFactory } from '@theia/core/lib/browser/progress-bar-factory';
26
+ import { FrontendVariableService } from '@theia/ai-core/lib/browser';
25
27
 
26
28
  export namespace ChatViewWidget {
27
29
  export interface State {
@@ -50,6 +52,12 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
50
52
  @inject(AIActivationService)
51
53
  protected readonly activationService: AIActivationService;
52
54
 
55
+ @inject(FrontendVariableService)
56
+ protected readonly variableService: FrontendVariableService;
57
+
58
+ @inject(ProgressBarFactory)
59
+ protected readonly progressBarFactory: ProgressBarFactory;
60
+
53
61
  protected chatSession: ChatSession;
54
62
 
55
63
  protected _state: ChatViewWidget.State = { locked: false };
@@ -110,10 +118,11 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
110
118
  this.inputWidget.setEnabled(change);
111
119
  this.update();
112
120
  });
121
+ this.toDispose.push(this.progressBarFactory({ container: this.node, insertMode: 'prepend', locationId: 'ai-chat' }));
113
122
  }
114
123
 
115
124
  protected initListeners(): void {
116
- this.toDispose.push(
125
+ this.toDispose.pushAll([
117
126
  this.chatService.onSessionEvent(event => {
118
127
  if (!isActiveSessionChangedEvent(event)) {
119
128
  return;
@@ -130,8 +139,12 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
130
139
  } else {
131
140
  console.warn(`Session with ${event.sessionId} not found.`);
132
141
  }
142
+ }),
143
+ // The chat view needs to handle the submission of the edit request
144
+ this.treeWidget.onDidSubmitEdit(request => {
145
+ this.onQuery(request);
133
146
  })
134
- );
147
+ ]);
135
148
  }
136
149
 
137
150
  protected override onActivateRequest(msg: Message): void {
@@ -164,10 +177,10 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
164
177
  return this.onStateChangedEmitter.event;
165
178
  }
166
179
 
167
- protected async onQuery(query: string): Promise<void> {
168
- if (query.length === 0) { return; }
180
+ protected async onQuery(query: string | ChatRequest): Promise<void> {
181
+ const chatRequest: ChatRequest = typeof query === 'string' ? { text: query } : { ...query };
182
+ if (chatRequest.text.length === 0) { return; }
169
183
 
170
- const chatRequest: ChatRequest = { text: query };
171
184
  const requestProgress = await this.chatService.sendRequest(this.chatSession.id, chatRequest);
172
185
  requestProgress?.responseCompleted.then(responseModel => {
173
186
  if (responseModel.isError) {
@@ -149,6 +149,37 @@ div:last-child > .theia-ChatNode {
149
149
  color: var(--theia-badge-foreground);
150
150
  }
151
151
 
152
+ .theia-RequestNode-Footer {
153
+ display: flex;
154
+ align-items: center;
155
+ justify-content: flex-end;
156
+ gap: 2px;
157
+ }
158
+
159
+ .theia-RequestNode-Footer .item {
160
+ opacity: var(--theia-mod-disabled-opacity);
161
+ cursor: default;
162
+ display: flex;
163
+ flex-direction: row;
164
+ column-gap: 0px;
165
+ align-items: center;
166
+ }
167
+
168
+ .theia-RequestNode-Footer .item.enabled {
169
+ cursor: pointer;
170
+ opacity: 1;
171
+ }
172
+
173
+ .theia-RequestNode-Footer :not(.item.enabled) .action-label {
174
+ background: transparent;
175
+ cursor: default;
176
+ }
177
+
178
+ .theia-RequestNode .theia-ChatInput-Editor-Box {
179
+ margin-left: 0px;
180
+ margin-right: 0px;
181
+ }
182
+
152
183
  .chat-input-widget {
153
184
  align-items: flex-end;
154
185
  display: flex;
@@ -181,11 +212,19 @@ div:last-child > .theia-ChatNode {
181
212
  height: 18px;
182
213
  line-height: 16px;
183
214
  min-width: 0;
215
+ user-select: none;
216
+ cursor: pointer;
184
217
  }
185
218
 
186
- .theia-ChatInput-ChatContext-title {
187
- flex: 10 1 auto;
219
+ .theia-ChatInput-ChatContext-labelParts {
220
+ flex: 1;
188
221
  min-width: 0;
222
+ white-space: nowrap;
223
+ overflow: hidden;
224
+ text-overflow: ellipsis;
225
+ }
226
+
227
+ .theia-ChatInput-ChatContext-title {
189
228
  overflow: hidden;
190
229
  text-overflow: ellipsis;
191
230
  white-space: nowrap;
@@ -199,8 +238,6 @@ div:last-child > .theia-ChatNode {
199
238
  overflow: hidden;
200
239
  text-overflow: ellipsis;
201
240
  white-space: nowrap;
202
- flex: 1 10 auto;
203
- min-width: 0;
204
241
  }
205
242
 
206
243
  .theia-ChatInput-ChatContext-Element .action {
@@ -301,6 +338,7 @@ div:last-child > .theia-ChatNode {
301
338
  }
302
339
 
303
340
  .theia-ChatInput-ChangeSet-List .theia-ChatInput-ChangeSet-Icon {
341
+ position: relative;
304
342
  padding-left: 2px;
305
343
  padding-right: 4px;
306
344
  min-width: var(--theia-icon-size);
@@ -325,11 +363,20 @@ div:last-child > .theia-ChatNode {
325
363
  }
326
364
 
327
365
  .theia-ChatInput-ChangeSet-additionalInfo {
366
+ align-items: center;
367
+ gap: 4px;
328
368
  margin-left: 8px;
329
369
  color: var(--theia-disabledForeground);
330
370
  }
331
371
 
372
+ .theia-ChatInput-ChangeSet-List
373
+ .theia-ChatInput-ChangeSet-AdditionalInfo-SuffixIcon {
374
+ font-size: var(--theia-ui-font-size0) px;
375
+ margin-left: 4px;
376
+ }
377
+
332
378
  .theia-ChatInput-ChangeSet-labelParts {
379
+ display: flex;
333
380
  overflow: hidden;
334
381
  text-overflow: ellipsis;
335
382
  }
@@ -354,6 +401,7 @@ div:last-child > .theia-ChatNode {
354
401
  .theia-ChatInput-ChangeSet-Header-Actions,
355
402
  .theia-ChatInput-ChangeSet-Box h3,
356
403
  .theia-ChatInput-ChangeSet-additionalInfo {
404
+ display: flex;
357
405
  white-space: nowrap;
358
406
  overflow: hidden;
359
407
  text-overflow: ellipsis;
@@ -698,3 +746,9 @@ details[open].collapsible-arguments .collapsible-arguments-summary {
698
746
  .session-settings-container .monaco-editor {
699
747
  outline-color: var(--theia-editor-background);
700
748
  }
749
+
750
+ .chat-agent-suggestions {
751
+ padding-inline: 16px;
752
+ padding-block-end: 8px;
753
+ user-select: none;
754
+ }