From c358cedbaee6dbe8a448273b3a3eb8a8568ca1e8 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Thu, 9 Apr 2026 00:00:39 +0530 Subject: [PATCH] feat: add chat session and message synchronization hooks --- .../new-chat/[[...chat_id]]/page.tsx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx index 7bef1fff2..e92134111 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx @@ -38,6 +38,43 @@ import { removeChatTabAtom, updateChatTabTitleAtom } from "@/atoms/tabs/tabs.ato import { currentUserAtom } from "@/atoms/user/user-query.atoms"; import { ThinkingStepsDataUI } from "@/components/assistant-ui/thinking-steps"; import { Thread } from "@/components/assistant-ui/thread"; +import { useChatSessionStateSync } from "@/hooks/use-chat-session-state"; +import { useMessagesSync } from "@/hooks/use-messages-sync"; +import { getBearerToken } from "@/lib/auth-utils"; +import { documentsApiService } from "@/lib/apis/documents-api.service"; +import { + type ContentPartsState, + FrameBatchedUpdater, + type ThinkingStepData, + addToolCall, + appendText, + buildContentForPersistence, + buildContentForUI, + readSSEStream, + updateThinkingSteps, + updateToolCall, +} from "@/lib/chat/streaming-state"; +import { convertToThreadMessage } from "@/lib/chat/message-utils"; +import { + isPodcastGenerating, + looksLikePodcastRequest, + setActivePodcastTaskId, +} from "@/lib/chat/podcast-state"; +import { + type ThreadRecord, + appendMessage, + createThread, + getRegenerateUrl, + getThreadFull, + getThreadMessages, +} from "@/lib/chat/thread-persistence"; +import { NotFoundError } from "@/lib/error"; +import { + trackChatCreated, + trackChatError, + trackChatMessageSent, + trackChatResponseReceived, +} from "@/lib/posthog/events"; import Loading from "../loading"; const MobileEditorPanel = dynamic(