@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.js CHANGED
@@ -501,6 +501,7 @@ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
501
501
  // src/components/chat/AssistantActivity.tsx
502
502
  import { Brain, ChevronDown, ChevronRight, LoaderCircle, Sparkles, Wrench } from "lucide-react";
503
503
  import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
504
+ var ROOT_SPACING_CLASS = "mb-4 w-full max-w-full min-w-0";
504
505
  var interpolate = (template, replacements) => Object.entries(replacements).reduce(
505
506
  (output, [key, value]) => output.replaceAll(`{{${key}}}`, String(value ?? "")),
506
507
  template
@@ -528,45 +529,65 @@ var resolveSummaryLabel = (activity, labels) => {
528
529
  }
529
530
  return labels?.activityThinking || "Thinking...";
530
531
  };
531
- var getStatusIcon = (toolCall) => {
532
+ var getStatusBadge = (toolCall) => {
532
533
  if (toolCall.status === "failed") {
533
534
  return /* @__PURE__ */ jsx7(Badge, { variant: "destructive", children: "failed" });
534
535
  }
535
536
  if (toolCall.status === "completed") {
536
- return /* @__PURE__ */ jsx7(Badge, { variant: "secondary", className: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300", children: "done" });
537
+ return /* @__PURE__ */ jsx7(
538
+ Badge,
539
+ {
540
+ variant: "secondary",
541
+ className: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",
542
+ children: "done"
543
+ }
544
+ );
537
545
  }
538
546
  if (toolCall.status === "running") {
539
547
  return /* @__PURE__ */ jsx7(Badge, { variant: "secondary", className: "bg-primary/10 text-primary", children: "running" });
540
548
  }
541
549
  return /* @__PURE__ */ jsx7(Badge, { variant: "secondary", children: "pending" });
542
550
  };
543
- var AssistantActivitySkeleton = memo(function AssistantActivitySkeleton2() {
544
- return /* @__PURE__ */ jsxs2("div", { className: "mb-4 flex items-center gap-3 rounded-lg border border-border/50 bg-muted/20 px-3 py-2", children: [
545
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1.5", children: [
546
- /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/80 animate-pulse" }),
547
- /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/60 animate-pulse [animation-delay:120ms]" }),
548
- /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40 animate-pulse [animation-delay:240ms]" })
549
- ] }),
550
- /* @__PURE__ */ jsx7("div", { className: "h-3 w-28 rounded-full bg-muted animate-pulse" })
551
- ] });
552
- });
553
- var AssistantActivitySummary = memo(function AssistantActivitySummary2({
551
+ var ActivitySummaryCard = memo(function ActivitySummaryCard2({
554
552
  activity,
555
553
  labels
556
554
  }) {
557
- const summaryLabel = useMemo(() => resolveSummaryLabel(activity, labels), [activity, labels]);
555
+ const label = useMemo(() => resolveSummaryLabel(activity, labels), [activity, labels]);
558
556
  const isActive = activity.isActive;
559
557
  const icon = activity.summary.kind === "using_tools" ? /* @__PURE__ */ jsx7(Wrench, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") }) : activity.summary.kind === "preparing_answer" ? /* @__PURE__ */ jsx7(Sparkles, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") }) : /* @__PURE__ */ jsx7(Brain, { className: cn("h-4 w-4 shrink-0", isActive ? "text-primary" : "text-muted-foreground") });
560
- return /* @__PURE__ */ jsxs2("div", { className: cn(
561
- "flex w-full min-w-0 items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors",
562
- isActive ? "border-primary/30 bg-primary/5 text-foreground" : "border-border/60 bg-muted/20 text-muted-foreground"
563
- ), children: [
564
- icon,
565
- /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate", children: summaryLabel }),
566
- isActive && /* @__PURE__ */ jsx7(LoaderCircle, { className: "h-4 w-4 shrink-0 animate-spin text-primary" })
558
+ return /* @__PURE__ */ jsxs2(
559
+ "div",
560
+ {
561
+ className: cn(
562
+ "flex w-full min-w-0 items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors",
563
+ isActive ? "border-primary/30 bg-primary/5 text-foreground" : "border-border/60 bg-muted/20 text-muted-foreground"
564
+ ),
565
+ children: [
566
+ icon,
567
+ /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate", children: label }),
568
+ isActive && /* @__PURE__ */ jsx7(LoaderCircle, { className: "h-4 w-4 shrink-0 animate-spin text-primary" })
569
+ ]
570
+ }
571
+ );
572
+ });
573
+ var ActivitySummaryRow = memo(function ActivitySummaryRow2({
574
+ activity,
575
+ labels,
576
+ hasDetails,
577
+ open
578
+ }) {
579
+ if (!hasDetails) {
580
+ return /* @__PURE__ */ jsx7("div", { className: "block w-full min-w-0", children: /* @__PURE__ */ jsx7(ActivitySummaryCard, { activity, labels }) });
581
+ }
582
+ return /* @__PURE__ */ jsxs2("div", { className: "grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2", children: [
583
+ /* @__PURE__ */ jsx7("div", { className: "min-w-0", children: /* @__PURE__ */ jsx7(ActivitySummaryCard, { activity, labels }) }),
584
+ /* @__PURE__ */ jsx7(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "ghost", size: "sm", className: "h-9 shrink-0 px-2 text-xs text-muted-foreground", children: [
585
+ open ? labels?.activityHideDetails || "Hide details" : labels?.activityShowDetails || "Show details",
586
+ open ? /* @__PURE__ */ jsx7(ChevronDown, { className: "ml-1 h-3.5 w-3.5" }) : /* @__PURE__ */ jsx7(ChevronRight, { className: "ml-1 h-3.5 w-3.5" })
587
+ ] }) })
567
588
  ] });
568
589
  });
569
- var AssistantActivityDetails = memo(function AssistantActivityDetails2({
590
+ var ActivityDetails = memo(function ActivityDetails2({
570
591
  activity
571
592
  }) {
572
593
  return /* @__PURE__ */ jsxs2("div", { className: "space-y-3 pt-3", children: [
@@ -579,7 +600,7 @@ var AssistantActivityDetails = memo(function AssistantActivityDetails2({
579
600
  activity.toolCalls.map((toolCall) => /* @__PURE__ */ jsx7(Card, { className: "border-border/60 bg-background/70", children: /* @__PURE__ */ jsxs2(CardContent, { className: "space-y-2 px-3 py-3", children: [
580
601
  /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-3", children: [
581
602
  /* @__PURE__ */ jsx7("div", { className: "min-w-0", children: /* @__PURE__ */ jsx7("div", { className: "truncate text-sm font-medium", children: toolCall.name }) }),
582
- getStatusIcon(toolCall)
603
+ getStatusBadge(toolCall)
583
604
  ] }),
584
605
  /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
585
606
  /* @__PURE__ */ jsxs2("div", { children: [
@@ -595,6 +616,16 @@ var AssistantActivityDetails = memo(function AssistantActivityDetails2({
595
616
  ] })
596
617
  ] });
597
618
  });
619
+ var ActivitySkeleton = memo(function ActivitySkeleton2() {
620
+ return /* @__PURE__ */ jsx7("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ jsxs2("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: [
621
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1.5", children: [
622
+ /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/80 animate-pulse" }),
623
+ /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/60 animate-pulse [animation-delay:120ms]" }),
624
+ /* @__PURE__ */ jsx7("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40 animate-pulse [animation-delay:240ms]" })
625
+ ] }),
626
+ /* @__PURE__ */ jsx7("div", { className: "h-3 w-28 rounded-full bg-muted animate-pulse" })
627
+ ] }) });
628
+ });
598
629
  var AssistantActivity = memo(function AssistantActivity2({
599
630
  activity,
600
631
  displayMode,
@@ -602,30 +633,36 @@ var AssistantActivity = memo(function AssistantActivity2({
602
633
  }) {
603
634
  if (!activity) return null;
604
635
  if (displayMode === "hidden") {
605
- return activity.isActive ? /* @__PURE__ */ jsx7(AssistantActivitySkeleton, {}) : null;
636
+ return activity.isActive ? /* @__PURE__ */ jsx7(ActivitySkeleton, {}) : null;
606
637
  }
607
638
  if (displayMode === "summary") {
608
- if (!activity.isActive && activity.isComplete) return null;
609
- return /* @__PURE__ */ jsx7("div", { className: "mb-4 w-full", children: /* @__PURE__ */ jsx7(AssistantActivitySummary, { activity, labels }) });
639
+ if (!activity.isActive && activity.isComplete) {
640
+ return null;
641
+ }
642
+ return /* @__PURE__ */ jsx7("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ jsx7(ActivitySummaryCard, { activity, labels }) });
610
643
  }
611
644
  const hasDetails = Boolean(activity.reasoning) || Boolean(activity.toolCalls?.length);
612
- const defaultOpen = activity.isActive && hasDetails;
613
- const [open, setOpen] = useState(defaultOpen);
645
+ const [open, setOpen] = useState(activity.isActive && hasDetails);
614
646
  useEffect(() => {
615
647
  if (activity.isActive && hasDetails) {
616
648
  setOpen(true);
617
649
  }
618
650
  }, [activity.isActive, hasDetails]);
619
- return /* @__PURE__ */ jsx7("div", { className: "mb-4 w-full", children: /* @__PURE__ */ jsx7(Collapsible, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
620
- /* @__PURE__ */ jsxs2("div", { className: "grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-2", children: [
621
- /* @__PURE__ */ jsx7("div", { className: "min-w-0 w-full", children: /* @__PURE__ */ jsx7(AssistantActivitySummary, { activity, labels }) }),
622
- hasDetails && /* @__PURE__ */ jsx7(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "ghost", size: "sm", className: "h-9 shrink-0 px-2 text-xs text-muted-foreground", children: [
623
- open ? labels?.activityHideDetails || "Hide details" : labels?.activityShowDetails || "Show details",
624
- open ? /* @__PURE__ */ jsx7(ChevronDown, { className: "ml-1 h-3.5 w-3.5" }) : /* @__PURE__ */ jsx7(ChevronRight, { className: "ml-1 h-3.5 w-3.5" })
625
- ] }) })
626
- ] }),
627
- hasDetails && /* @__PURE__ */ jsx7(CollapsibleContent2, { className: "overflow-hidden rounded-lg border border-border/60 bg-muted/10 px-3", children: /* @__PURE__ */ jsx7(AssistantActivityDetails, { activity }) })
628
- ] }) }) });
651
+ if (!hasDetails) {
652
+ return /* @__PURE__ */ jsx7("div", { className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ jsx7(ActivitySummaryCard, { activity, labels }) });
653
+ }
654
+ return /* @__PURE__ */ jsx7(Collapsible, { open, onOpenChange: setOpen, className: ROOT_SPACING_CLASS, children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
655
+ /* @__PURE__ */ jsx7(
656
+ ActivitySummaryRow,
657
+ {
658
+ activity,
659
+ labels,
660
+ hasDetails,
661
+ open
662
+ }
663
+ ),
664
+ /* @__PURE__ */ jsx7(CollapsibleContent2, { className: "w-full overflow-hidden rounded-lg border border-border/60 bg-muted/10 px-3", children: /* @__PURE__ */ jsx7(ActivityDetails, { activity }) })
665
+ ] }) });
629
666
  });
630
667
 
631
668
  // src/components/chat/Message.tsx