@theia/ai-chat-ui 1.72.0-next.52 → 1.72.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 (39) hide show
  1. package/lib/browser/ai-chat-navigation-service.d.ts +2 -2
  2. package/lib/browser/ai-chat-navigation-service.d.ts.map +1 -1
  3. package/lib/browser/ai-chat-navigation-service.js +2 -2
  4. package/lib/browser/ai-chat-navigation-service.js.map +1 -1
  5. package/lib/browser/ai-chat-ui-contribution.js +1 -1
  6. package/lib/browser/ai-chat-ui-contribution.js.map +1 -1
  7. package/lib/browser/chat-focus-contribution.d.ts.map +1 -1
  8. package/lib/browser/chat-focus-contribution.js +1 -21
  9. package/lib/browser/chat-focus-contribution.js.map +1 -1
  10. package/lib/browser/chat-input-widget.d.ts +4 -5
  11. package/lib/browser/chat-input-widget.d.ts.map +1 -1
  12. package/lib/browser/chat-input-widget.js +28 -15
  13. package/lib/browser/chat-input-widget.js.map +1 -1
  14. package/lib/browser/chat-response-renderer/code-part-renderer.js +1 -1
  15. package/lib/browser/chat-response-renderer/code-part-renderer.js.map +1 -1
  16. package/lib/browser/chat-response-renderer/error-part-renderer.d.ts.map +1 -1
  17. package/lib/browser/chat-response-renderer/error-part-renderer.js +14 -3
  18. package/lib/browser/chat-response-renderer/error-part-renderer.js.map +1 -1
  19. package/lib/browser/chat-token-usage-indicator-util.d.ts +3 -7
  20. package/lib/browser/chat-token-usage-indicator-util.d.ts.map +1 -1
  21. package/lib/browser/chat-token-usage-indicator-util.js +8 -12
  22. package/lib/browser/chat-token-usage-indicator-util.js.map +1 -1
  23. package/lib/browser/chat-token-usage-indicator-util.spec.js +18 -0
  24. package/lib/browser/chat-token-usage-indicator-util.spec.js.map +1 -1
  25. package/lib/browser/chat-view-widget.d.ts +8 -1
  26. package/lib/browser/chat-view-widget.d.ts.map +1 -1
  27. package/lib/browser/chat-view-widget.js +34 -3
  28. package/lib/browser/chat-view-widget.js.map +1 -1
  29. package/package.json +12 -12
  30. package/src/browser/ai-chat-navigation-service.ts +2 -2
  31. package/src/browser/ai-chat-ui-contribution.ts +1 -1
  32. package/src/browser/chat-focus-contribution.ts +1 -21
  33. package/src/browser/chat-input-widget.tsx +33 -15
  34. package/src/browser/chat-response-renderer/code-part-renderer.tsx +1 -1
  35. package/src/browser/chat-response-renderer/error-part-renderer.tsx +20 -2
  36. package/src/browser/chat-token-usage-indicator-util.spec.ts +31 -0
  37. package/src/browser/chat-token-usage-indicator-util.ts +12 -11
  38. package/src/browser/chat-view-widget.tsx +42 -5
  39. package/src/browser/style/index.css +33 -3
@@ -14,9 +14,12 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
  import { CommandService, ContributionProvider, deepClone, Emitter, Event, MessageService, URI } from '@theia/core';
17
- import { ChatRequest, ChatRequestModel, ChatService, ChatSession, ChatSessionSettings, isActiveSessionChangedEvent, MutableChatModel } from '@theia/ai-chat';
17
+ import {
18
+ ChatRequest, ChatRequestModel, ChatService, ChatSession, ChatSessionSettings,
19
+ formatProviderError, formattedProviderErrorToShortString, isActiveSessionChangedEvent, MutableChatModel
20
+ } from '@theia/ai-chat';
18
21
  import { GenericCapabilitySelections, AIVariableResolutionRequest } from '@theia/ai-core';
19
- import { BaseWidget, codicon, ExtractableWidget, Message, PanelLayout, StatefulWidget } from '@theia/core/lib/browser';
22
+ import { ApplicationShell, BaseWidget, codicon, ExtractableWidget, Message, PanelLayout, StatefulWidget } from '@theia/core/lib/browser';
20
23
  import { nls } from '@theia/core/lib/common/nls';
21
24
  import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify';
22
25
  import { AIChatInputWidget } from './chat-input-widget';
@@ -246,7 +249,7 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
246
249
  if (chatRequest.text.length === 0) { return; }
247
250
 
248
251
  if (this.chatSession.model.isEmpty()) {
249
- this.navigationService.notifyQueryFromWelcomeScreen(this.chatSession.id);
252
+ this.navigationService.notifyInitialQuery(this.chatSession.id);
250
253
  }
251
254
 
252
255
  // Include all variables (context + pending image attachments) in the request
@@ -264,8 +267,14 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
264
267
  }
265
268
  requestProgress?.responseCompleted.then(responseModel => {
266
269
  if (responseModel.isError) {
267
- this.messageService.error(responseModel.errorObject?.message ??
268
- nls.localize('theia/ai/chat-ui/errorChatInvocation', 'An error occurred during chat service invocation.'));
270
+ const rawError = responseModel.errorObject?.message;
271
+ const message = rawError
272
+ ? nls.localize('theia/ai/chat-ui/chatRequestFailedWithDetail',
273
+ 'Chat request failed: {0}',
274
+ formattedProviderErrorToShortString(formatProviderError(rawError)))
275
+ : nls.localize('theia/ai/chat-ui/errorChatInvocation',
276
+ 'An error occurred during chat service invocation.');
277
+ this.messageService.error(message);
269
278
  }
270
279
  }).finally(() => {
271
280
  this.inputWidget.pinnedAgent = this.chatSession.pinnedAgent;
@@ -333,3 +342,31 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta
333
342
  return this.chatSession.model.settings;
334
343
  }
335
344
  }
345
+
346
+ export namespace ChatViewWidget {
347
+ /**
348
+ * Returns the active `ChatViewWidget` if the shell's active widget is one,
349
+ * or if focus is inside one of its child widgets (e.g. the input or tree).
350
+ */
351
+ export function findActive(shell: ApplicationShell): ChatViewWidget | undefined {
352
+ const activeWidget = shell.activeWidget;
353
+ if (activeWidget instanceof ChatViewWidget) {
354
+ return activeWidget;
355
+ }
356
+ const activeElement = document.activeElement;
357
+ if (activeElement instanceof HTMLElement) {
358
+ const widget = shell.findWidgetForElement(activeElement);
359
+ if (widget instanceof ChatViewWidget) {
360
+ return widget;
361
+ }
362
+ let parent = widget?.parent;
363
+ while (parent) {
364
+ if (parent instanceof ChatViewWidget) {
365
+ return parent;
366
+ }
367
+ parent = parent.parent;
368
+ }
369
+ }
370
+ return undefined;
371
+ }
372
+ }
@@ -1243,10 +1243,40 @@ details.theia-tool-confirmation-args>summary::marker {
1243
1243
  }
1244
1244
 
1245
1245
  .theia-ChatPart-Error {
1246
- display: flex;
1247
- flex-direction: row;
1248
- gap: 0.5em;
1246
+ margin-block: 1em;
1247
+ }
1248
+
1249
+ .theia-ChatPart-Error-headline {
1249
1250
  color: var(--theia-errorForeground);
1251
+ display: flex;
1252
+ flex-direction: column;
1253
+ row-gap: var(--theia-ui-padding);
1254
+ }
1255
+
1256
+ .theia-ChatPart-Error-prefix {
1257
+ font-weight: bold;
1258
+ display: flex;
1259
+ align-items: center;
1260
+ gap: var(--theia-ui-padding);
1261
+ }
1262
+
1263
+ .theia-ChatPart-Error details {
1264
+ margin-top: var(--theia-ui-padding);
1265
+ color: var(--theia-descriptionForeground);
1266
+ }
1267
+
1268
+ .theia-ChatPart-Error details summary::marker {
1269
+ color: var(--theia-button-background);
1270
+ }
1271
+
1272
+ .theia-ChatPart-Error details pre {
1273
+ cursor: text;
1274
+ line-height: 1rem;
1275
+ margin: 0;
1276
+ padding: 6px;
1277
+ background-color: var(--theia-editor-background);
1278
+ overflow: auto;
1279
+ text-wrap: auto;
1250
1280
  }
1251
1281
 
1252
1282
  .section-header {