/** * Derived turn-navigation state plus a tiny hand-written observable store. * * The store is a ~30-line getSnapshot/subscribe pair so this third-party * bundle carries no zustand/immer engine. Snapshot identity stays stable: * set/update replace the object only when a fact actually changed, which is * what lets the renderer's uSES binding skip re-renders. */ /** Structural view of the chat-node location this plugin reads (duck-typed against the runtime contract). */ export interface ChatNodeLocationView { kind: string; turn?: { turn: number; }; } /** Structural view of a chat node: only its resolved location is consumed. */ export interface ChatNodeView { location: ChatNodeLocationView; } /** Structural view of the chat snapshot fields this plugin reads. */ export interface ChatSnapshotView { /** Render order of materialized node keys (the DOM anchor keys). */ order: readonly string[]; /** Stable live per-key reader. */ nodes: { get(key: string): ChatNodeView | undefined; }; /** Ordered turn numbers in the window. */ timeline: { turnOrder: readonly number[]; }; /** Ordered node keys per turn. */ locations: { getTurn(turn: number): readonly string[]; }; } /** One turn's jump target: its number and the DOM anchor key of its first node. */ export interface TurnEntry { turn: number; firstKey: string; } /** The complete navigation snapshot the panel consumes. */ export interface TurnNavState { sessionId: string | undefined; /** Whole-log turn count (sessionStats projection), falling back to the window max turn. */ totalTurns: number; turns: readonly TurnEntry[]; keyToTurn: ReadonlyMap; minTurn: number | undefined; maxTurn: number | undefined; hasMore: boolean; /** The turn currently at the top of the viewport, reported by the panel. */ currentTurn: number | undefined; } /** Derived (non-interactive) slice, produced by `deriveTurnNav`. */ export type TurnNavDerived = Omit; /** Extract the owning turn number from a chat node's resolved location. */ export declare function turnOfNode(node: ChatNodeView | undefined): number | undefined; /** Derive the turn list, key→turn index, and min/max from a chat snapshot. */ export declare function deriveTurnNav(input: { sessionId: string | undefined; chat: ChatSnapshotView | undefined; projectedTurns: number | undefined; hasMore: boolean; }): TurnNavDerived; /** The no-session / empty snapshot. */ export declare function emptyNav(sessionId?: string | undefined): TurnNavDerived; /** Minimal observable store over an immutable snapshot. */ export interface NavStore { getSnapshot(): TurnNavState; subscribe(fn: () => void): () => void; set(next: TurnNavState): void; update(fn: (prev: TurnNavState) => TurnNavState): void; } /** Create the navigation store with a stable initial snapshot. */ export declare function createNavStore(): NavStore;