import { type ReactNode, type Ref } from 'react'; import type { ComposerPastes } from '../core/pasteCards.js'; import { type ComposerRecall } from '../core/takeBack.js'; import type { AttachmentMeta, MessagePaste } from '../types.js'; import { type SlashMenuConfig } from './SlashMenu.js'; import { type ComposerHistory } from './useComposerHistory.js'; export type { ComposerRecall, RecalledMessage } from '../core/takeBack.js'; interface ChatInputProps { /** The box empties at once. Answering false, or with a promise of false or * one that rejects, puts everything back so the person can try again. */ onSend: (content: string, attachmentIds?: string[], attachmentMeta?: AttachmentMeta, pastes?: MessagePaste[]) => unknown; /** ↑ and ↓ in an empty box step through what was sent: the history's seed * and what this tab sent, failed sends included. Takes ↑ over from * onEditLastMessage. */ history?: ComposerHistory | undefined; /** ↑ in an empty box takes back what was sent but not read yet, ahead of * the history, and puts it back in the box with its pastes. */ recall?: ComposerRecall | undefined; disabled?: boolean; placeholder?: string | undefined; conversationId?: string; onEditLastMessage?: () => void; /** Send with nothing typed, for a surface where the text is optional. */ allowEmpty?: boolean; /** Attach, paste, and drop files. Off for a target that takes text only. */ attachments?: boolean; /** Files picked from the +, dropped on the composer or pasted into it go to * the host in place of the chat's attachments. */ files?: ComposerFiles | undefined; /** Hold sending until the provider's selected model is one it can serve. * Off when the target picks its own model. */ requireModel?: boolean; inputLabel?: string; sendLabel?: string; sendTestId?: string; /** Offers the host's slash commands as the input starts with /. */ slash?: SlashMenuConfig | undefined; /** The host runs a message starting with `!` as a shell command, as a * terminal's shell mode does: a `!` typed first becomes the box's prompt, * the hint line says what Enter does, and ↑ walks only shell commands. * Backspace at the command's start, or Escape on an empty one, leaves it. */ shell?: boolean | undefined; /** Cards above everything else, such as a warning about this turn. */ notices?: ReactNode; /** Sits where a terminal's spinner line would, just above the box. */ activity?: ReactNode; /** Pills naming where the turn runs, rendered above the input. */ context?: ReactNode; /** Keeps the row of pills above the box even with none, so the box sits * where it does on a surface that has them. */ reserveContext?: boolean; /** Under the box, on the left. */ settingsLeft?: ReactNode; /** In the box beside send. Defaults to the model and allocation pickers. */ settingsRight?: ReactNode; /** One centered line under everything. */ hint?: string | undefined; /** A turn the chat provider does not run, such as an agent session's: it * drives the Stop button in place of the provider's stream and queue. */ turn?: { running: boolean; onStop: () => void; stopping?: boolean; }; /** False where the chat's tools do not apply, such as starting an agent * session, which brings its own. */ tools?: boolean; pastes?: ComposerPastes | undefined; ref?: Ref | undefined; } /** Files the host takes itself, such as images a session saves where it runs. */ export interface ComposerFiles { /** The types the picker offers, as a file input's `accept`. */ accept?: string | undefined; onAdd: (files: File[]) => void; } export interface ChatInputHandle { addFiles: (files: FileList | File[]) => void; focus: () => void; /** Takes back what waits into the box, ahead of anything typed there; * resolves once it is there, to whether anything came back. `focus: false` * is for a take the person did not ask for: focus held elsewhere stays * there. `ifEmpty` takes nothing while the box holds something the person * put there, as a terminal refills only an empty line. */ recall: (options?: { focus?: boolean; ifEmpty?: boolean; }) => Promise; } export default function ChatInput({ onSend, history, recall, disabled, placeholder, conversationId, onEditLastMessage, allowEmpty, attachments: attachmentsWanted, files, requireModel, inputLabel, sendLabel, sendTestId, slash, shell, notices, activity, context, reserveContext, settingsLeft, settingsRight, hint, turn, tools: toolsAllowed, pastes, ref, }: ChatInputProps): import("react").JSX.Element;