@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.cjs
CHANGED
|
@@ -543,6 +543,7 @@ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
|
|
|
543
543
|
var import_lucide_react = require("lucide-react");
|
|
544
544
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
545
545
|
var ROOT_SPACING_CLASS = "mb-4 w-full max-w-full min-w-0";
|
|
546
|
+
var ACTION_SLOT_CLASS = "inline-flex h-9 min-w-[132px] items-center justify-end px-2 text-xs";
|
|
546
547
|
var interpolate = (template, replacements) => Object.entries(replacements).reduce(
|
|
547
548
|
(output, [key, value]) => output.replaceAll(`{{${key}}}`, String(value ?? "")),
|
|
548
549
|
template
|
|
@@ -617,15 +618,15 @@ var ActivitySummaryRow = (0, import_react.memo)(function ActivitySummaryRow2({
|
|
|
617
618
|
hasDetails,
|
|
618
619
|
open
|
|
619
620
|
}) {
|
|
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
621
|
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
622
|
/* @__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: "
|
|
623
|
+
hasDetails ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Button, { variant: "ghost", size: "sm", className: cn(ACTION_SLOT_CLASS, "shrink-0 text-muted-foreground"), children: [
|
|
626
624
|
open ? labels?.activityHideDetails || "Hide details" : labels?.activityShowDetails || "Show details",
|
|
627
625
|
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
|
-
] }) })
|
|
626
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "aria-hidden": "true", className: cn(ACTION_SLOT_CLASS, "pointer-events-none invisible shrink-0"), children: [
|
|
627
|
+
labels?.activityShowDetails || "Show details",
|
|
628
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronRight, { className: "ml-1 h-3.5 w-3.5" })
|
|
629
|
+
] })
|
|
629
630
|
] });
|
|
630
631
|
});
|
|
631
632
|
var ActivityDetails = (0, import_react.memo)(function ActivityDetails2({
|
|
@@ -689,21 +690,26 @@ var AssistantActivity = (0, import_react.memo)(function AssistantActivity2({
|
|
|
689
690
|
setOpen(true);
|
|
690
691
|
}
|
|
691
692
|
}, [activity.isActive, hasDetails]);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
{
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
694
|
+
Collapsible,
|
|
695
|
+
{
|
|
696
|
+
open: hasDetails ? open : false,
|
|
697
|
+
onOpenChange: hasDetails ? setOpen : void 0,
|
|
698
|
+
className: ROOT_SPACING_CLASS,
|
|
699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
|
|
700
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
701
|
+
ActivitySummaryRow,
|
|
702
|
+
{
|
|
703
|
+
activity,
|
|
704
|
+
labels,
|
|
705
|
+
hasDetails,
|
|
706
|
+
open
|
|
707
|
+
}
|
|
708
|
+
),
|
|
709
|
+
hasDetails && /* @__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 }) })
|
|
710
|
+
] })
|
|
711
|
+
}
|
|
712
|
+
);
|
|
707
713
|
});
|
|
708
714
|
|
|
709
715
|
// src/components/chat/Message.tsx
|
|
@@ -5041,6 +5047,25 @@ function getMessageSpeakerKey(message) {
|
|
|
5041
5047
|
}
|
|
5042
5048
|
return message.role;
|
|
5043
5049
|
}
|
|
5050
|
+
function getAssistantSpeakerTokens(message) {
|
|
5051
|
+
if (!message || message.role !== "assistant") return [];
|
|
5052
|
+
const rawTokens = [message.senderAgentId, message.senderName].filter((value) => typeof value === "string" && value.trim().length > 0).map((value) => value.trim().toLowerCase());
|
|
5053
|
+
if (rawTokens.length > 0) {
|
|
5054
|
+
return Array.from(new Set(rawTokens));
|
|
5055
|
+
}
|
|
5056
|
+
return ["assistant"];
|
|
5057
|
+
}
|
|
5058
|
+
function canGroupMessages(previous, next) {
|
|
5059
|
+
if (previous.role !== next.role) {
|
|
5060
|
+
return false;
|
|
5061
|
+
}
|
|
5062
|
+
if (previous.role !== "assistant") {
|
|
5063
|
+
return getMessageSpeakerKey(previous) === getMessageSpeakerKey(next);
|
|
5064
|
+
}
|
|
5065
|
+
const previousTokens = getAssistantSpeakerTokens(previous);
|
|
5066
|
+
const nextTokens = getAssistantSpeakerTokens(next);
|
|
5067
|
+
return previousTokens.some((token) => nextTokens.includes(token));
|
|
5068
|
+
}
|
|
5044
5069
|
var mergeToolCalls = (activities) => {
|
|
5045
5070
|
const merged = /* @__PURE__ */ new Map();
|
|
5046
5071
|
for (const activity of activities) {
|
|
@@ -5106,7 +5131,7 @@ var groupMessagesForRender = (messages) => {
|
|
|
5106
5131
|
for (let index = 1; index < messages.length; index++) {
|
|
5107
5132
|
const previous = currentGroup[currentGroup.length - 1];
|
|
5108
5133
|
const next = messages[index];
|
|
5109
|
-
if (
|
|
5134
|
+
if (canGroupMessages(previous, next)) {
|
|
5110
5135
|
currentGroup.push(next);
|
|
5111
5136
|
continue;
|
|
5112
5137
|
}
|