@copilotz/chat-ui 0.6.3 → 0.6.4
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.cjs +75 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -38
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -542,6 +542,7 @@ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
|
|
|
542
542
|
// src/components/chat/AssistantActivity.tsx
|
|
543
543
|
var import_lucide_react = require("lucide-react");
|
|
544
544
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
545
|
+
var ROOT_SPACING_CLASS = "mb-4 w-full max-w-full min-w-0";
|
|
545
546
|
var interpolate = (template, replacements) => Object.entries(replacements).reduce(
|
|
546
547
|
(output, [key, value]) => output.replaceAll(`{{${key}}}`, String(value ?? "")),
|
|
547
548
|
template
|
|
@@ -569,45 +570,65 @@ var resolveSummaryLabel = (activity, labels) => {
|
|
|
569
570
|
}
|
|
570
571
|
return labels?.activityThinking || "Thinking...";
|
|
571
572
|
};
|
|
572
|
-
var
|
|
573
|
+
var getStatusBadge = (toolCall) => {
|
|
573
574
|
if (toolCall.status === "failed") {
|
|
574
575
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { variant: "destructive", children: "failed" });
|
|
575
576
|
}
|
|
576
577
|
if (toolCall.status === "completed") {
|
|
577
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
578
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
579
|
+
Badge,
|
|
580
|
+
{
|
|
581
|
+
variant: "secondary",
|
|
582
|
+
className: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",
|
|
583
|
+
children: "done"
|
|
584
|
+
}
|
|
585
|
+
);
|
|
578
586
|
}
|
|
579
587
|
if (toolCall.status === "running") {
|
|
580
588
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { variant: "secondary", className: "bg-primary/10 text-primary", children: "running" });
|
|
581
589
|
}
|
|
582
590
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { variant: "secondary", children: "pending" });
|
|
583
591
|
};
|
|
584
|
-
var
|
|
585
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mb-4 flex items-center gap-3 rounded-lg border border-border/50 bg-muted/20 px-3 py-2", children: [
|
|
586
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
587
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/80 animate-pulse" }),
|
|
588
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/60 animate-pulse [animation-delay:120ms]" }),
|
|
589
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40 animate-pulse [animation-delay:240ms]" })
|
|
590
|
-
] }),
|
|
591
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "h-3 w-28 rounded-full bg-muted animate-pulse" })
|
|
592
|
-
] });
|
|
593
|
-
});
|
|
594
|
-
var AssistantActivitySummary = (0, import_react.memo)(function AssistantActivitySummary2({
|
|
592
|
+
var ActivitySummaryCard = (0, import_react.memo)(function ActivitySummaryCard2({
|
|
595
593
|
activity,
|
|
596
594
|
labels
|
|
597
595
|
}) {
|
|
598
|
-
const
|
|
596
|
+
const label = (0, import_react.useMemo)(() => resolveSummaryLabel(activity, labels), [activity, labels]);
|
|
599
597
|
const isActive = activity.isActive;
|
|
600
598
|
const icon = activity.summary.kind === "using_tools" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.Wrench, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") }) : activity.summary.kind === "preparing_answer" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.Sparkles, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.Brain, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") });
|
|
601
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
602
|
-
"
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
600
|
+
"div",
|
|
601
|
+
{
|
|
602
|
+
className: cn(
|
|
603
|
+
"flex w-full min-w-0 items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors",
|
|
604
|
+
isActive ? "border-primary/30 bg-primary/5 text-foreground" : "border-border/60 bg-muted/20 text-muted-foreground"
|
|
605
|
+
),
|
|
606
|
+
children: [
|
|
607
|
+
icon,
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 flex-1 truncate", children: label }),
|
|
609
|
+
isActive && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.LoaderCircle, { className: "h-4 w-4 shrink-0 animate-spin text-primary" })
|
|
610
|
+
]
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
});
|
|
614
|
+
var ActivitySummaryRow = (0, import_react.memo)(function ActivitySummaryRow2({
|
|
615
|
+
activity,
|
|
616
|
+
labels,
|
|
617
|
+
hasDetails,
|
|
618
|
+
open
|
|
619
|
+
}) {
|
|
620
|
+
if (!hasDetails) {
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "block w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivitySummaryCard, { activity, labels }) });
|
|
622
|
+
}
|
|
623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2", children: [
|
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivitySummaryCard, { activity, labels }) }),
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Button, { variant: "ghost", size: "sm", className: "h-9 shrink-0 px-2 text-xs text-muted-foreground", children: [
|
|
626
|
+
open ? labels?.activityHideDetails || "Hide details" : labels?.activityShowDetails || "Show details",
|
|
627
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronDown, { className: "ml-1 h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronRight, { className: "ml-1 h-3.5 w-3.5" })
|
|
628
|
+
] }) })
|
|
608
629
|
] });
|
|
609
630
|
});
|
|
610
|
-
var
|
|
631
|
+
var ActivityDetails = (0, import_react.memo)(function ActivityDetails2({
|
|
611
632
|
activity
|
|
612
633
|
}) {
|
|
613
634
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3 pt-3", children: [
|
|
@@ -620,7 +641,7 @@ var AssistantActivityDetails = (0, import_react.memo)(function AssistantActivity
|
|
|
620
641
|
activity.toolCalls.map((toolCall) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Card, { className: "border-border/60 bg-background/70", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(CardContent, { className: "space-y-2 px-3 py-3", children: [
|
|
621
642
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
622
643
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "truncate text-sm font-medium", children: toolCall.name }) }),
|
|
623
|
-
|
|
644
|
+
getStatusBadge(toolCall)
|
|
624
645
|
] }),
|
|
625
646
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
|
|
626
647
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
@@ -636,6 +657,16 @@ var AssistantActivityDetails = (0, import_react.memo)(function AssistantActivity
|
|
|
636
657
|
] })
|
|
637
658
|
] });
|
|
638
659
|
});
|
|
660
|
+
var ActivitySkeleton = (0, import_react.memo)(function ActivitySkeleton2() {
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex w-full min-w-0 items-center gap-3 rounded-lg border border-border/50 bg-muted/20 px-3 py-2", children: [
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/80 animate-pulse" }),
|
|
664
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/60 animate-pulse [animation-delay:120ms]" }),
|
|
665
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40 animate-pulse [animation-delay:240ms]" })
|
|
666
|
+
] }),
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "h-3 w-28 rounded-full bg-muted animate-pulse" })
|
|
668
|
+
] }) });
|
|
669
|
+
});
|
|
639
670
|
var AssistantActivity = (0, import_react.memo)(function AssistantActivity2({
|
|
640
671
|
activity,
|
|
641
672
|
displayMode,
|
|
@@ -643,30 +674,36 @@ var AssistantActivity = (0, import_react.memo)(function AssistantActivity2({
|
|
|
643
674
|
}) {
|
|
644
675
|
if (!activity) return null;
|
|
645
676
|
if (displayMode === "hidden") {
|
|
646
|
-
return activity.isActive ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
677
|
+
return activity.isActive ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivitySkeleton, {}) : null;
|
|
647
678
|
}
|
|
648
679
|
if (displayMode === "summary") {
|
|
649
|
-
if (!activity.isActive && activity.isComplete)
|
|
650
|
-
|
|
680
|
+
if (!activity.isActive && activity.isComplete) {
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivitySummaryCard, { activity, labels }) });
|
|
651
684
|
}
|
|
652
685
|
const hasDetails = Boolean(activity.reasoning) || Boolean(activity.toolCalls?.length);
|
|
653
|
-
const
|
|
654
|
-
const [open, setOpen] = (0, import_react.useState)(defaultOpen);
|
|
686
|
+
const [open, setOpen] = (0, import_react.useState)(activity.isActive && hasDetails);
|
|
655
687
|
(0, import_react.useEffect)(() => {
|
|
656
688
|
if (activity.isActive && hasDetails) {
|
|
657
689
|
setOpen(true);
|
|
658
690
|
}
|
|
659
691
|
}, [activity.isActive, hasDetails]);
|
|
660
|
-
|
|
661
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
692
|
+
if (!hasDetails) {
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivitySummaryCard, { activity, labels }) });
|
|
694
|
+
}
|
|
695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Collapsible, { open, onOpenChange: setOpen, className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
|
|
696
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
697
|
+
ActivitySummaryRow,
|
|
698
|
+
{
|
|
699
|
+
activity,
|
|
700
|
+
labels,
|
|
701
|
+
hasDetails,
|
|
702
|
+
open
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleContent2, { className: "w-full overflow-hidden rounded-lg border border-border/60 bg-muted/10 px-3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActivityDetails, { activity }) })
|
|
706
|
+
] }) });
|
|
670
707
|
});
|
|
671
708
|
|
|
672
709
|
// src/components/chat/Message.tsx
|