/** * useChatHistoryHydration — mount-time rebuild of the chat message list from * the SERVER-side conversation store (the `chat_conversations` / * `chat_messages` SSOT behind `GET /history`). * * The client persists ONLY the server-issued conversation id (see * `chat-conversation-storage.ts`); this hook turns that id back into rendered * history: message bubbles and the send counter. Inline entity cards need no * per-row metadata — they hydrate by id from the `[card://…]` markers in the * message content via the card fetch path. * * Failure semantics: a fetch/parse failure simply leaves the UI empty — the * SERVER still resolves full history for the next turn (it re-reads * `chat_messages` by conversation id on every send), so conversation context * is never lost when hydration misses. */ import { type MutableRefObject } from 'react'; import type { Message } from './use-chat'; export interface UseChatHistoryHydrationArgs { /** Mirrors the adapter's `active` gate — an idle (Mingo-mode) mount never fetches. */ active: boolean; /** Chat source (= platform); part of the once-per-conversation guard key. */ source: string; /** Resolved history endpoint (`/history` by default). */ historyUrl: string; /** The server-issued conversation id (null = nothing to hydrate). */ conversationIdRef: MutableRefObject; /** User-send counter — set to the hydrated user-turn count so the next * live send lands on the following `sendIdx`. */ sendCountRef: MutableRefObject; /** `useChat`'s injection primitive (replace-or-prepend). */ hydrateMessages: (history: Message[], /** Per-send "Sources used" chips restored from the persisted audit copy * (`[sendIdx, sources[]]` entries for the reducer's sourcesMap). */ sourcesSeed?: Array<[number, unknown[]]>) => void; /** Invalidates the adapter's `latestMeta` memo after hydration lands. */ bumpMetaTick: () => void; } export interface UseChatHistoryHydrationResult { /** True while the rebuild request is in flight. */ isHydratingHistory: boolean; /** Once-per-`source:conversationId` guard. The adapter's `clearMessages` * resets it to null alongside the stored id (a fresh conversation has no * server history to fetch). */ hydratedKeyRef: MutableRefObject; } export declare function useChatHistoryHydration({ active, source, historyUrl, conversationIdRef, sendCountRef, hydrateMessages, bumpMetaTick, }: UseChatHistoryHydrationArgs): UseChatHistoryHydrationResult; //# sourceMappingURL=use-chat-history-hydration.d.ts.map