@galaxycore/ai-chat 0.4.0 → 0.5.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.
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
  "use client";
3
- import { i as useAiChat, n as resolveLabels, r as zhCN, t as enUS } from "./labels-DJsjblzj.js";
4
- import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-DlZ1hJkr.js";
3
+ import { i as useAiChat, n as resolveLabels, r as zhCN, t as enUS } from "./labels-BM5o9a9K.js";
4
+ import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-BCbe9Ds8.js";
5
5
  import { i as safeUrl, n as asError, r as getMessageText, t as acceptsFile } from "./utils-DqBGBYA1.js";
6
6
  import { SpeechInputError, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
7
+ import { MarkdownResponse } from "./markdown.js";
7
8
  import { ContextTray, createTextSelectionAdapter, useChatContext } from "./context.js";
8
9
  import "./appearance.js";
9
10
  import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
@@ -59,12 +60,21 @@ function Composer({ chat, labels: overrides, attachments, speech, toolbar, conte
59
60
  };
60
61
  }, []);
61
62
  useEffect(() => {
62
- const element = textarea.current;
63
- if (element) {
64
- element.style.height = "auto";
65
- element.style.height = `${Math.min(element.scrollHeight, 180)}px`;
66
- }
63
+ if (textarea.current) fitTextarea(textarea.current);
67
64
  }, [text]);
65
+ useEffect(() => {
66
+ const element = textarea.current;
67
+ if (!element || typeof ResizeObserver === "undefined") return;
68
+ let width = element.getBoundingClientRect().width;
69
+ const observer = new ResizeObserver(() => {
70
+ const nextWidth = element.getBoundingClientRect().width;
71
+ if (nextWidth === width) return;
72
+ width = nextWidth;
73
+ fitTextarea(element);
74
+ });
75
+ observer.observe(element);
76
+ return () => observer.disconnect();
77
+ }, []);
68
78
  function report(value) {
69
79
  const actionError = asError(value);
70
80
  setError(actionError.message);
@@ -136,215 +146,229 @@ function Composer({ chat, labels: overrides, attachments, speech, toolbar, conte
136
146
  sending.current = false;
137
147
  }
138
148
  }
139
- return /* @__PURE__ */ jsxs("form", {
140
- className: `gc-chat__composer ${className}`,
141
- onSubmit: (event) => {
142
- event.preventDefault();
143
- send();
144
- },
145
- onDragOver: (event) => {
146
- if (attachments && !disabled) event.preventDefault();
147
- },
148
- onDrop: (event) => {
149
- if (attachments && !disabled) {
149
+ return /* @__PURE__ */ jsxs("div", {
150
+ className: "gc-chat__composer-wrap",
151
+ children: [context != null ? /* @__PURE__ */ jsx("div", {
152
+ className: "gc-chat__context",
153
+ children: context
154
+ }) : null, /* @__PURE__ */ jsxs("form", {
155
+ className: `gc-chat__composer ${className}`,
156
+ onSubmit: (event) => {
150
157
  event.preventDefault();
151
- addFiles(Array.from(event.dataTransfer.files));
152
- }
153
- },
154
- children: [
155
- context != null ? /* @__PURE__ */ jsx("div", {
156
- className: "gc-chat__context",
157
- children: context
158
- }) : null,
159
- files.length ? /* @__PURE__ */ jsx("ul", {
160
- className: "gc-chat__attachments",
161
- "aria-label": labels.attach,
162
- children: files.map((file) => /* @__PURE__ */ jsxs("li", {
163
- className: "gc-chat__attachment",
158
+ send();
159
+ },
160
+ onDragOver: (event) => {
161
+ if (attachments && !disabled) event.preventDefault();
162
+ },
163
+ onDrop: (event) => {
164
+ if (attachments && !disabled) {
165
+ event.preventDefault();
166
+ addFiles(Array.from(event.dataTransfer.files));
167
+ }
168
+ },
169
+ children: [
170
+ files.length ? /* @__PURE__ */ jsx("ul", {
171
+ className: "gc-chat__attachments",
172
+ "aria-label": labels.attach,
173
+ children: files.map((file) => /* @__PURE__ */ jsxs("li", {
174
+ className: "gc-chat__attachment",
175
+ children: [
176
+ /* @__PURE__ */ jsx(Icon, { name: "file" }),
177
+ /* @__PURE__ */ jsx("span", { children: file.name }),
178
+ !file.part ? /* @__PURE__ */ jsx("span", {
179
+ role: "status",
180
+ children: labels.uploading
181
+ }) : null,
182
+ /* @__PURE__ */ jsx(ChatIconButton, {
183
+ label: `${labels.removeAttachment}: ${file.name}`,
184
+ icon: "close",
185
+ onClick: () => removeFile(file.id)
186
+ })
187
+ ]
188
+ }, file.id))
189
+ }) : null,
190
+ speech && voice.state === "consent" && /* @__PURE__ */ jsxs("div", {
191
+ className: "gc-chat__voice-consent",
192
+ role: "group",
193
+ "aria-label": voiceLabels.consentTitle,
194
+ children: [
195
+ /* @__PURE__ */ jsx("strong", { children: voiceLabels.consentTitle }),
196
+ /* @__PURE__ */ jsx("p", {
197
+ className: "gc-chat__voice-disclosure",
198
+ children: voice.disclosure
199
+ }),
200
+ /* @__PURE__ */ jsxs("label", {
201
+ className: "gc-chat__voice-remember",
202
+ children: [/* @__PURE__ */ jsx("input", {
203
+ type: "checkbox",
204
+ checked: rememberSpeech,
205
+ onChange: (event) => setRememberSpeech(event.target.checked)
206
+ }), voiceLabels.remember]
207
+ }),
208
+ /* @__PURE__ */ jsxs("div", {
209
+ className: "gc-chat__voice-actions",
210
+ children: [/* @__PURE__ */ jsx("button", {
211
+ type: "button",
212
+ className: "gc-chat__button",
213
+ disabled: disabled || chat.isBusy,
214
+ onClick: () => voice.confirm(rememberSpeech),
215
+ children: voiceLabels.confirm
216
+ }), /* @__PURE__ */ jsx("button", {
217
+ type: "button",
218
+ className: "gc-chat__button",
219
+ onClick: voice.cancel,
220
+ children: voiceLabels.cancel
221
+ })]
222
+ })
223
+ ]
224
+ }),
225
+ speech && voice.isActive && /* @__PURE__ */ jsxs("div", {
226
+ className: "gc-chat__voice",
227
+ "data-state": voice.state,
164
228
  children: [
165
- /* @__PURE__ */ jsx(Icon, { name: "file" }),
166
- /* @__PURE__ */ jsx("span", { children: file.name }),
167
- !file.part ? /* @__PURE__ */ jsx("span", {
229
+ /* @__PURE__ */ jsxs("span", {
230
+ className: "gc-chat__voice-wave",
231
+ "aria-hidden": "true",
232
+ children: [
233
+ /* @__PURE__ */ jsx("i", {}),
234
+ /* @__PURE__ */ jsx("i", {}),
235
+ /* @__PURE__ */ jsx("i", {}),
236
+ /* @__PURE__ */ jsx("i", {}),
237
+ /* @__PURE__ */ jsx("i", {})
238
+ ]
239
+ }),
240
+ /* @__PURE__ */ jsx("span", {
241
+ className: "gc-chat__voice-status",
168
242
  role: "status",
169
- children: labels.uploading
170
- }) : null,
171
- /* @__PURE__ */ jsx(ChatIconButton, {
172
- label: `${labels.removeAttachment}: ${file.name}`,
173
- icon: "close",
174
- onClick: () => removeFile(file.id)
243
+ children: voice.state === "starting" ? voiceLabels.starting : voice.state === "stopping" ? voiceLabels.stopping : voiceLabels.listening
244
+ }),
245
+ /* @__PURE__ */ jsxs("div", {
246
+ className: "gc-chat__voice-actions",
247
+ children: [/* @__PURE__ */ jsx(ChatIconButton, {
248
+ disabled: voice.state === "stopping",
249
+ label: voiceLabels.finish,
250
+ icon: "check",
251
+ onClick: voice.stop
252
+ }), /* @__PURE__ */ jsx(ChatIconButton, {
253
+ label: voiceLabels.cancel,
254
+ icon: "close",
255
+ onClick: voice.cancel
256
+ })]
257
+ }),
258
+ /* @__PURE__ */ jsxs("p", {
259
+ className: "gc-chat__voice-transcript",
260
+ children: [
261
+ voice.result.finalText,
262
+ /* @__PURE__ */ jsx("span", { children: voice.result.interimText }),
263
+ !voice.result.finalText && !voice.result.interimText ? voiceLabels.empty : null
264
+ ]
175
265
  })
176
266
  ]
177
- }, file.id))
178
- }) : null,
179
- speech && voice.state === "consent" && /* @__PURE__ */ jsxs("div", {
180
- className: "gc-chat__voice-consent",
181
- role: "group",
182
- "aria-label": voiceLabels.consentTitle,
183
- children: [
184
- /* @__PURE__ */ jsx("strong", { children: voiceLabels.consentTitle }),
185
- /* @__PURE__ */ jsx("p", {
186
- className: "gc-chat__voice-disclosure",
187
- children: voice.disclosure
188
- }),
189
- /* @__PURE__ */ jsxs("label", {
190
- className: "gc-chat__voice-remember",
191
- children: [/* @__PURE__ */ jsx("input", {
192
- type: "checkbox",
193
- checked: rememberSpeech,
194
- onChange: (event) => setRememberSpeech(event.target.checked)
195
- }), voiceLabels.remember]
196
- }),
197
- /* @__PURE__ */ jsxs("div", {
198
- className: "gc-chat__voice-actions",
199
- children: [/* @__PURE__ */ jsx("button", {
200
- type: "button",
201
- className: "gc-chat__button",
202
- disabled: disabled || chat.isBusy,
203
- onClick: () => voice.confirm(rememberSpeech),
204
- children: voiceLabels.confirm
205
- }), /* @__PURE__ */ jsx("button", {
206
- type: "button",
207
- className: "gc-chat__button",
208
- onClick: voice.cancel,
209
- children: voiceLabels.cancel
210
- })]
211
- })
212
- ]
213
- }),
214
- speech && voice.isActive && /* @__PURE__ */ jsxs("div", {
215
- className: "gc-chat__voice",
216
- "data-state": voice.state,
217
- children: [
218
- /* @__PURE__ */ jsxs("span", {
219
- className: "gc-chat__voice-wave",
220
- "aria-hidden": "true",
267
+ }),
268
+ speech && !voice.support.supported && /* @__PURE__ */ jsx("p", {
269
+ id: `${inputId}-voice-support`,
270
+ className: "gc-chat__voice-unsupported",
271
+ children: voice.support.reason
272
+ }),
273
+ speech && voice.error && /* @__PURE__ */ jsx("p", {
274
+ className: "gc-chat__voice-error",
275
+ role: "alert",
276
+ children: voice.error.message
277
+ }),
278
+ /* @__PURE__ */ jsx("textarea", {
279
+ ref: textarea,
280
+ className: "gc-chat__input",
281
+ "aria-label": labels.placeholder,
282
+ placeholder: labels.placeholder,
283
+ value: text,
284
+ rows: 2,
285
+ disabled,
286
+ onChange: (event) => setText(event.target.value),
287
+ onPaste: (event) => {
288
+ if (attachments && event.clipboardData.files.length) {
289
+ event.preventDefault();
290
+ addFiles(Array.from(event.clipboardData.files));
291
+ }
292
+ },
293
+ onKeyDown: (event) => {
294
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
295
+ event.preventDefault();
296
+ send();
297
+ }
298
+ }
299
+ }),
300
+ /* @__PURE__ */ jsxs("div", {
301
+ className: "gc-chat__composer-bottom",
302
+ children: [/* @__PURE__ */ jsxs("div", {
303
+ className: "gc-chat__toolbar",
221
304
  children: [
222
- /* @__PURE__ */ jsx("i", {}),
223
- /* @__PURE__ */ jsx("i", {}),
224
- /* @__PURE__ */ jsx("i", {}),
225
- /* @__PURE__ */ jsx("i", {}),
226
- /* @__PURE__ */ jsx("i", {})
305
+ attachments ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
306
+ ref: fileInput,
307
+ id: inputId,
308
+ type: "file",
309
+ hidden: true,
310
+ multiple: true,
311
+ accept: attachments.accept,
312
+ disabled,
313
+ onChange: (event) => {
314
+ addFiles(Array.from(event.target.files ?? []));
315
+ event.target.value = "";
316
+ }
317
+ }), /* @__PURE__ */ jsx(ChatIconButton, {
318
+ disabled,
319
+ label: labels.attach,
320
+ icon: "plus",
321
+ onClick: () => fileInput.current?.click()
322
+ })] }) : null,
323
+ toolbar,
324
+ !attachments && !speech && toolbar == null && /* @__PURE__ */ jsx("span", {
325
+ className: "gc-chat__input-hint",
326
+ children: labels.composerHint
327
+ })
227
328
  ]
228
- }),
229
- /* @__PURE__ */ jsx("span", {
230
- className: "gc-chat__voice-status",
231
- role: "status",
232
- children: voice.state === "starting" ? voiceLabels.starting : voice.state === "stopping" ? voiceLabels.stopping : voiceLabels.listening
233
- }),
234
- /* @__PURE__ */ jsxs("div", {
235
- className: "gc-chat__voice-actions",
236
- children: [/* @__PURE__ */ jsx(ChatIconButton, {
237
- disabled: voice.state === "stopping",
238
- label: voiceLabels.finish,
239
- icon: "check",
240
- onClick: voice.stop
241
- }), /* @__PURE__ */ jsx(ChatIconButton, {
242
- label: voiceLabels.cancel,
243
- icon: "close",
244
- onClick: voice.cancel
329
+ }), /* @__PURE__ */ jsxs("div", {
330
+ className: "gc-chat__composer-actions",
331
+ children: [speech && /* @__PURE__ */ jsx(ChatIconButton, {
332
+ label: voiceLabels.start,
333
+ icon: "mic",
334
+ tooltip: voice.support.reason ?? voiceLabels.start,
335
+ "aria-describedby": !voice.support.supported ? `${inputId}-voice-support` : void 0,
336
+ disabled: disabled || chat.isBusy || voice.isActive || voice.state === "consent" || !voice.support.supported,
337
+ onClick: voice.start
338
+ }), chat.isBusy ? /* @__PURE__ */ jsx(ChatIconButton, {
339
+ className: "gc-chat__send",
340
+ label: labels.stop,
341
+ icon: "stop",
342
+ onClick: (event) => {
343
+ event.preventDefault();
344
+ chat.stop().catch(report);
345
+ }
346
+ }) : /* @__PURE__ */ jsx(ChatIconButton, {
347
+ className: "gc-chat__send",
348
+ type: "submit",
349
+ disabled: !canSend,
350
+ label: labels.send,
351
+ icon: "send"
245
352
  })]
246
- }),
247
- /* @__PURE__ */ jsxs("p", {
248
- className: "gc-chat__voice-transcript",
249
- children: [
250
- voice.result.finalText,
251
- /* @__PURE__ */ jsx("span", { children: voice.result.interimText }),
252
- !voice.result.finalText && !voice.result.interimText ? voiceLabels.empty : null
253
- ]
254
- })
255
- ]
256
- }),
257
- speech && !voice.support.supported && /* @__PURE__ */ jsx("p", {
258
- id: `${inputId}-voice-support`,
259
- className: "gc-chat__voice-unsupported",
260
- children: voice.support.reason
261
- }),
262
- speech && voice.error && /* @__PURE__ */ jsx("p", {
263
- className: "gc-chat__voice-error",
264
- role: "alert",
265
- children: voice.error.message
266
- }),
267
- /* @__PURE__ */ jsx("textarea", {
268
- ref: textarea,
269
- className: "gc-chat__input",
270
- "aria-label": labels.placeholder,
271
- placeholder: labels.placeholder,
272
- value: text,
273
- rows: 1,
274
- disabled,
275
- onChange: (event) => setText(event.target.value),
276
- onPaste: (event) => {
277
- if (attachments && event.clipboardData.files.length) {
278
- event.preventDefault();
279
- addFiles(Array.from(event.clipboardData.files));
280
- }
281
- },
282
- onKeyDown: (event) => {
283
- if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
284
- event.preventDefault();
285
- send();
286
- }
287
- }
288
- }),
289
- /* @__PURE__ */ jsxs("div", {
290
- className: "gc-chat__composer-bottom",
291
- children: [/* @__PURE__ */ jsxs("div", {
292
- className: "gc-chat__toolbar",
293
- children: [attachments ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
294
- ref: fileInput,
295
- id: inputId,
296
- type: "file",
297
- hidden: true,
298
- multiple: true,
299
- accept: attachments.accept,
300
- disabled,
301
- onChange: (event) => {
302
- addFiles(Array.from(event.target.files ?? []));
303
- event.target.value = "";
304
- }
305
- }), /* @__PURE__ */ jsx(ChatIconButton, {
306
- disabled,
307
- label: labels.attach,
308
- icon: "plus",
309
- onClick: () => fileInput.current?.click()
310
- })] }) : null, toolbar]
311
- }), /* @__PURE__ */ jsxs("div", {
312
- className: "gc-chat__composer-actions",
313
- children: [speech && /* @__PURE__ */ jsx(ChatIconButton, {
314
- label: voiceLabels.start,
315
- icon: "mic",
316
- tooltip: voice.support.reason ?? voiceLabels.start,
317
- "aria-describedby": !voice.support.supported ? `${inputId}-voice-support` : void 0,
318
- disabled: disabled || chat.isBusy || voice.isActive || voice.state === "consent" || !voice.support.supported,
319
- onClick: voice.start
320
- }), chat.isBusy ? /* @__PURE__ */ jsx(ChatIconButton, {
321
- className: "gc-chat__send",
322
- label: labels.stop,
323
- icon: "stop",
324
- onClick: () => {
325
- chat.stop().catch(report);
326
- }
327
- }) : /* @__PURE__ */ jsx(ChatIconButton, {
328
- className: "gc-chat__send",
329
- type: "submit",
330
- disabled: !canSend,
331
- label: labels.send,
332
- icon: "send"
333
353
  })]
334
- })]
335
- }),
336
- error ? /* @__PURE__ */ jsxs("div", {
337
- className: "gc-chat__error",
338
- role: "alert",
339
- children: [error, /* @__PURE__ */ jsx(ChatIconButton, {
340
- label: labels.dismiss,
341
- icon: "close",
342
- onClick: () => setError(void 0)
343
- })]
344
- }) : null
345
- ]
354
+ }),
355
+ error ? /* @__PURE__ */ jsxs("div", {
356
+ className: "gc-chat__error",
357
+ role: "alert",
358
+ children: [error, /* @__PURE__ */ jsx(ChatIconButton, {
359
+ label: labels.dismiss,
360
+ icon: "close",
361
+ onClick: () => setError(void 0)
362
+ })]
363
+ }) : null
364
+ ]
365
+ })]
346
366
  });
347
367
  }
368
+ function fitTextarea(element) {
369
+ element.style.height = "auto";
370
+ element.style.height = `${Math.min(Math.max(element.getBoundingClientRect().height, element.scrollHeight), 180)}px`;
371
+ }
348
372
  //#endregion
349
373
  //#region src/tool-activity.tsx
350
374
  function readableValue(value) {
@@ -768,7 +792,7 @@ function StreamingText({ text, isStreaming, enabled = true, renderText }) {
768
792
  function ChatMessages(props) {
769
793
  return /* @__PURE__ */ jsx(Messages, { ...props }, props.chat.id);
770
794
  }
771
- function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming = true, renderers, tools, toolPresentation, empty, className, requestOptions, onActionError, capabilities }) {
795
+ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming = true, renderers, tools, toolPresentation, suggestedActions, suggestionsTitle, suggestionsDescription, renderMessageActions, renderMessageHeader, empty, className, requestOptions, onActionError, capabilities }) {
772
796
  const labels = resolveLabels(labelOverrides);
773
797
  const { scroller, content, awayFromBottom, scrollToLatest, scrollEvents } = useMessageScroll(chat.messages);
774
798
  const copyTimeout = useRef(void 0);
@@ -776,6 +800,7 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
776
800
  const [copiedId, setCopiedId] = useState();
777
801
  const [actionError, setActionError] = useState();
778
802
  const [actionPending, setActionPending] = useState(false);
803
+ const [pendingSuggestion, setPendingSuggestion] = useState();
779
804
  useEffect(() => () => clearTimeout(copyTimeout.current), []);
780
805
  function reportError(cause) {
781
806
  const error = asError(cause);
@@ -810,6 +835,29 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
810
835
  setActionPending(false);
811
836
  }
812
837
  }
838
+ function focusComposer() {
839
+ content.current?.closest(".gc-chat")?.querySelector(".gc-chat__input")?.focus();
840
+ }
841
+ async function selectSuggestion(action, message) {
842
+ if (chat.isBusy || actionInFlight.current || action.disabled || message !== chat.messages.at(-1)) return;
843
+ actionInFlight.current = true;
844
+ setActionPending(true);
845
+ setPendingSuggestion(action.id);
846
+ setActionError(void 0);
847
+ try {
848
+ await action.onSelect({
849
+ message,
850
+ chat,
851
+ focusComposer
852
+ });
853
+ } catch (cause) {
854
+ reportError(cause);
855
+ } finally {
856
+ actionInFlight.current = false;
857
+ setActionPending(false);
858
+ setPendingSuggestion(void 0);
859
+ }
860
+ }
813
861
  function renderPart(part, message, isStreaming) {
814
862
  const renderer = renderers?.[part.type];
815
863
  if (renderer) return renderer({
@@ -850,7 +898,7 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
850
898
  text: part.text,
851
899
  isStreaming: message.role === "assistant" && isStreaming && part.state !== "done",
852
900
  enabled: smoothStreaming,
853
- renderText
901
+ renderText: renderText ?? (message.role === "assistant" ? MarkdownResponse : void 0)
854
902
  })
855
903
  }) : null;
856
904
  case "reasoning": return /* @__PURE__ */ jsxs("details", {
@@ -910,6 +958,8 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
910
958
  const lastPart = last?.parts.filter((part) => part.type !== "step-start").at(-1);
911
959
  const toolFinished = lastPart && isToolUIPart(lastPart) && (lastPart.state === "output-available" && !lastPart.preliminary || lastPart.state === "output-error" || lastPart.state === "output-denied");
912
960
  const visibleMessages = chat.messages.filter((message) => message.role !== "system");
961
+ const actions = suggestedActions?.slice(0, 3) ?? [];
962
+ const recommendedIndex = actions.findIndex((action) => action.emphasis === "recommended");
913
963
  const showThinking = chat.isBusy && (last?.role !== "assistant" || !lastPart || lastPart.type === "text" && !lastPart.text || toolFinished);
914
964
  const thinking = /* @__PURE__ */ jsxs("div", {
915
965
  className: "gc-chat__thinking",
@@ -962,35 +1012,83 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
962
1012
  visibleMessages.map((message) => /* @__PURE__ */ jsxs("article", {
963
1013
  className: `gc-chat__message gc-chat__message--${message.role}`,
964
1014
  "aria-label": message.role === "user" ? labels.user : labels.assistant,
965
- children: [/* @__PURE__ */ jsx("div", {
966
- className: "gc-chat__message-body",
967
- children: message.parts.map((part, partIndex) => /* @__PURE__ */ jsx("div", {
968
- className: "gc-chat__part",
969
- "data-part": isToolUIPart(part) ? "tool" : part.type,
970
- children: renderPart(part, message, chat.status === "streaming" && message === last)
971
- }, isToolUIPart(part) ? `tool-${part.toolCallId}` : `${part.type}-${partIndex}`))
972
- }), message.role === "assistant" && /* @__PURE__ */ jsx("div", {
973
- className: "gc-chat__message-footer",
974
- children: showThinking && message === last ? thinking : /* @__PURE__ */ jsxs("div", {
975
- className: "gc-chat__message-actions",
976
- role: "group",
977
- "aria-label": labels.assistant,
978
- children: [getMessageText(message) && /* @__PURE__ */ jsx(ChatIconButton, {
979
- size: "sm",
980
- label: copiedId === message.id ? labels.copied : labels.copy,
981
- icon: copiedId === message.id ? "check" : "copy",
982
- "data-copied": copiedId === message.id || void 0,
983
- disabled: chat.isBusy && message === last,
984
- onClick: () => void copy(message)
985
- }), message === last && capabilities?.regenerate !== false && /* @__PURE__ */ jsx(ChatIconButton, {
986
- size: "sm",
987
- label: labels.regenerate,
988
- icon: "refresh",
989
- disabled: chat.isBusy || actionPending,
990
- onClick: () => void regenerate(message)
1015
+ children: [
1016
+ message.role === "assistant" && (renderMessageHeader ? renderMessageHeader({
1017
+ message,
1018
+ isStreaming: chat.status === "streaming" && message === last,
1019
+ chat
1020
+ }) : /* @__PURE__ */ jsxs("div", {
1021
+ className: "gc-chat__message-heading",
1022
+ children: [/* @__PURE__ */ jsx("span", {
1023
+ className: "gc-chat__assistant-mark",
1024
+ children: /* @__PURE__ */ jsx(Icon, { name: "sparkle" })
1025
+ }), /* @__PURE__ */ jsx("strong", {
1026
+ className: "gc-chat__assistant-name",
1027
+ children: labels.assistant
1028
+ })]
1029
+ })),
1030
+ /* @__PURE__ */ jsx("div", {
1031
+ className: "gc-chat__message-body",
1032
+ children: message.parts.map((part, partIndex) => /* @__PURE__ */ jsx("div", {
1033
+ className: "gc-chat__part",
1034
+ "data-part": isToolUIPart(part) ? "tool" : part.type,
1035
+ children: renderPart(part, message, chat.status === "streaming" && message === last)
1036
+ }, isToolUIPart(part) ? `tool-${part.toolCallId}` : `${part.type}-${partIndex}`))
1037
+ }),
1038
+ message === last && message.role === "assistant" && !chat.isBusy && /* @__PURE__ */ jsxs(Fragment, { children: [actions.length > 0 && /* @__PURE__ */ jsxs("section", {
1039
+ className: "gc-chat__suggestions",
1040
+ "aria-label": labels.suggestions ?? "Suggested next steps",
1041
+ "aria-busy": pendingSuggestion !== void 0,
1042
+ children: [/* @__PURE__ */ jsxs("div", {
1043
+ className: "gc-chat__suggestions-heading",
1044
+ children: [/* @__PURE__ */ jsx("h3", { children: suggestionsTitle ?? labels.suggestions ?? "Suggested next steps" }), suggestionsDescription != null && /* @__PURE__ */ jsx("span", {
1045
+ className: "gc-chat__suggestions-reason",
1046
+ children: suggestionsDescription
1047
+ })]
1048
+ }), /* @__PURE__ */ jsx("div", {
1049
+ className: "gc-chat__suggestions-actions",
1050
+ children: actions.map((action, index) => /* @__PURE__ */ jsxs("button", {
1051
+ type: "button",
1052
+ className: "gc-chat__suggestion",
1053
+ "data-emphasis": action.emphasis === "recommended" && index !== recommendedIndex ? "secondary" : action.emphasis ?? "secondary",
1054
+ "data-pending": pendingSuggestion === action.id || void 0,
1055
+ disabled: actionPending || action.disabled,
1056
+ onClick: () => void selectSuggestion(action, message),
1057
+ children: [
1058
+ action.icon,
1059
+ pendingSuggestion === action.id ? action.pendingLabel ?? action.label : action.label,
1060
+ action.trailingIcon
1061
+ ]
1062
+ }, action.id))
991
1063
  })]
1064
+ }), renderMessageActions?.({
1065
+ message,
1066
+ chat,
1067
+ focusComposer
1068
+ })] }),
1069
+ message.role === "assistant" && /* @__PURE__ */ jsx("div", {
1070
+ className: "gc-chat__message-footer",
1071
+ children: showThinking && message === last ? thinking : /* @__PURE__ */ jsxs("div", {
1072
+ className: "gc-chat__message-actions",
1073
+ role: "group",
1074
+ "aria-label": labels.assistant,
1075
+ children: [getMessageText(message) && /* @__PURE__ */ jsx(ChatIconButton, {
1076
+ size: "sm",
1077
+ label: copiedId === message.id ? labels.copied : labels.copy,
1078
+ icon: copiedId === message.id ? "check" : "copy",
1079
+ "data-copied": copiedId === message.id || void 0,
1080
+ disabled: chat.isBusy && message === last,
1081
+ onClick: () => void copy(message)
1082
+ }), message === last && capabilities?.regenerate !== false && /* @__PURE__ */ jsx(ChatIconButton, {
1083
+ size: "sm",
1084
+ label: labels.regenerate,
1085
+ icon: "refresh",
1086
+ disabled: chat.isBusy || actionPending,
1087
+ onClick: () => void regenerate(message)
1088
+ })]
1089
+ })
992
1090
  })
993
- })]
1091
+ ]
994
1092
  }, message.id)),
995
1093
  showThinking && last?.role !== "assistant" && /* @__PURE__ */ jsx("article", {
996
1094
  className: "gc-chat__message gc-chat__message--assistant",
@@ -1032,7 +1130,7 @@ function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming =
1032
1130
  function ChatPanel(props) {
1033
1131
  return /* @__PURE__ */ jsx(Panel, { ...props }, props.chat.id);
1034
1132
  }
1035
- function Panel({ chat, labels: labelOverrides, title, header, headerActions, footer, composer, composerProps, theme = "auto", variant = "panel", density = "comfortable", capabilities, className, renderText, smoothStreaming, renderers, tools, toolPresentation, empty, requestOptions, onActionError, ...elementProps }) {
1133
+ function Panel({ chat, labels: labelOverrides, title, subtitle, headerIcon, header, headerActions, footer, composer, composerProps, theme = "auto", variant = "panel", density = "comfortable", capabilities, className, renderText, smoothStreaming, renderers, tools, toolPresentation, suggestedActions, suggestionsTitle, suggestionsDescription, renderMessageActions, renderMessageHeader, empty, requestOptions, onActionError, ...elementProps }) {
1036
1134
  const labels = resolveLabels(labelOverrides);
1037
1135
  const [retrying, setRetrying] = useState(false);
1038
1136
  const [retryError, setRetryError] = useState();
@@ -1073,10 +1171,16 @@ function Panel({ chat, labels: labelOverrides, title, header, headerActions, foo
1073
1171
  className: "gc-chat__heading",
1074
1172
  children: [/* @__PURE__ */ jsx("span", {
1075
1173
  className: "gc-chat__brand",
1076
- children: /* @__PURE__ */ jsx(Icon, { name: "sparkle" })
1077
- }), /* @__PURE__ */ jsx("span", {
1078
- className: "gc-chat__title",
1079
- children: title ?? labels.title
1174
+ children: headerIcon ?? /* @__PURE__ */ jsx(Icon, { name: "sparkle" })
1175
+ }), /* @__PURE__ */ jsxs("div", {
1176
+ className: "gc-chat__header-copy",
1177
+ children: [/* @__PURE__ */ jsx("span", {
1178
+ className: "gc-chat__title",
1179
+ children: title ?? labels.title
1180
+ }), subtitle != null && /* @__PURE__ */ jsx("p", {
1181
+ className: "gc-chat__subtitle",
1182
+ children: subtitle
1183
+ })]
1080
1184
  })]
1081
1185
  }), headerActions && /* @__PURE__ */ jsx("div", {
1082
1186
  className: "gc-chat__header-actions",
@@ -1092,6 +1196,11 @@ function Panel({ chat, labels: labelOverrides, title, header, headerActions, foo
1092
1196
  renderers,
1093
1197
  tools,
1094
1198
  toolPresentation,
1199
+ suggestedActions,
1200
+ suggestionsTitle,
1201
+ suggestionsDescription,
1202
+ renderMessageActions,
1203
+ renderMessageHeader,
1095
1204
  empty,
1096
1205
  requestOptions,
1097
1206
  onActionError