/** * The conversation's message versions, as the transcript needs them. * * Editing a turn forks the conversation on Core: the turn and everything after it are archived, and * the replacement continues from the same point. This controller is the read side of that — it * holds the version groups the server reports and turns them into the ‹ n/m › pager state for each * user turn, and it performs the switch when the visitor pages between versions. * * Mirrors Core's `useChatMessageBranches`: refresh on session change, refresh again when a turn * finishes (the fork is created mid-turn, so the count only settles afterwards), and treat every * failure as non-fatal — a conversation with no reachable version state renders with no pager, * which is exactly how an unedited conversation renders. */ import type { Accessor } from 'solid-js'; import { type WidgetSessionParams } from '@/widget/services/sessions'; import type { MessageType } from '@/widget/types'; import { type BranchPager } from './messageVersions'; type BranchControllerDeps = { params: Accessor; /** The open session, or undefined when the conversation is not server-backed yet. */ sessionId: Accessor; /** False in preview mounts and wherever the session plane is unreachable. */ enabled: Accessor; messages: Accessor; /** True while a turn is streaming. */ loading: Accessor; /** Re-read the live conversation after a switch swapped it out. */ reloadMessages: (sessionId: string) => Promise; }; export type BranchController = { /** Pager state keyed by transcript index; absent for turns that were never edited. */ pagerByIndex: Accessor>; /** True while a switch is in flight — the pager is inert until it settles. */ isSwitching: Accessor; refresh: () => Promise; switchTo: (index: number, targetBranchIndex: number) => Promise; }; export declare function createBranchController(deps: BranchControllerDeps): BranchController; export {};