import type { SessionTurn } from "@opengeni/sdk"; import type { ComposerOptimisticMessage, ComposerState } from "./use-composer.js"; import type { QueueMutationKind, UseTurnQueueResult } from "./use-turn-queue.js"; /** What one Up-arrow recall did. `unavailable` leaves the composer untouched. */ export type QueuedPromptRecallOutcome = "recalled" | "already_sent" | "unavailable"; /** * How long Up pressed right after a send waits for that prompt to reach the * queue. The send is normally settled within a second or two; past this the * press is dropped rather than left pending behind a stalled send. */ export declare const QUEUED_RECALL_SETTLE_TIMEOUT_MS = 10000; /** * Up-arrow recall of the person's latest waiting prompt. `available` is a * render-time hint that Up should be taken for recall: a prompt is waiting, or * one just sent is still on its way into the queue. `recall` re-checks * everything against live state, waiting for such a send to settle first. */ export type ComposerQueuedRecall = { available: boolean; /** The waiting prompt Up would pull back now, for a subtle hint on its row. */ turnId: string | null; recall: () => Promise; }; /** * Plain Up in an empty composer (caret necessarily at the start), outside IME * composition and with no command/mention popup open. Any typed text, quote or * attachment keeps normal Up behaviour so recall never replaces a draft. */ export declare function shouldRecallQueuedOnKey(event: { key: string; shiftKey?: boolean; altKey?: boolean; metaKey?: boolean; ctrlKey?: boolean; keyCode?: number; nativeEvent?: { isComposing?: boolean; keyCode?: number; }; }, field: { value: string; selectionStart: number | null; selectionEnd: number | null; /** Attachments, quotes or restored files already in the draft. */ hasOtherContent: boolean; /** A command palette, mention list or other popup owns the arrow keys. */ popupOpen: boolean; }): boolean; /** * The newest waiting human prompt this person may pull back: the last one in * queue order (the one that would run last), queued, not mid-mutation, not a * once personal-resource attachment (the server refuses those), and initiated * by this viewer when one is given. */ export declare function latestRecallableQueuedTurn(turns: readonly SessionTurn[], mutationFor: (turnId: string) => QueueMutationKind | null, subjectId?: string | null): SessionTurn | null; /** * A just-sent prompt still on its way into the queue. Until it shows up there, * "the latest waiting prompt" is unknown, so recall waits rather than pulling * back an older one. */ export declare function hasQueuedSendInFlight(messages: readonly ComposerOptimisticMessage[] | undefined, queuedTurnIds: ReadonlySet, queueVersion: number | null | undefined): boolean; /** * Wire a session's queue to its composer for Up-arrow recall. The withdraw is * the same atomic server checkout as the queue's Edit action, so a prompt the * agent already took can never be duplicated or lost. * * The queue row shows a just-sent prompt as waiting before the server's queue * snapshot includes it. Up pressed in that window is taken at once: recall * follows exactly the sends in flight at the press and pulls back the newest * of them once it lands, so one press is always enough. */ export declare function useQueuedPromptRecall({ queue, composer, subjectId, enabled, }: { queue: Pick; composer: Pick | undefined; subjectId?: string | null | undefined; enabled?: boolean | undefined; }): ComposerQueuedRecall | undefined;