From c1f4f74244cd2cc9a5454ee87aeafb19122af837 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Wed, 6 May 2026 17:37:57 +0800 Subject: [PATCH] fix(kefu): avoid chat control hydration mismatch --- web/components/kefu/chat-shell.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/components/kefu/chat-shell.tsx b/web/components/kefu/chat-shell.tsx index bee6d8d..26f8ff0 100644 --- a/web/components/kefu/chat-shell.tsx +++ b/web/components/kefu/chat-shell.tsx @@ -85,7 +85,7 @@ export function KefuChatShell() { useKefuSystemTheme() const messageListRef = useRef(null) - const [isEmbedded] = useState(() => isEmbeddedInHost()) + const [isEmbedded, setIsEmbedded] = useState(false) const [isMaximized, setIsMaximized] = useState(false) const [isCloseDialogOpen, setIsCloseDialogOpen] = useState(false) const [isClosingConversation, setIsClosingConversation] = useState(false) @@ -142,6 +142,10 @@ export function KefuChatShell() { ) const safeMessages = Array.isArray(messages) ? messages : [] + useEffect(() => { + setIsEmbedded(isEmbeddedInHost()) + }, []) + const maybeMarkConversationRead = useCallback(() => { if (!isVisible || !conversation || typeof document === "undefined") { return