@copilotz/chat-ui 0.6.4 → 0.6.5
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 +46 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -21
- package/dist/index.js.map +1 -1
- package/dist/styles.css +6 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -502,6 +502,7 @@ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
|
|
|
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
504
|
var ROOT_SPACING_CLASS = "mb-4 w-full max-w-full min-w-0";
|
|
505
|
+
var ACTION_SLOT_CLASS = "inline-flex h-9 min-w-[132px] items-center justify-end px-2 text-xs";
|
|
505
506
|
var interpolate = (template, replacements) => Object.entries(replacements).reduce(
|
|
506
507
|
(output, [key, value]) => output.replaceAll(`{{${key}}}`, String(value ?? "")),
|
|
507
508
|
template
|
|
@@ -576,15 +577,15 @@ var ActivitySummaryRow = memo(function ActivitySummaryRow2({
|
|
|
576
577
|
hasDetails,
|
|
577
578
|
open
|
|
578
579
|
}) {
|
|
579
|
-
if (!hasDetails) {
|
|
580
|
-
return /* @__PURE__ */ jsx7("div", { className: "block w-full min-w-0", children: /* @__PURE__ */ jsx7(ActivitySummaryCard, { activity, labels }) });
|
|
581
|
-
}
|
|
582
580
|
return /* @__PURE__ */ jsxs2("div", { className: "grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2", children: [
|
|
583
581
|
/* @__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: "
|
|
582
|
+
hasDetails ? /* @__PURE__ */ jsx7(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "ghost", size: "sm", className: cn(ACTION_SLOT_CLASS, "shrink-0 text-muted-foreground"), children: [
|
|
585
583
|
open ? labels?.activityHideDetails || "Hide details" : labels?.activityShowDetails || "Show details",
|
|
586
584
|
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
|
-
] }) })
|
|
585
|
+
] }) }) : /* @__PURE__ */ jsxs2("div", { "aria-hidden": "true", className: cn(ACTION_SLOT_CLASS, "pointer-events-none invisible shrink-0"), children: [
|
|
586
|
+
labels?.activityShowDetails || "Show details",
|
|
587
|
+
/* @__PURE__ */ jsx7(ChevronRight, { className: "ml-1 h-3.5 w-3.5" })
|
|
588
|
+
] })
|
|
588
589
|
] });
|
|
589
590
|
});
|
|
590
591
|
var ActivityDetails = memo(function ActivityDetails2({
|
|
@@ -648,21 +649,26 @@ var AssistantActivity = memo(function AssistantActivity2({
|
|
|
648
649
|
setOpen(true);
|
|
649
650
|
}
|
|
650
651
|
}, [activity.isActive, hasDetails]);
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
652
|
+
return /* @__PURE__ */ jsx7(
|
|
653
|
+
Collapsible,
|
|
654
|
+
{
|
|
655
|
+
open: hasDetails ? open : false,
|
|
656
|
+
onOpenChange: hasDetails ? setOpen : void 0,
|
|
657
|
+
className: ROOT_SPACING_CLASS,
|
|
658
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
659
|
+
/* @__PURE__ */ jsx7(
|
|
660
|
+
ActivitySummaryRow,
|
|
661
|
+
{
|
|
662
|
+
activity,
|
|
663
|
+
labels,
|
|
664
|
+
hasDetails,
|
|
665
|
+
open
|
|
666
|
+
}
|
|
667
|
+
),
|
|
668
|
+
hasDetails && /* @__PURE__ */ jsx7(CollapsibleContent2, { className: "w-full overflow-hidden rounded-lg border border-border/60 bg-muted/10 px-3", children: /* @__PURE__ */ jsx7(ActivityDetails, { activity }) })
|
|
669
|
+
] })
|
|
670
|
+
}
|
|
671
|
+
);
|
|
666
672
|
});
|
|
667
673
|
|
|
668
674
|
// src/components/chat/Message.tsx
|
|
@@ -5073,6 +5079,25 @@ function getMessageSpeakerKey(message) {
|
|
|
5073
5079
|
}
|
|
5074
5080
|
return message.role;
|
|
5075
5081
|
}
|
|
5082
|
+
function getAssistantSpeakerTokens(message) {
|
|
5083
|
+
if (!message || message.role !== "assistant") return [];
|
|
5084
|
+
const rawTokens = [message.senderAgentId, message.senderName].filter((value) => typeof value === "string" && value.trim().length > 0).map((value) => value.trim().toLowerCase());
|
|
5085
|
+
if (rawTokens.length > 0) {
|
|
5086
|
+
return Array.from(new Set(rawTokens));
|
|
5087
|
+
}
|
|
5088
|
+
return ["assistant"];
|
|
5089
|
+
}
|
|
5090
|
+
function canGroupMessages(previous, next) {
|
|
5091
|
+
if (previous.role !== next.role) {
|
|
5092
|
+
return false;
|
|
5093
|
+
}
|
|
5094
|
+
if (previous.role !== "assistant") {
|
|
5095
|
+
return getMessageSpeakerKey(previous) === getMessageSpeakerKey(next);
|
|
5096
|
+
}
|
|
5097
|
+
const previousTokens = getAssistantSpeakerTokens(previous);
|
|
5098
|
+
const nextTokens = getAssistantSpeakerTokens(next);
|
|
5099
|
+
return previousTokens.some((token) => nextTokens.includes(token));
|
|
5100
|
+
}
|
|
5076
5101
|
var mergeToolCalls = (activities) => {
|
|
5077
5102
|
const merged = /* @__PURE__ */ new Map();
|
|
5078
5103
|
for (const activity of activities) {
|
|
@@ -5138,7 +5163,7 @@ var groupMessagesForRender = (messages) => {
|
|
|
5138
5163
|
for (let index = 1; index < messages.length; index++) {
|
|
5139
5164
|
const previous = currentGroup[currentGroup.length - 1];
|
|
5140
5165
|
const next = messages[index];
|
|
5141
|
-
if (
|
|
5166
|
+
if (canGroupMessages(previous, next)) {
|
|
5142
5167
|
currentGroup.push(next);
|
|
5143
5168
|
continue;
|
|
5144
5169
|
}
|