@nextclaw/agent-chat-ui 0.3.6 → 0.3.7
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.d.ts +1 -0
- package/dist/index.js +47 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -341,6 +341,12 @@ const ChatButton = React.forwardRef(({ className, variant, size, ...props }, ref
|
|
|
341
341
|
ChatButton.displayName = "ChatButton";
|
|
342
342
|
//#endregion
|
|
343
343
|
//#region src/components/chat/ui/chat-input-bar/chat-input-bar-actions.tsx
|
|
344
|
+
const SEND_ERROR_PREVIEW_MAX_CHARS = 120;
|
|
345
|
+
function buildSendErrorPreview(value) {
|
|
346
|
+
const compact = value.replace(/\s+/g, " ").trim();
|
|
347
|
+
if (compact.length <= SEND_ERROR_PREVIEW_MAX_CHARS) return compact;
|
|
348
|
+
return `${compact.slice(0, SEND_ERROR_PREVIEW_MAX_CHARS - 1)}…`;
|
|
349
|
+
}
|
|
344
350
|
function StopIcon() {
|
|
345
351
|
return /* @__PURE__ */ jsx("span", {
|
|
346
352
|
"aria-hidden": "true",
|
|
@@ -348,22 +354,49 @@ function StopIcon() {
|
|
|
348
354
|
className: "block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]"
|
|
349
355
|
});
|
|
350
356
|
}
|
|
351
|
-
function ChatInputBarActions(
|
|
352
|
-
const { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = ChatUiPrimitives;
|
|
357
|
+
function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canStopGeneration, sendDisabled, stopDisabled, stopHint, sendButtonLabel, stopButtonLabel, onSend, onStop }) {
|
|
358
|
+
const { Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = ChatUiPrimitives;
|
|
359
|
+
const normalizedSendError = sendError?.trim() ?? "";
|
|
360
|
+
const sendErrorPreview = normalizedSendError ? buildSendErrorPreview(normalizedSendError) : "";
|
|
361
|
+
const resolvedSendErrorDetailsLabel = sendErrorDetailsLabel?.trim() || "Details";
|
|
353
362
|
return /* @__PURE__ */ jsxs("div", {
|
|
354
363
|
className: "flex flex-col items-end gap-1",
|
|
355
|
-
children: [
|
|
356
|
-
className: "max-w-[420px]
|
|
357
|
-
children:
|
|
364
|
+
children: [normalizedSendError ? /* @__PURE__ */ jsxs("div", {
|
|
365
|
+
className: "flex max-w-[420px] items-start justify-end gap-2 text-right",
|
|
366
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
367
|
+
className: "min-w-0 flex-1 text-[11px] text-red-600",
|
|
368
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
369
|
+
className: "block truncate",
|
|
370
|
+
title: normalizedSendError,
|
|
371
|
+
children: sendErrorPreview
|
|
372
|
+
})
|
|
373
|
+
}), /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
374
|
+
asChild: true,
|
|
375
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
376
|
+
type: "button",
|
|
377
|
+
className: "shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100",
|
|
378
|
+
children: resolvedSendErrorDetailsLabel
|
|
379
|
+
})
|
|
380
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
381
|
+
align: "end",
|
|
382
|
+
className: "w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0",
|
|
383
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
384
|
+
className: "border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700",
|
|
385
|
+
children: resolvedSendErrorDetailsLabel
|
|
386
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
387
|
+
className: "max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700",
|
|
388
|
+
children: normalizedSendError
|
|
389
|
+
})]
|
|
390
|
+
})] })]
|
|
358
391
|
}) : null, /* @__PURE__ */ jsx("div", {
|
|
359
392
|
className: "flex items-center gap-2",
|
|
360
|
-
children:
|
|
393
|
+
children: isSending ? canStopGeneration ? /* @__PURE__ */ jsx(ChatButton, {
|
|
361
394
|
size: "icon",
|
|
362
395
|
variant: "outline",
|
|
363
396
|
className: "h-8 w-8 rounded-full",
|
|
364
|
-
"aria-label":
|
|
365
|
-
onClick: () => void
|
|
366
|
-
disabled:
|
|
397
|
+
"aria-label": stopButtonLabel,
|
|
398
|
+
onClick: () => void onStop(),
|
|
399
|
+
disabled: stopDisabled,
|
|
367
400
|
children: /* @__PURE__ */ jsx(StopIcon, {})
|
|
368
401
|
}) : /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
369
402
|
asChild: true,
|
|
@@ -371,7 +404,7 @@ function ChatInputBarActions(props) {
|
|
|
371
404
|
size: "icon",
|
|
372
405
|
variant: "outline",
|
|
373
406
|
className: "h-8 w-8 rounded-full",
|
|
374
|
-
"aria-label":
|
|
407
|
+
"aria-label": stopButtonLabel,
|
|
375
408
|
disabled: true,
|
|
376
409
|
children: /* @__PURE__ */ jsx(StopIcon, {})
|
|
377
410
|
}) })
|
|
@@ -379,14 +412,14 @@ function ChatInputBarActions(props) {
|
|
|
379
412
|
side: "top",
|
|
380
413
|
children: /* @__PURE__ */ jsx("p", {
|
|
381
414
|
className: "text-xs",
|
|
382
|
-
children:
|
|
415
|
+
children: stopHint
|
|
383
416
|
})
|
|
384
417
|
})] }) }) : /* @__PURE__ */ jsx(ChatButton, {
|
|
385
418
|
size: "icon",
|
|
386
419
|
className: "h-8 w-8 rounded-full",
|
|
387
|
-
"aria-label":
|
|
388
|
-
onClick: () => void
|
|
389
|
-
disabled:
|
|
420
|
+
"aria-label": sendButtonLabel,
|
|
421
|
+
onClick: () => void onSend(),
|
|
422
|
+
disabled: sendDisabled,
|
|
390
423
|
children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-5 w-5" })
|
|
391
424
|
})
|
|
392
425
|
})]
|