import { type ComponentProps, type ReactNode, type Ref } from 'react'; import type { ApprovalAnswerHandler } from '../core/config.js'; import type { ChatMessage as Message } from '../types.js'; import ChatInput from './ChatInput.js'; import ChatMessageList from './ChatMessageList.js'; type ComposerProps = Omit, 'ref' | 'onSend' | 'turn' | 'conversationId' | 'onEditLastMessage'>; type ListProps = ComponentProps; export interface SessionViewProps { /** Keys the composer's draft, so each conversation or session keeps its own. */ sessionKey: string; messages: Message[]; /** Every message branch navigation and turn attribution look through; * defaults to `messages`. */ allMessages?: Message[]; streamingMessage?: Message | null; queuedMessages?: Message[]; onRemoveQueued?: (id: string) => void; canRemoveQueued?: (id: string) => boolean; queueDelivery?: ListProps['queueDelivery']; /** A turn the chat provider does not run, such as an agent session's: it * drives the composer's Stop and Escape in place of the provider's stream. */ turn?: { running: boolean; onStop: () => void; stopping?: boolean; }; onSend: ComponentProps['onSend']; /** Whether a send adds to the transcript, which returns the list to its * newest message first. A command that only opens a picker does not, and * leaves the reader where they are. Every send does when unset. */ addsToTranscript?: (content: string) => boolean; /** Resends an edited user message as a new branch. Without it, messages * cannot be edited. */ onEdit?: (message: Message, content: string) => void; onRegenerate?: (messageId: string) => void; onRetry?: (messageId: string) => void; onNavigateBranch?: (messageId: string) => void; /** A promise it returns holds the approval as sending its answer until it settles. */ onApprovalAnswer?: ApprovalAnswerHandler; showAuthor?: boolean; currentUsername?: string; /** Shown above the transcript, such as a blocked allocation or an * unreachable machine. */ banners?: ReactNode; /** In place of the transcript, such as a failed load with a way to retry. */ error?: ReactNode; /** Still loading the first messages: the transcript stays empty and the * composer disabled. */ loading?: boolean; /** Files dropped anywhere on the view go to the composer, as if dropped on it. */ dropFiles?: boolean; footer?: ReactNode; label?: string; flush?: boolean; /** Draws the transcript as a terminal does: every run of tool calls folds * from its first call, failures and running calls included, and a thought * shows whole while it streams. */ foldEveryRun?: boolean; workingIndicator?: boolean; /** Pins the prompt of the turn in view over the transcript once it scrolls away. */ pinPrompt?: boolean; composer?: ComposerProps; /** Finds text in the transcript: ⌘F, or FIND_IN_TRANSCRIPT_EVENT from the * host's own control, opens a bar above it. */ find?: boolean; ref?: Ref | undefined; } export interface SessionViewHandle { /** Stops the turn as Escape does, for the host's own Stop outside the * composer: what waits comes back to the composer first. */ stop: () => Promise; /** Takes back into the composer what the host's `composer.recall` gives, * as ↑ does, for a message the host learns later was never read, such as * when its turn failed first. Focus held elsewhere stays there. Resolves * to whether anything came back: `ifEmpty` takes nothing while the person * has something in the box, as a terminal refills only an empty line. */ recall: (options?: { ifEmpty?: boolean; }) => Promise; } /** One conversation or agent session: its transcript, with the composer at * the foot of the scrolling column. The host binds its own data and actions; * what it leaves out (editing, regenerating, branches) the view leaves out. */ export default function SessionView({ sessionKey, messages, allMessages, streamingMessage, queuedMessages, onRemoveQueued, canRemoveQueued, queueDelivery, turn, onSend, addsToTranscript, onEdit, onRegenerate, onRetry, onNavigateBranch, onApprovalAnswer, showAuthor, currentUsername, banners, error, loading, dropFiles, footer, label, flush, foldEveryRun, workingIndicator, pinPrompt, composer, find, ref, }: SessionViewProps): import("react").JSX.Element; export {};