@copilotz/chat-ui 0.1.8 → 0.1.9
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 +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -836,7 +836,7 @@ var Message = memo(({
|
|
|
836
836
|
message.isEdited && /* @__PURE__ */ jsx7(Badge, { variant: "outline", className: "text-xs", children: "editado" })
|
|
837
837
|
] })
|
|
838
838
|
] }),
|
|
839
|
-
/* @__PURE__ */ jsx7("div", { className: `flex-1 min-w-0 ${messageIsUser ? "text-right" : "text-left"} ${isGrouped && showAvatar && !messageIsUser ? compactMode ? "ml-9" : "ml-11" : ""} ${isGrouped && showAvatar && messageIsUser ? compactMode ? "mr-9" : "mr-11" : ""}`, children: /* @__PURE__ */ jsxs2("div", { className: `relative inline-flex flex-col overflow-hidden ${messageIsUser ? "rounded-lg p-3 bg-primary text-primary-foreground ml-auto max-w-[85%]" : "max-w-full"}`, children: [
|
|
839
|
+
/* @__PURE__ */ jsx7("div", { className: `flex-1 min-w-0 ${messageIsUser ? "text-right" : "text-left"} ${isGrouped && showAvatar && !messageIsUser ? compactMode ? "ml-9" : "ml-11" : ""} ${isGrouped && showAvatar && messageIsUser ? compactMode ? "mr-9" : "mr-11" : ""}`, children: /* @__PURE__ */ jsxs2("div", { className: `relative inline-flex flex-col overflow-hidden text-left ${messageIsUser ? "rounded-lg p-3 bg-primary text-primary-foreground ml-auto max-w-[85%]" : "max-w-full"}`, children: [
|
|
840
840
|
isEditing ? /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
841
841
|
/* @__PURE__ */ jsx7(
|
|
842
842
|
Textarea,
|
|
@@ -864,8 +864,7 @@ var Message = memo(({
|
|
|
864
864
|
{
|
|
865
865
|
content: message.content,
|
|
866
866
|
isStreaming: message.isStreaming,
|
|
867
|
-
thinkingLabel
|
|
868
|
-
className: messageIsUser ? "[&_*]:text-right" : ""
|
|
867
|
+
thinkingLabel
|
|
869
868
|
}
|
|
870
869
|
),
|
|
871
870
|
message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsx7("div", { className: "mt-3 space-y-2", children: message.attachments.map((attachment, index) => /* @__PURE__ */ jsx7(MediaRenderer, { attachment }, index)) })
|
|
@@ -3834,8 +3833,23 @@ var ChatUI = ({
|
|
|
3834
3833
|
return () => clearTimeout(t);
|
|
3835
3834
|
}
|
|
3836
3835
|
}, [state.showSidebar, isMobile, config.customComponent]);
|
|
3836
|
+
const prevMessageCountRef = useRef7(0);
|
|
3837
3837
|
useEffect9(() => {
|
|
3838
|
-
if (
|
|
3838
|
+
if (messages.length === 0) {
|
|
3839
|
+
prevMessageCountRef.current = 0;
|
|
3840
|
+
return;
|
|
3841
|
+
}
|
|
3842
|
+
const wasEmpty = prevMessageCountRef.current === 0;
|
|
3843
|
+
prevMessageCountRef.current = messages.length;
|
|
3844
|
+
if (wasEmpty) {
|
|
3845
|
+
requestAnimationFrame(() => {
|
|
3846
|
+
requestAnimationFrame(() => {
|
|
3847
|
+
virtualizer.scrollToIndex(messages.length - 1, { align: "end" });
|
|
3848
|
+
});
|
|
3849
|
+
});
|
|
3850
|
+
return;
|
|
3851
|
+
}
|
|
3852
|
+
if (!state.isAtBottom) return;
|
|
3839
3853
|
requestAnimationFrame(() => {
|
|
3840
3854
|
const viewport = scrollAreaRef.current;
|
|
3841
3855
|
if (!viewport) return;
|
|
@@ -3845,7 +3859,7 @@ var ChatUI = ({
|
|
|
3845
3859
|
viewport.scrollTop = viewport.scrollHeight;
|
|
3846
3860
|
}
|
|
3847
3861
|
});
|
|
3848
|
-
}, [messages, state.isAtBottom]);
|
|
3862
|
+
}, [messages, state.isAtBottom, virtualizer]);
|
|
3849
3863
|
const handleScroll = useCallback4((e) => {
|
|
3850
3864
|
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
|
|
3851
3865
|
const isAtBottom = scrollHeight - scrollTop - clientHeight < 50;
|