@copilotz/chat-ui 0.6.7 → 0.7.0
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 +28 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -757,8 +757,7 @@ var StreamingText = memo2(function StreamingText2({
|
|
|
757
757
|
className = "",
|
|
758
758
|
renderMarkdown = true,
|
|
759
759
|
markdown,
|
|
760
|
-
plainTextChunkChars = 12e3
|
|
761
|
-
contentStyle
|
|
760
|
+
plainTextChunkChars = 12e3
|
|
762
761
|
}) {
|
|
763
762
|
const hasContent = content.trim().length > 0;
|
|
764
763
|
const enableSyntaxHighlight = renderMarkdown && !isStreaming && hasCodeBlocks(content);
|
|
@@ -788,7 +787,6 @@ var StreamingText = memo2(function StreamingText2({
|
|
|
788
787
|
LongContentShell,
|
|
789
788
|
{
|
|
790
789
|
className: `prose prose-sm max-w-none dark:prose-invert break-words ${className}`.trim(),
|
|
791
|
-
style: contentStyle,
|
|
792
790
|
children: /* @__PURE__ */ jsx8(
|
|
793
791
|
ReactMarkdown,
|
|
794
792
|
{
|
|
@@ -804,8 +802,7 @@ var StreamingText = memo2(function StreamingText2({
|
|
|
804
802
|
{
|
|
805
803
|
content,
|
|
806
804
|
className,
|
|
807
|
-
chunkSize: plainTextChunkChars
|
|
808
|
-
style: contentStyle
|
|
805
|
+
chunkSize: plainTextChunkChars
|
|
809
806
|
}
|
|
810
807
|
) : null,
|
|
811
808
|
isStreaming && hasContent && /* @__PURE__ */ jsx8("span", { className: "inline-block w-2 h-4 bg-primary animate-pulse ml-1" })
|
|
@@ -955,11 +952,6 @@ var Message = memo2(({
|
|
|
955
952
|
const isCollapsed = canCollapseMessage && !isExpanded;
|
|
956
953
|
const contentToRender = isCollapsed ? getCollapsedPreview(message.content, normalizedPreviewChars, previewOverride) : message.content;
|
|
957
954
|
const shouldRenderMarkdown = !isCollapsed && (!messageIsUser || renderUserMarkdown);
|
|
958
|
-
const shouldApplyLargeContentContainment = !isCollapsed && message.content.length > normalizedChunkChars;
|
|
959
|
-
const contentStyle = shouldApplyLargeContentContainment ? {
|
|
960
|
-
contentVisibility: "auto",
|
|
961
|
-
containIntrinsicSize: "1px 400px"
|
|
962
|
-
} : void 0;
|
|
963
955
|
const horizontalOffsetClass = showAvatar ? messageIsUser ? compactMode ? "mr-9" : "mr-11" : compactMode ? "ml-9" : "ml-11" : "";
|
|
964
956
|
const handleCopy = async () => {
|
|
965
957
|
try {
|
|
@@ -1070,8 +1062,7 @@ var Message = memo2(({
|
|
|
1070
1062
|
isStreaming: message.isStreaming,
|
|
1071
1063
|
renderMarkdown: shouldRenderMarkdown,
|
|
1072
1064
|
markdown,
|
|
1073
|
-
plainTextChunkChars: normalizedChunkChars
|
|
1074
|
-
contentStyle
|
|
1065
|
+
plainTextChunkChars: normalizedChunkChars
|
|
1075
1066
|
}
|
|
1076
1067
|
),
|
|
1077
1068
|
canCollapseMessage && /* @__PURE__ */ jsx8("div", { className: "mt-3", children: /* @__PURE__ */ jsx8(
|
|
@@ -5350,6 +5341,7 @@ var ChatUI = ({
|
|
|
5350
5341
|
const virtualizer = useVirtualizer({
|
|
5351
5342
|
count: groupedMessages.length,
|
|
5352
5343
|
getScrollElement: () => scrollAreaRef.current,
|
|
5344
|
+
getItemKey: (index) => groupedMessages[index]?.id ?? index,
|
|
5353
5345
|
estimateSize: () => 100,
|
|
5354
5346
|
overscan: 5
|
|
5355
5347
|
});
|
|
@@ -5418,8 +5410,29 @@ var ChatUI = ({
|
|
|
5418
5410
|
});
|
|
5419
5411
|
}, [groupedMessages, state.isAtBottom, virtualizer]);
|
|
5420
5412
|
useEffect11(() => {
|
|
5421
|
-
|
|
5422
|
-
|
|
5413
|
+
const viewport = scrollAreaRef.current;
|
|
5414
|
+
if (!viewport) return;
|
|
5415
|
+
let rafId;
|
|
5416
|
+
const ro = new ResizeObserver(() => {
|
|
5417
|
+
cancelAnimationFrame(rafId);
|
|
5418
|
+
rafId = requestAnimationFrame(() => {
|
|
5419
|
+
const elements = virtualizer.elementsCache;
|
|
5420
|
+
if (elements) {
|
|
5421
|
+
elements.forEach((node) => {
|
|
5422
|
+
if (node.isConnected) {
|
|
5423
|
+
virtualizer.observer?.unobserve(node);
|
|
5424
|
+
virtualizer.observer?.observe(node);
|
|
5425
|
+
}
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
});
|
|
5429
|
+
});
|
|
5430
|
+
ro.observe(viewport);
|
|
5431
|
+
return () => {
|
|
5432
|
+
cancelAnimationFrame(rafId);
|
|
5433
|
+
ro.disconnect();
|
|
5434
|
+
};
|
|
5435
|
+
}, [virtualizer]);
|
|
5423
5436
|
useEffect11(() => {
|
|
5424
5437
|
prependSnapshotRef.current = null;
|
|
5425
5438
|
}, [currentThreadId]);
|
|
@@ -5776,7 +5789,7 @@ var ChatUI = ({
|
|
|
5776
5789
|
className: "flex-1 min-h-0",
|
|
5777
5790
|
viewportClassName: "p-4 overscroll-contain",
|
|
5778
5791
|
onScrollCapture: handleScroll,
|
|
5779
|
-
style: { contain: "
|
|
5792
|
+
style: { contain: "content" },
|
|
5780
5793
|
children: /* @__PURE__ */ jsxs17("div", { className: "max-w-4xl mx-auto pb-4", children: [
|
|
5781
5794
|
groupedMessages.length > 0 && /* @__PURE__ */ jsx27("div", { className: "flex justify-center py-2", children: isLoadingOlderMessages ? /* @__PURE__ */ jsx27("span", { className: "text-xs text-muted-foreground", children: config.labels.loadingOlderMessages }) : hasMoreMessagesBefore ? /* @__PURE__ */ jsx27(
|
|
5782
5795
|
"button",
|