/** * @fileoverview Chat message loading functionality. * Handles loading chat messages from localStorage (for guest chats), * the API (for authenticated users), or the API for public shared chats (for unauthenticated users). * @module components/ResearchAgent/state/chat/chatMessages */ import { Message } from "../../components/ChatConversation/ChatWindow"; import { ChatFile } from "../../types/chat"; /** * Loads chat messages and metadata for an existing chat session. * * This function handles three scenarios: * - **Guest users**: Loads messages from localStorage via `getGuestChat()`, then tries API for public shared chats if not found * - **Public shared chats**: Unauthenticated users can view public chats via the API without sign-in * - **Authenticated users**: Fetches messages from the `/api/chats/:id` endpoint * * After loading, it: * - Sets the document title to the first message * - Builds the chat history for context * - Loads attached files and their IDs * - Sets the focus mode from the saved chat * * @param chatId - The unique identifier of the chat to load * @param isAuthenticated - Whether the current user is authenticated * @param setMessages - Callback to set the loaded messages * @param setIsMessagesLoaded - Callback to signal loading completion * @param setChatHistory - Callback to set the conversation history * @param setFocusMode - Callback to set the chat's focus mode * @param setNotFound - Callback to signal if the chat doesn't exist * @param setFiles - Callback to set the attached files * @param setFileIds - Callback to set the file IDs * * @example * ```typescript * await loadMessages( * chatId, * isAuthenticated, * setMessages, * setIsMessagesLoaded, * setChatHistory, * setFocusMode, * setNotFound, * setFiles, * setFileIds, * ); * ``` */ export declare const loadMessages: (chatId: string, isAuthenticated: boolean, setMessages: (messages: Message[]) => void, setIsMessagesLoaded: (loaded: boolean) => void, setChatHistory: (history: [string, string][]) => void, setFocusMode: (mode: string) => void, setNotFound: (notFound: boolean) => void, setFiles: (files: ChatFile[]) => void, setFileIds: (fileIds: string[]) => void) => Promise;