/** * What the app already knows about chats, so the command menu can answer * instantly: rows the sidebar and searches have loaded, the chats someone * opened recently in any of their workspaces (kept across reloads), and each * workspace's sidebar order for next and previous chat. It is a cache for speed, never a source of authority: opening a chat * still goes through the normal authorized reads. */ import type { SessionAvatar } from "@opengeni/sdk"; import { type SessionListRow } from "../../../session-list-model.js"; export type ChatRecord = { id: string; workspaceId: string; title: string; /** The chat's avatar, drawn as the sidebar draws it; null when it has none. */ avatar: SessionAvatar | null; updatedAt: number; pinned: boolean; archived: boolean; /** * The chat that started this one, for a sub-agent chat; null for a chat of * its own. Kept across reloads, so it is known before the row is read again. */ parentId: string | null; /** That chat's title when this record was last written, for when it isn't loaded. */ parentTitle: string | null; /** Present when the app holds a full or list row, needed for pin and archive. */ row: SessionListRow | null; /** When `row` was last read from the server (ms), so its status is known to be current. */ readAt: number; }; export declare function chatRecordFromRow(row: SessionListRow, readAt?: number, parentTitle?: string | null): ChatRecord; /** * Whether a chat lists with the person's own chats: every top-level chat, and * a sub-agent chat they pinned. Pinning says "this one is a real agent to me". * Other sub-agent chats show only once opened, or in their own search group. */ export declare function listsAsTopLevel(record: Pick): boolean; /** The title of the chat a sub-agent chat belongs to, when the app knows it. */ export declare function chatParentTitle(rows: ReadonlyMap, record: Pick): string | null; /** * Changes when a row's status marks could change (working, waiting, needs you, * failed, unread, scheduled, creator), so a status-only change re-renders the * lists. Raw fields only: the marks themselves are drawn by the lazy lists. */ export declare function chatStatusKey(row: SessionListRow | null): string; /** Remember rows the app has read (sidebar pages, search results, the open chat). */ export declare function rememberChats(subjectId: string, rows: readonly SessionListRow[]): void; /** The chat was opened: move it to the front of the recent list. */ export declare function recordChatVisit(subjectId: string, row: SessionListRow): void; /** The sidebar reports the chats it shows, in order, so next and previous follow it. */ export declare function setSidebarOrder(subjectId: string, workspaceId: string, order: readonly string[], pinnedOrder: readonly string[]): void; export type ChatDirectorySnapshot = Readonly<{ /** Chats in every workspace; each record names its workspace. */ rows: ReadonlyMap; /** Recently opened chats across workspaces, most recent first. */ recent: readonly string[]; /** The given workspace's sidebar order and pinned order. */ sidebarOrder: readonly string[]; pinnedOrder: readonly string[]; version: number; }>; export declare function readChatDirectory(subjectId: string, workspaceId: string): ChatDirectorySnapshot; /** Re-renders when the directory changes; read the snapshot through `readChatDirectory`. */ export declare function useChatDirectoryVersion(subjectId: string): number;