@copilotz/chat-ui 0.1.23 → 0.1.25
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 +31 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +56 -111
- package/dist/index.js.map +1 -1
- package/dist/styles.css +22 -41
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -630,88 +630,35 @@ var ThinkingIndicator = (0, import_react.memo)(function ThinkingIndicator2({ lab
|
|
|
630
630
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-sm text-muted-foreground animate-pulse", children: label })
|
|
631
631
|
] });
|
|
632
632
|
});
|
|
633
|
-
var ThinkingBlock = (0, import_react.memo)(function ThinkingBlock2({
|
|
634
|
-
const [
|
|
635
|
-
const [thinkingActive, setThinkingActive] = (0, import_react.useState)(false);
|
|
636
|
-
const contentLenRef = (0, import_react.useRef)(0);
|
|
633
|
+
var ThinkingBlock = (0, import_react.memo)(function ThinkingBlock2({ reasoning, isStreaming = false, label = "Thinking..." }) {
|
|
634
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(isStreaming);
|
|
637
635
|
(0, import_react.useEffect)(() => {
|
|
638
|
-
if (
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
643
|
-
if (content.length > contentLenRef.current) {
|
|
644
|
-
contentLenRef.current = content.length;
|
|
645
|
-
setThinkingActive(true);
|
|
646
|
-
}
|
|
647
|
-
}, [content.length, isStreaming]);
|
|
648
|
-
(0, import_react.useEffect)(() => {
|
|
649
|
-
if (!thinkingActive || !isStreaming) return;
|
|
650
|
-
const timer = setTimeout(() => setThinkingActive(false), 1e3);
|
|
651
|
-
return () => clearTimeout(timer);
|
|
652
|
-
}, [thinkingActive, isStreaming, content.length]);
|
|
653
|
-
(0, import_react.useEffect)(() => {
|
|
654
|
-
if (isStreaming && content.length > 0) setOpen(true);
|
|
655
|
-
}, [isStreaming, content.length]);
|
|
656
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mb-3 relative rounded-lg overflow-hidden", children: [
|
|
657
|
-
thinkingActive && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
658
|
-
"div",
|
|
659
|
-
{
|
|
660
|
-
className: "absolute inset-0 rounded-lg pointer-events-none",
|
|
661
|
-
style: {
|
|
662
|
-
padding: "1px",
|
|
663
|
-
background: "linear-gradient(135deg, hsl(var(--primary) / 0.4), hsl(var(--muted-foreground) / 0.2), hsl(var(--primary) / 0.4))",
|
|
664
|
-
backgroundSize: "200% 200%",
|
|
665
|
-
animation: "thinking-shimmer 2s ease-in-out infinite"
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
),
|
|
636
|
+
if (isStreaming) setIsOpen(true);
|
|
637
|
+
}, [isStreaming]);
|
|
638
|
+
const finishedLabel = label.replace(/\.{3}$/, "");
|
|
639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `mb-3 rounded-lg border ${isStreaming ? "border-primary/40 bg-primary/5" : "border-border/60 bg-muted/30"} overflow-hidden transition-colors duration-300`, children: [
|
|
669
640
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
670
|
-
"
|
|
641
|
+
"button",
|
|
671
642
|
{
|
|
672
|
-
|
|
673
|
-
|
|
643
|
+
type: "button",
|
|
644
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-left text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",
|
|
645
|
+
onClick: () => setIsOpen(!isOpen),
|
|
674
646
|
children: [
|
|
675
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "flex-1", children: [
|
|
684
|
-
label,
|
|
685
|
-
thinkingActive && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "ml-1 inline-flex gap-0.5", children: [
|
|
686
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-current rounded-full animate-bounce", style: { animationDelay: "0ms" } }),
|
|
687
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-current rounded-full animate-bounce", style: { animationDelay: "150ms" } }),
|
|
688
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-current rounded-full animate-bounce", style: { animationDelay: "300ms" } })
|
|
689
|
-
] })
|
|
690
|
-
] }),
|
|
691
|
-
open ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronRight, { className: "h-3 w-3" })
|
|
692
|
-
]
|
|
693
|
-
}
|
|
694
|
-
),
|
|
695
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "px-3 pb-3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "border-l-2 border-muted-foreground/20 pl-3", children: [
|
|
696
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
697
|
-
PlainTextContent,
|
|
698
|
-
{
|
|
699
|
-
content,
|
|
700
|
-
className: "text-xs text-muted-foreground/80 leading-5",
|
|
701
|
-
chunkSize
|
|
702
|
-
}
|
|
703
|
-
),
|
|
704
|
-
thinkingActive && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1.5 h-3 bg-muted-foreground/40 animate-pulse ml-0.5" })
|
|
705
|
-
] }) })
|
|
647
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.Brain, { className: `h-4 w-4 flex-shrink-0 ${isStreaming ? "text-primary animate-pulse" : "text-muted-foreground"}` }),
|
|
648
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex-1", children: isStreaming ? label : finishedLabel }),
|
|
649
|
+
isStreaming && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex gap-0.5 mr-1", children: [
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-primary rounded-full animate-bounce", style: { animationDelay: "0ms" } }),
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-primary rounded-full animate-bounce", style: { animationDelay: "150ms" } }),
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1 h-1 bg-primary rounded-full animate-bounce", style: { animationDelay: "300ms" } })
|
|
653
|
+
] }),
|
|
654
|
+
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronDown, { className: "h-3 w-3 flex-shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react.ChevronRight, { className: "h-3 w-3 flex-shrink-0" })
|
|
706
655
|
]
|
|
707
656
|
}
|
|
708
657
|
),
|
|
709
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
` })
|
|
658
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "px-3 pb-3 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap break-words border-t border-border/40", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "pt-2", children: [
|
|
659
|
+
reasoning,
|
|
660
|
+
isStreaming && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5" })
|
|
661
|
+
] }) })
|
|
715
662
|
] });
|
|
716
663
|
});
|
|
717
664
|
var markdownComponents = {
|
|
@@ -780,7 +727,8 @@ var StreamingText = (0, import_react.memo)(function StreamingText2({
|
|
|
780
727
|
className = "",
|
|
781
728
|
renderMarkdown = true,
|
|
782
729
|
plainTextChunkChars = 12e3,
|
|
783
|
-
contentStyle
|
|
730
|
+
contentStyle,
|
|
731
|
+
hideThinkingIndicator = false
|
|
784
732
|
}) {
|
|
785
733
|
const hasContent = content.trim().length > 0;
|
|
786
734
|
const enableSyntaxHighlight = renderMarkdown && !isStreaming && hasCodeBlocks(content);
|
|
@@ -808,10 +756,7 @@ var StreamingText = (0, import_react.memo)(function StreamingText2({
|
|
|
808
756
|
chunkSize: plainTextChunkChars,
|
|
809
757
|
style: contentStyle
|
|
810
758
|
}
|
|
811
|
-
) : isStreaming ? (
|
|
812
|
-
// Show thinking indicator while waiting for first token
|
|
813
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingIndicator, { label: thinkingLabel })
|
|
814
|
-
) : null,
|
|
759
|
+
) : isStreaming && !hideThinkingIndicator ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingIndicator, { label: thinkingLabel }) : null,
|
|
815
760
|
isStreaming && hasContent && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "inline-block w-2 h-4 bg-primary animate-pulse ml-1" })
|
|
816
761
|
] });
|
|
817
762
|
});
|
|
@@ -1104,13 +1049,12 @@ var Message = (0, import_react.memo)(({
|
|
|
1104
1049
|
] })
|
|
1105
1050
|
] })
|
|
1106
1051
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1107
|
-
!messageIsUser && message.reasoning &&
|
|
1052
|
+
!messageIsUser && message.reasoning && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1108
1053
|
ThinkingBlock,
|
|
1109
1054
|
{
|
|
1110
|
-
|
|
1111
|
-
isStreaming: message.
|
|
1112
|
-
label: thinkingLabel
|
|
1113
|
-
chunkSize: normalizedChunkChars
|
|
1055
|
+
reasoning: message.reasoning,
|
|
1056
|
+
isStreaming: message.isReasoningStreaming,
|
|
1057
|
+
label: thinkingLabel
|
|
1114
1058
|
}
|
|
1115
1059
|
),
|
|
1116
1060
|
enableToolCallsDisplay && message.toolCalls && message.toolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ToolCallsDisplay, { toolCalls: message.toolCalls, label: toolUsedLabel }) }),
|
|
@@ -1122,7 +1066,8 @@ var Message = (0, import_react.memo)(({
|
|
|
1122
1066
|
thinkingLabel,
|
|
1123
1067
|
renderMarkdown: shouldRenderMarkdown,
|
|
1124
1068
|
plainTextChunkChars: normalizedChunkChars,
|
|
1125
|
-
contentStyle
|
|
1069
|
+
contentStyle,
|
|
1070
|
+
hideThinkingIndicator: !!message.reasoning
|
|
1126
1071
|
}
|
|
1127
1072
|
),
|
|
1128
1073
|
canCollapseMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|