@elyracode/web-ui 0.9.57 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/SandboxedIframe.d.ts +15 -1
  3. package/dist/components/SandboxedIframe.d.ts.map +1 -1
  4. package/dist/components/SandboxedIframe.js +129 -67
  5. package/dist/components/SandboxedIframe.js.map +1 -1
  6. package/dist/components/sandbox/RuntimeMessageRouter.d.ts +12 -2
  7. package/dist/components/sandbox/RuntimeMessageRouter.d.ts.map +1 -1
  8. package/dist/components/sandbox/RuntimeMessageRouter.js +26 -2
  9. package/dist/components/sandbox/RuntimeMessageRouter.js.map +1 -1
  10. package/package.json +18 -8
  11. package/example/README.md +0 -61
  12. package/example/index.html +0 -13
  13. package/example/package.json +0 -25
  14. package/example/src/app.css +0 -1
  15. package/example/src/css-modules.d.ts +0 -3
  16. package/example/src/custom-messages.ts +0 -99
  17. package/example/src/main.ts +0 -421
  18. package/example/tsconfig.json +0 -23
  19. package/example/vite.config.ts +0 -6
  20. package/scripts/count-prompt-tokens.ts +0 -88
  21. package/src/ChatPanel.ts +0 -209
  22. package/src/app.css +0 -68
  23. package/src/components/AgentInterface.ts +0 -403
  24. package/src/components/AttachmentTile.ts +0 -107
  25. package/src/components/ConsoleBlock.ts +0 -72
  26. package/src/components/CustomProviderCard.ts +0 -100
  27. package/src/components/ExpandableSection.ts +0 -46
  28. package/src/components/Input.ts +0 -113
  29. package/src/components/MessageEditor.ts +0 -405
  30. package/src/components/MessageList.ts +0 -98
  31. package/src/components/Messages.ts +0 -383
  32. package/src/components/ProviderKeyInput.ts +0 -153
  33. package/src/components/SandboxedIframe.ts +0 -627
  34. package/src/components/StreamingMessageContainer.ts +0 -103
  35. package/src/components/ThinkingBlock.ts +0 -43
  36. package/src/components/message-renderer-registry.ts +0 -28
  37. package/src/components/sandbox/ArtifactsRuntimeProvider.ts +0 -226
  38. package/src/components/sandbox/AttachmentsRuntimeProvider.ts +0 -68
  39. package/src/components/sandbox/ConsoleRuntimeProvider.ts +0 -188
  40. package/src/components/sandbox/FileDownloadRuntimeProvider.ts +0 -114
  41. package/src/components/sandbox/RuntimeMessageBridge.ts +0 -82
  42. package/src/components/sandbox/RuntimeMessageRouter.ts +0 -215
  43. package/src/components/sandbox/SandboxRuntimeProvider.ts +0 -54
  44. package/src/components/sandbox/runtime-messages.ts +0 -146
  45. package/src/dialogs/ApiKeyPromptDialog.ts +0 -75
  46. package/src/dialogs/AttachmentOverlay.ts +0 -637
  47. package/src/dialogs/CustomProviderDialog.ts +0 -274
  48. package/src/dialogs/ModelSelector.ts +0 -370
  49. package/src/dialogs/PersistentStorageDialog.ts +0 -144
  50. package/src/dialogs/ProvidersModelsTab.ts +0 -212
  51. package/src/dialogs/SessionListDialog.ts +0 -150
  52. package/src/dialogs/SettingsDialog.ts +0 -218
  53. package/src/index.ts +0 -120
  54. package/src/prompts/prompts.ts +0 -282
  55. package/src/storage/app-storage.ts +0 -60
  56. package/src/storage/backends/indexeddb-storage-backend.ts +0 -193
  57. package/src/storage/store.ts +0 -33
  58. package/src/storage/stores/custom-providers-store.ts +0 -62
  59. package/src/storage/stores/provider-keys-store.ts +0 -33
  60. package/src/storage/stores/sessions-store.ts +0 -136
  61. package/src/storage/stores/settings-store.ts +0 -34
  62. package/src/storage/types.ts +0 -206
  63. package/src/tools/artifacts/ArtifactElement.ts +0 -14
  64. package/src/tools/artifacts/ArtifactPill.ts +0 -26
  65. package/src/tools/artifacts/Console.ts +0 -93
  66. package/src/tools/artifacts/DocxArtifact.ts +0 -213
  67. package/src/tools/artifacts/ExcelArtifact.ts +0 -231
  68. package/src/tools/artifacts/GenericArtifact.ts +0 -117
  69. package/src/tools/artifacts/HtmlArtifact.ts +0 -195
  70. package/src/tools/artifacts/ImageArtifact.ts +0 -116
  71. package/src/tools/artifacts/MarkdownArtifact.ts +0 -82
  72. package/src/tools/artifacts/PdfArtifact.ts +0 -202
  73. package/src/tools/artifacts/SvgArtifact.ts +0 -119
  74. package/src/tools/artifacts/TextArtifact.ts +0 -148
  75. package/src/tools/artifacts/artifacts-tool-renderer.ts +0 -310
  76. package/src/tools/artifacts/artifacts.ts +0 -713
  77. package/src/tools/artifacts/index.ts +0 -7
  78. package/src/tools/extract-document.ts +0 -275
  79. package/src/tools/index.ts +0 -46
  80. package/src/tools/javascript-repl.ts +0 -293
  81. package/src/tools/renderer-registry.ts +0 -130
  82. package/src/tools/renderers/BashRenderer.ts +0 -52
  83. package/src/tools/renderers/CalculateRenderer.ts +0 -58
  84. package/src/tools/renderers/DefaultRenderer.ts +0 -103
  85. package/src/tools/renderers/GetCurrentTimeRenderer.ts +0 -92
  86. package/src/tools/types.ts +0 -15
  87. package/src/utils/attachment-utils.ts +0 -479
  88. package/src/utils/auth-token.ts +0 -22
  89. package/src/utils/format.ts +0 -42
  90. package/src/utils/i18n.ts +0 -653
  91. package/src/utils/model-discovery.ts +0 -290
  92. package/src/utils/proxy-utils.ts +0 -139
  93. package/src/utils/test-sessions.ts +0 -2357
  94. package/tsconfig.build.json +0 -20
  95. package/tsconfig.json +0 -7
@@ -1,46 +0,0 @@
1
- import { icon } from "@elyracode/mini-lit";
2
- import { html, LitElement, type TemplateResult } from "lit";
3
- import { customElement, property, state } from "lit/decorators.js";
4
- import { ChevronDown, ChevronRight } from "lucide";
5
-
6
- /**
7
- * Reusable expandable section component for tool renderers.
8
- * Captures children in connectedCallback and re-renders them in the details area.
9
- */
10
- @customElement("expandable-section")
11
- export class ExpandableSection extends LitElement {
12
- @property() summary!: string;
13
- @property({ type: Boolean }) defaultExpanded = false;
14
- @state() private expanded = false;
15
- private capturedChildren: Node[] = [];
16
-
17
- protected createRenderRoot() {
18
- return this; // light DOM
19
- }
20
-
21
- override connectedCallback() {
22
- super.connectedCallback();
23
- // Capture children before first render
24
- this.capturedChildren = Array.from(this.childNodes);
25
- // Clear children (we'll re-insert them in render)
26
- this.innerHTML = "";
27
- this.expanded = this.defaultExpanded;
28
- }
29
-
30
- override render(): TemplateResult {
31
- return html`
32
- <div>
33
- <button
34
- @click=${() => {
35
- this.expanded = !this.expanded;
36
- }}
37
- class="flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors w-full text-left"
38
- >
39
- ${icon(this.expanded ? ChevronDown : ChevronRight, "sm")}
40
- <span>${this.summary}</span>
41
- </button>
42
- ${this.expanded ? html`<div class="mt-2">${this.capturedChildren}</div>` : ""}
43
- </div>
44
- `;
45
- }
46
- }
@@ -1,113 +0,0 @@
1
- import { type BaseComponentProps, fc } from "@elyracode/mini-lit/dist/mini.js";
2
- import { html } from "lit";
3
- import { type Ref, ref } from "lit/directives/ref.js";
4
- import { i18n } from "../utils/i18n.js";
5
-
6
- export type InputType = "text" | "email" | "password" | "number" | "url" | "tel" | "search";
7
- export type InputSize = "sm" | "md" | "lg";
8
-
9
- export interface InputProps extends BaseComponentProps {
10
- type?: InputType;
11
- size?: InputSize;
12
- value?: string;
13
- placeholder?: string;
14
- label?: string;
15
- error?: string;
16
- disabled?: boolean;
17
- required?: boolean;
18
- name?: string;
19
- autocomplete?: string;
20
- min?: number;
21
- max?: number;
22
- step?: number;
23
- inputRef?: Ref<HTMLInputElement>;
24
- onInput?: (e: Event) => void;
25
- onChange?: (e: Event) => void;
26
- onKeyDown?: (e: KeyboardEvent) => void;
27
- onKeyUp?: (e: KeyboardEvent) => void;
28
- }
29
-
30
- export const Input = fc<InputProps>(
31
- ({
32
- type = "text",
33
- size = "md",
34
- value = "",
35
- placeholder = "",
36
- label = "",
37
- error = "",
38
- disabled = false,
39
- required = false,
40
- name = "",
41
- autocomplete = "",
42
- min,
43
- max,
44
- step,
45
- inputRef,
46
- onInput,
47
- onChange,
48
- onKeyDown,
49
- onKeyUp,
50
- className = "",
51
- }) => {
52
- const sizeClasses = {
53
- sm: "h-8 px-3 py-1 text-sm",
54
- md: "h-9 px-3 py-1 text-sm md:text-sm",
55
- lg: "h-10 px-4 py-1 text-base",
56
- };
57
-
58
- const baseClasses =
59
- "flex w-full min-w-0 rounded-md border bg-transparent text-foreground shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium";
60
- const interactionClasses =
61
- "placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground";
62
- const focusClasses = "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]";
63
- const darkClasses = "dark:bg-input/30";
64
- const stateClasses = error
65
- ? "border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40"
66
- : "border-input";
67
- const disabledClasses = "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50";
68
-
69
- const handleInput = (e: Event) => {
70
- onInput?.(e);
71
- };
72
-
73
- const handleChange = (e: Event) => {
74
- onChange?.(e);
75
- };
76
-
77
- return html`
78
- <div class="flex flex-col gap-1.5 ${className}">
79
- ${
80
- label
81
- ? html`
82
- <label class="text-sm font-medium text-foreground">
83
- ${label} ${required ? html`<span class="text-destructive">${i18n("*")}</span>` : ""}
84
- </label>
85
- `
86
- : ""
87
- }
88
- <input
89
- type="${type}"
90
- class="${baseClasses} ${
91
- sizeClasses[size]
92
- } ${interactionClasses} ${focusClasses} ${darkClasses} ${stateClasses} ${disabledClasses}"
93
- .value=${value}
94
- placeholder="${placeholder}"
95
- ?disabled=${disabled}
96
- ?required=${required}
97
- ?aria-invalid=${!!error}
98
- name="${name}"
99
- autocomplete="${autocomplete}"
100
- min="${min ?? ""}"
101
- max="${max ?? ""}"
102
- step="${step ?? ""}"
103
- @input=${handleInput}
104
- @change=${handleChange}
105
- @keydown=${onKeyDown}
106
- @keyup=${onKeyUp}
107
- ${inputRef ? ref(inputRef) : ""}
108
- />
109
- ${error ? html`<span class="text-sm text-destructive">${error}</span>` : ""}
110
- </div>
111
- `;
112
- },
113
- );
@@ -1,405 +0,0 @@
1
- import type { Api, Model } from "@elyracode/ai";
2
- import { icon } from "@elyracode/mini-lit";
3
- import { Button } from "@elyracode/mini-lit/dist/Button.js";
4
- import { Select, type SelectOption } from "@elyracode/mini-lit/dist/Select.js";
5
- import { html, LitElement } from "lit";
6
- import { customElement, property, state } from "lit/decorators.js";
7
- import { createRef, ref } from "lit/directives/ref.js";
8
- import { Brain, Loader2, Paperclip, Send, Sparkles, Square } from "lucide";
9
- import { type Attachment, loadAttachment } from "../utils/attachment-utils.js";
10
- import { i18n } from "../utils/i18n.js";
11
- import "./AttachmentTile.js";
12
- import type { ThinkingLevel } from "@elyracode/agent-core";
13
-
14
- @customElement("message-editor")
15
- export class MessageEditor extends LitElement {
16
- private _value = "";
17
- private textareaRef = createRef<HTMLTextAreaElement>();
18
-
19
- @property()
20
- get value() {
21
- return this._value;
22
- }
23
-
24
- set value(val: string) {
25
- const oldValue = this._value;
26
- this._value = val;
27
- this.requestUpdate("value", oldValue);
28
- }
29
-
30
- @property() isStreaming = false;
31
- @property() currentModel?: Model<Api>;
32
- @property() thinkingLevel: ThinkingLevel = "off";
33
- @property() showAttachmentButton = true;
34
- @property() showModelSelector = true;
35
- @property() showThinkingSelector = true;
36
- @property() onInput?: (value: string) => void;
37
- @property() onSend?: (input: string, attachments: Attachment[]) => void;
38
- @property() onAbort?: () => void;
39
- @property() onModelSelect?: () => void;
40
- @property() onThinkingChange?: (level: "off" | "minimal" | "low" | "medium" | "high") => void;
41
- @property() onFilesChange?: (files: Attachment[]) => void;
42
- @property() attachments: Attachment[] = [];
43
- @property() maxFiles = 10;
44
- @property() maxFileSize = 20 * 1024 * 1024; // 20MB
45
- @property() acceptedTypes =
46
- "image/*,application/pdf,.docx,.pptx,.xlsx,.xls,.txt,.md,.json,.xml,.html,.css,.js,.ts,.jsx,.tsx,.yml,.yaml";
47
-
48
- @state() processingFiles = false;
49
- @state() isDragging = false;
50
- private fileInputRef = createRef<HTMLInputElement>();
51
-
52
- protected override createRenderRoot(): HTMLElement | DocumentFragment {
53
- return this;
54
- }
55
-
56
- private handleTextareaInput = (e: Event) => {
57
- const textarea = e.target as HTMLTextAreaElement;
58
- this.value = textarea.value;
59
- this.onInput?.(this.value);
60
- };
61
-
62
- private handleKeyDown = (e: KeyboardEvent) => {
63
- // Ignore key events during IME composition (e.g. CJK input)
64
- if (e.isComposing || e.key === "Process") return;
65
-
66
- if (e.key === "Enter" && !e.shiftKey) {
67
- e.preventDefault();
68
- if (!this.isStreaming && !this.processingFiles && (this.value.trim() || this.attachments.length > 0)) {
69
- this.handleSend();
70
- }
71
- } else if (e.key === "Escape" && this.isStreaming) {
72
- e.preventDefault();
73
- this.onAbort?.();
74
- }
75
- };
76
-
77
- private handlePaste = async (e: ClipboardEvent) => {
78
- const items = e.clipboardData?.items;
79
- if (!items) return;
80
-
81
- const imageFiles: File[] = [];
82
-
83
- // Check for image items in clipboard
84
- for (let i = 0; i < items.length; i++) {
85
- const item = items[i];
86
- if (item.type.startsWith("image/")) {
87
- const file = item.getAsFile();
88
- if (file) {
89
- imageFiles.push(file);
90
- }
91
- }
92
- }
93
-
94
- // If we found images, process them
95
- if (imageFiles.length > 0) {
96
- e.preventDefault(); // Prevent default paste behavior
97
-
98
- if (imageFiles.length + this.attachments.length > this.maxFiles) {
99
- alert(`Maximum ${this.maxFiles} files allowed`);
100
- return;
101
- }
102
-
103
- this.processingFiles = true;
104
- const newAttachments: Attachment[] = [];
105
-
106
- for (const file of imageFiles) {
107
- try {
108
- if (file.size > this.maxFileSize) {
109
- alert(`Image exceeds maximum size of ${Math.round(this.maxFileSize / 1024 / 1024)}MB`);
110
- continue;
111
- }
112
-
113
- const attachment = await loadAttachment(file);
114
- newAttachments.push(attachment);
115
- } catch (error) {
116
- console.error("Error processing pasted image:", error);
117
- alert(`Failed to process pasted image: ${String(error)}`);
118
- }
119
- }
120
-
121
- this.attachments = [...this.attachments, ...newAttachments];
122
- this.onFilesChange?.(this.attachments);
123
- this.processingFiles = false;
124
- }
125
- };
126
-
127
- private handleSend = () => {
128
- this.onSend?.(this.value, this.attachments);
129
- };
130
-
131
- private handleAttachmentClick = () => {
132
- this.fileInputRef.value?.click();
133
- };
134
-
135
- private async handleFilesSelected(e: Event) {
136
- const input = e.target as HTMLInputElement;
137
- const files = Array.from(input.files || []);
138
- if (files.length === 0) return;
139
-
140
- if (files.length + this.attachments.length > this.maxFiles) {
141
- alert(`Maximum ${this.maxFiles} files allowed`);
142
- input.value = "";
143
- return;
144
- }
145
-
146
- this.processingFiles = true;
147
- const newAttachments: Attachment[] = [];
148
-
149
- for (const file of files) {
150
- try {
151
- if (file.size > this.maxFileSize) {
152
- alert(`${file.name} exceeds maximum size of ${Math.round(this.maxFileSize / 1024 / 1024)}MB`);
153
- continue;
154
- }
155
-
156
- const attachment = await loadAttachment(file);
157
- newAttachments.push(attachment);
158
- } catch (error) {
159
- console.error(`Error processing ${file.name}:`, error);
160
- alert(`Failed to process ${file.name}: ${String(error)}`);
161
- }
162
- }
163
-
164
- this.attachments = [...this.attachments, ...newAttachments];
165
- this.onFilesChange?.(this.attachments);
166
- this.processingFiles = false;
167
- input.value = ""; // Reset input
168
- }
169
-
170
- private removeFile(fileId: string) {
171
- this.attachments = this.attachments.filter((f) => f.id !== fileId);
172
- this.onFilesChange?.(this.attachments);
173
- }
174
-
175
- private handleDragOver = (e: DragEvent) => {
176
- e.preventDefault();
177
- e.stopPropagation();
178
- if (!this.isDragging) {
179
- this.isDragging = true;
180
- }
181
- };
182
-
183
- private handleDragLeave = (e: DragEvent) => {
184
- e.preventDefault();
185
- e.stopPropagation();
186
- // Only set isDragging to false if we're leaving the entire component
187
- const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
188
- const x = e.clientX;
189
- const y = e.clientY;
190
- if (x <= rect.left || x >= rect.right || y <= rect.top || y >= rect.bottom) {
191
- this.isDragging = false;
192
- }
193
- };
194
-
195
- private handleDrop = async (e: DragEvent) => {
196
- e.preventDefault();
197
- e.stopPropagation();
198
- this.isDragging = false;
199
-
200
- const files = Array.from(e.dataTransfer?.files || []);
201
- if (files.length === 0) return;
202
-
203
- if (files.length + this.attachments.length > this.maxFiles) {
204
- alert(`Maximum ${this.maxFiles} files allowed`);
205
- return;
206
- }
207
-
208
- this.processingFiles = true;
209
- const newAttachments: Attachment[] = [];
210
-
211
- for (const file of files) {
212
- try {
213
- if (file.size > this.maxFileSize) {
214
- alert(`${file.name} exceeds maximum size of ${Math.round(this.maxFileSize / 1024 / 1024)}MB`);
215
- continue;
216
- }
217
-
218
- const attachment = await loadAttachment(file);
219
- newAttachments.push(attachment);
220
- } catch (error) {
221
- console.error(`Error processing ${file.name}:`, error);
222
- alert(`Failed to process ${file.name}: ${String(error)}`);
223
- }
224
- }
225
-
226
- this.attachments = [...this.attachments, ...newAttachments];
227
- this.onFilesChange?.(this.attachments);
228
- this.processingFiles = false;
229
- };
230
-
231
- override firstUpdated() {
232
- const textarea = this.textareaRef.value;
233
- if (textarea) {
234
- textarea.focus();
235
- }
236
- }
237
-
238
- override render() {
239
- // Check if current model supports thinking/reasoning
240
- const model = this.currentModel;
241
- const supportsThinking = model?.reasoning === true; // Models with reasoning:true support thinking
242
-
243
- return html`
244
- <div
245
- class="bg-card rounded-xl border shadow-sm relative ${this.isDragging ? "border-primary border-2 bg-primary/5" : "border-border"}"
246
- @dragover=${this.handleDragOver}
247
- @dragleave=${this.handleDragLeave}
248
- @drop=${this.handleDrop}
249
- >
250
- <!-- Drag overlay -->
251
- ${
252
- this.isDragging
253
- ? html`
254
- <div class="absolute inset-0 bg-primary/10 rounded-xl pointer-events-none z-10 flex items-center justify-center">
255
- <div class="text-primary font-medium">${i18n("Drop files here")}</div>
256
- </div>
257
- `
258
- : ""
259
- }
260
-
261
- <!-- Attachments -->
262
- ${
263
- this.attachments.length > 0
264
- ? html`
265
- <div class="px-4 pt-3 pb-2 flex flex-wrap gap-2">
266
- ${this.attachments.map(
267
- (attachment) => html`
268
- <attachment-tile
269
- .attachment=${attachment}
270
- .showDelete=${true}
271
- .onDelete=${() => this.removeFile(attachment.id)}
272
- ></attachment-tile>
273
- `,
274
- )}
275
- </div>
276
- `
277
- : ""
278
- }
279
-
280
- <textarea
281
- class="w-full bg-transparent p-4 text-foreground placeholder-muted-foreground outline-none resize-none overflow-y-auto"
282
- placeholder=${i18n("Type a message...")}
283
- rows="1"
284
- style="max-height: 200px; field-sizing: content; min-height: 1lh; height: auto;"
285
- .value=${this.value}
286
- @input=${this.handleTextareaInput}
287
- @keydown=${this.handleKeyDown}
288
- @paste=${this.handlePaste}
289
- ${ref(this.textareaRef)}
290
- ></textarea>
291
-
292
- <!-- Hidden file input -->
293
- <input
294
- type="file"
295
- ${ref(this.fileInputRef)}
296
- @change=${this.handleFilesSelected}
297
- accept=${this.acceptedTypes}
298
- multiple
299
- style="display: none;"
300
- />
301
-
302
- <!-- Button Row -->
303
- <div class="px-2 pb-2 flex items-center justify-between">
304
- <!-- Left side - attachment and thinking selector -->
305
- <div class="flex gap-2 items-center">
306
- ${
307
- this.showAttachmentButton
308
- ? this.processingFiles
309
- ? html`
310
- <div class="h-8 w-8 flex items-center justify-center">
311
- ${icon(Loader2, "sm", "animate-spin text-muted-foreground")}
312
- </div>
313
- `
314
- : html`
315
- ${Button({
316
- variant: "ghost",
317
- size: "icon",
318
- className: "h-8 w-8",
319
- onClick: this.handleAttachmentClick,
320
- children: icon(Paperclip, "sm"),
321
- })}
322
- `
323
- : ""
324
- }
325
- ${
326
- supportsThinking && this.showThinkingSelector
327
- ? html`
328
- ${Select({
329
- value: this.thinkingLevel,
330
- placeholder: i18n("Off"),
331
- options: [
332
- { value: "off", label: i18n("Off"), icon: icon(Brain, "sm") },
333
- { value: "minimal", label: i18n("Minimal"), icon: icon(Brain, "sm") },
334
- { value: "low", label: i18n("Low"), icon: icon(Brain, "sm") },
335
- { value: "medium", label: i18n("Medium"), icon: icon(Brain, "sm") },
336
- { value: "high", label: i18n("High"), icon: icon(Brain, "sm") },
337
- ] as SelectOption[],
338
- onChange: (value: string) => {
339
- const level = value as "off" | "minimal" | "low" | "medium" | "high";
340
- this.thinkingLevel = level;
341
- this.onThinkingChange?.(level);
342
- },
343
- width: "80px",
344
- size: "sm",
345
- variant: "ghost",
346
- fitContent: true,
347
- })}
348
- `
349
- : ""
350
- }
351
- </div>
352
-
353
- <!-- Model selector and send on the right -->
354
- <div class="flex gap-2 items-center">
355
- ${
356
- this.showModelSelector && this.currentModel
357
- ? html`
358
- ${Button({
359
- variant: "ghost",
360
- size: "sm",
361
- onClick: () => {
362
- // Focus textarea before opening model selector so focus returns there
363
- this.textareaRef.value?.focus();
364
- // Wait for next frame to ensure focus takes effect before dialog captures it
365
- requestAnimationFrame(() => {
366
- this.onModelSelect?.();
367
- });
368
- },
369
- children: html`
370
- ${icon(Sparkles, "sm")}
371
- <span class="ml-1">${this.currentModel.id}</span>
372
- `,
373
- className: "h-8 text-xs truncate",
374
- })}
375
- `
376
- : ""
377
- }
378
- ${
379
- this.isStreaming
380
- ? html`
381
- ${Button({
382
- variant: "ghost",
383
- size: "icon",
384
- onClick: this.onAbort,
385
- children: icon(Square, "sm"),
386
- className: "h-8 w-8",
387
- })}
388
- `
389
- : html`
390
- ${Button({
391
- variant: "ghost",
392
- size: "icon",
393
- onClick: this.handleSend,
394
- disabled: (!this.value.trim() && this.attachments.length === 0) || this.processingFiles,
395
- children: html`<div style="transform: rotate(-45deg)">${icon(Send, "sm")}</div>`,
396
- className: "h-8 w-8",
397
- })}
398
- `
399
- }
400
- </div>
401
- </div>
402
- </div>
403
- `;
404
- }
405
- }
@@ -1,98 +0,0 @@
1
- import type { AgentMessage, AgentTool } from "@elyracode/agent-core";
2
- import type {
3
- AssistantMessage as AssistantMessageType,
4
- ToolResultMessage as ToolResultMessageType,
5
- } from "@elyracode/ai";
6
- import { html, LitElement, type TemplateResult } from "lit";
7
- import { property } from "lit/decorators.js";
8
- import { repeat } from "lit/directives/repeat.js";
9
- import { renderMessage } from "./message-renderer-registry.js";
10
-
11
- export class MessageList extends LitElement {
12
- @property({ type: Array }) messages: AgentMessage[] = [];
13
- @property({ type: Array }) tools: AgentTool[] = [];
14
- @property({ type: Object }) pendingToolCalls?: ReadonlySet<string>;
15
- @property({ type: Boolean }) isStreaming: boolean = false;
16
- @property({ attribute: false }) onCostClick?: () => void;
17
-
18
- protected override createRenderRoot(): HTMLElement | DocumentFragment {
19
- return this;
20
- }
21
-
22
- override connectedCallback(): void {
23
- super.connectedCallback();
24
- this.style.display = "block";
25
- }
26
-
27
- private buildRenderItems() {
28
- // Map tool results by call id for quick lookup
29
- const resultByCallId = new Map<string, ToolResultMessageType>();
30
- for (const message of this.messages) {
31
- if (message.role === "toolResult") {
32
- resultByCallId.set(message.toolCallId, message);
33
- }
34
- }
35
-
36
- const items: Array<{ key: string; template: TemplateResult }> = [];
37
- let index = 0;
38
- for (const msg of this.messages) {
39
- // Skip artifact messages - they're for session persistence only, not UI display
40
- if (msg.role === "artifact") {
41
- continue;
42
- }
43
-
44
- // Try custom renderer first
45
- const customTemplate = renderMessage(msg);
46
- if (customTemplate) {
47
- items.push({ key: `msg:${index}`, template: customTemplate });
48
- index++;
49
- continue;
50
- }
51
-
52
- // Fall back to built-in renderers
53
- if (msg.role === "user" || msg.role === "user-with-attachments") {
54
- items.push({
55
- key: `msg:${index}`,
56
- template: html`<user-message .message=${msg}></user-message>`,
57
- });
58
- index++;
59
- } else if (msg.role === "assistant") {
60
- const amsg = msg as AssistantMessageType;
61
- items.push({
62
- key: `msg:${index}`,
63
- template: html`<assistant-message
64
- .message=${amsg}
65
- .tools=${this.tools}
66
- .isStreaming=${false}
67
- .pendingToolCalls=${this.pendingToolCalls}
68
- .toolResultsById=${resultByCallId}
69
- .hideToolCalls=${false}
70
- .hidePendingToolCalls=${this.isStreaming}
71
- .onCostClick=${this.onCostClick}
72
- ></assistant-message>`,
73
- });
74
- index++;
75
- } else {
76
- // Skip standalone toolResult messages; they are rendered via paired tool-message above
77
- // Skip unknown roles
78
- }
79
- }
80
- return items;
81
- }
82
-
83
- override render() {
84
- const items = this.buildRenderItems();
85
- return html`<div class="flex flex-col gap-3">
86
- ${repeat(
87
- items,
88
- (it) => it.key,
89
- (it) => it.template,
90
- )}
91
- </div>`;
92
- }
93
- }
94
-
95
- // Register custom element
96
- if (!customElements.get("message-list")) {
97
- customElements.define("message-list", MessageList);
98
- }