import type { Message, MessagesPage } from '../types/api'; export declare function sameMessageList(left: readonly Message[], right: readonly Message[]): boolean; /** Total persisted parts a page currently holds. Mirrors the route's partCount. */ export declare function countPageParts(items: readonly Message[]): number; /** * Flattens newest-first pages into one chronological thread with a single * entry per message. Pages hold whole turns, so this is a concatenation in * page order; ids seen more than once (only possible after a widened refetch * of the newest page) are collapsed into one message that keeps the position * of its oldest copy and the newest copy's metadata. */ export declare function mergeMessagePages(pages: readonly MessagesPage[] | undefined): Message[]; /** * Reconciles a refetched newest page against the copy already in the cache. * The refetch window is capped, so a page that grew past the cap could * otherwise drop parts (or whole messages) that are still loaded and still * persisted. Fresh parts win; anything the server no longer returns but the * cache still holds is kept, oldest first, so nothing already rendered * disappears. Optimistic entries are excluded here and re-appended separately. */ export declare function reconcileRefetchedPage(cached: MessagesPage | undefined, fresh: MessagesPage): MessagesPage; /** * Writes a merged, flat thread back into the page shape. A message lives on * exactly one page — the page it was loaded from — and carries all of its * parts, so this is a bucketed pass with no part-level splitting. Messages the * cache has not seen before (optimistic sends, a turn that started streaming * after the last fetch) join the newest page. * * Untouched pages are returned by identity, so an update at the live edge never * invalidates the older pages above it. * * Returns `null` when nothing changed. */ export declare function distributeMessagesToPages(pages: readonly MessagesPage[], next: readonly Message[]): MessagesPage[] | null; //# sourceMappingURL=messagePageMerge.d.ts.map