Runtime Hooks

AttachmentRuntime

Hooks for accessing attachment state in composer and messages.

useAuiState (Attachment State)

Access the current attachment state reactively:

import { useAuiState } from "@assistant-ui/react";

const name = useAuiState((s) => s.attachment.name);
const type = useAuiState((s) => s.attachment.type);

For imperative access and actions, use useAui:

import { useAui } from "@assistant-ui/react";

const aui = useAui();
aui.attachment().remove();
const state = aui.attachment().getState();

Attachment Runtime

AttachmentRuntime
path: AttachmentRuntimePath & { attachmentSource: TSource; }

source: TSource

getState: () => AttachmentState & { source: TSource; }

remove: () => Promise<void>

subscribe: (callback: () => void) => Unsubscribe

Attachment State

AttachmentState
id: string

type: "image" | "document" | "file" | (string & {})

name: string

contentType?: string | undefined

file?: File

content?: ThreadUserMessagePart[]

status: CompleteAttachmentStatus | PendingAttachmentStatus

source: "message" | "thread-composer" | "edit-composer"