/** * Generation-safe navigation reads within one selected session. * * This keeps event discovery, explicit event disclosure, and lineage tracing * reusable by session surfaces that are not corpus catalogs. It owns every * cancellation handle for those reads, so disposing a surface cannot let a * late result redraw the next one. * @module dshline/sessions/navigator */ import type { SessionId, SessionSeq } from '@deepseek-ai/dsh-session'; import type { SessionEventReadRequest, SessionEventSearchPage, SessionEventSearchRequest, SessionEventWindow, SessionLineageTrace, SessionSearchExecContext, SessionTitleObservationResult } from '@deepseek-ai/dsh-session-query'; import type { EventContextState, EventSearchState, LineageState } from './model.ts'; /** Full-text results requested from either search service per page. */ export declare const CONTENT_SEARCH_LIMIT = 50; /** Raw events read on each side of one disclosed search hit. */ export declare const EVENT_CONTEXT_BEFORE = 8; /** Raw events read after one disclosed search hit. */ export declare const EVENT_CONTEXT_AFTER = 8; /** The exact query reads required for one-session navigation. */ export interface SessionNavigationReads { /** Full-text search within one session. */ searchEvents(request: SessionEventSearchRequest, exec?: SessionSearchExecContext): Promise; /** Read one exact event and a bounded surrounding raw-log window. */ readEvent(request: SessionEventReadRequest, signal?: AbortSignal): Promise; /** Trace one session's ancestors and descendants. */ traceSession(sessionId: SessionId, signal?: AbortSignal): Promise; } /** A folded title that can safely replace a displayed lineage title. */ export interface SessionObservedTitle { /** The authoritative folded title, absent when the session has none. */ readonly title?: string; } /** Construction dependencies for a {@link SessionNavigator}. */ export interface SessionNavigatorSpec { /** Mounted navigation reads, or undefined when session query is unavailable. */ readonly query: SessionNavigationReads | undefined; /** Redraw after navigation state changes. */ readonly invalidate: () => void; /** * Observe folded titles for lineage rows. * * The catalog supplies this adapter so title settlement policy remains owned * by the catalog rather than duplicated by each navigation surface. */ readonly observeTitles: (sessionIds: readonly SessionId[], signal?: AbortSignal) => Promise>; } /** * Fold one settled title batch into the traits lineage rows consume. * * The ONE home of Harness title-settlement policy for every navigation surface: * a fulfilled observation contributes an entry even when the log carries no * title (which is how a stale displayed title is cleared), a rejected member is * dropped rather than propagated, and an empty title is an absence rather than * a placeholder. Both the corpus catalog and the attached-session hub pass * their `readTitleSnapshots` results through here, so the two cannot drift. * @param results - the batch's ordered settlements. * @returns traits by session id for every fulfilled observation. */ export declare function observedTitleTraits(results: readonly SessionTitleObservationResult[]): Map; /** Generation-safe event and lineage navigation for one session surface. */ export declare class SessionNavigator { private readonly spec; private eventState; private eventContextState; private lineageState; private eventGeneration; private eventContextGeneration; private lineageGeneration; private eventAbort; private eventContextAbort; private lineageAbort; private eventChain; /** A revision changes for an empty settled page too. */ private pageRevision; private disposed; /** * @param spec - the navigation reads and redraw callback. */ constructor(spec: SessionNavigatorSpec); /** @returns the current within-session event search state. */ events(): EventSearchState; /** * @param sessionId - the hit's owning session. * @param seq - the hit's event sequence number. * @returns context only when it belongs to that exact hit. */ eventContext(sessionId: SessionId, seq: SessionSeq): EventContextState; /** * @param sessionId - the selected session. * @returns lineage only when it belongs to that selected session. */ lineage(sessionId: SessionId): LineageState; /** * @returns the current lineage state for catalog title reconciliation. */ lineageSnapshot(): LineageState; /** * Start a fresh cursorless event search within one session. * @param sessionId - the selected session. * @param text - backend-interpreted query text. * @returns nothing. */ searchEvents(sessionId: SessionId, text: string): void; /** Append the next within-session event page when its cursor remains valid. */ loadMoreEvents(): void; /** * Read one disclosed hit's exact target event and bounded raw-log window. * @param sessionId - the hit's owning session. * @param seq - the hit's event sequence number. * @returns nothing. */ requestEventContext(sessionId: SessionId, seq: SessionSeq): void; /** * Request and flatten the selected session's lineage. * @param sessionId - the selected session. * @returns nothing. */ requestLineage(sessionId: SessionId): void; /** * Apply a catalog-owned title observation to the exact lineage snapshot read. * @param snapshot - lineage state captured before observing titles. * @param titles - authoritative fulfilled title observations. * @returns whether the displayed lineage changed. */ reconcileLineageTitles(snapshot: LineageState, titles: ReadonlyMap): boolean; /** Abort every in-flight navigation read and reject all late settlements. */ dispose(): void; /** * Abandon in-flight reads and return the navigation surface to idle. * * Separate from {@link dispose} because a surface can close and reopen over * the life of one attachment: the reads must be aborted so a late page cannot * repaint, but the navigator stays usable for the next open. The state is * reset to `idle` rather than left at `loading`, because an aborted read has * no page coming and `loading` would be a promise nothing will keep. * * Disposal deliberately does NOT reset the state: the corpus browser asserts * its last reading after closing, and the catalog owns those states for its * whole (one-open) life. */ abort(): void; /** Bump every generation and abort every live read, leaving state untouched. */ private cancelReads; private requestEventPage; private currentEventChain; private titleLineageRow; private stale; } //# sourceMappingURL=navigator.d.ts.map