Add thread-level Electric sync for comments, remove per-message hooks

This commit is contained in:
CREDO23 2026-01-22 17:57:20 +02:00
parent 4b57ba9d2b
commit 0b8fed7304
3 changed files with 365 additions and 154 deletions

View file

@ -62,6 +62,7 @@ import type { ThinkingStep } from "@/components/tool-ui/deepagent-thinking";
import { Button } from "@/components/ui/button";
import type { Document } from "@/contracts/types/document.types";
import { useChatSessionState } from "@/hooks/use-chat-session-state";
import { useCommentsElectric } from "@/hooks/use-comments-electric";
import { cn } from "@/lib/utils";
interface ThreadProps {
@ -238,6 +239,9 @@ const Composer: FC = () => {
const { isAiResponding, respondingToUserId } = useChatSessionState(threadId);
const isBlockedByOtherUser = isAiResponding && respondingToUserId !== currentUser?.id;
// Sync comments for the entire thread via Electric SQL (one subscription per thread)
useCommentsElectric(threadId);
// Auto-focus editor on new chat page after mount
useEffect(() => {
if (isThreadEmpty && !hasAutoFocusedRef.current && editorRef.current) {