import { createContext, useContext, type PropsWithChildren } from 'react' export type AddToolApprovalResponse = (args: { id: string approved: boolean reason?: string }) => void | PromiseLike export interface MessageInfo { id: string variant?: 'default' | 'warning' isLoading: boolean readOnly?: boolean isUserMessage?: boolean isLastMessage?: boolean state: 'idle' | 'editing' | 'predecessor-editing' rating?: 'positive' | 'negative' | null } export interface MessageActions { addToolApprovalResponse?: AddToolApprovalResponse onDelete: (id: string) => void onEdit: (id: string) => void onCancelEdit: () => void onRate?: (id: string, rating: 'positive' | 'negative', reason?: string) => void } const MessageInfoContext = createContext(null) const MessageActionsContext = createContext(null) export function useMessageInfoContext() { const ctx = useContext(MessageInfoContext) if (!ctx) { throw Error('useMessageInfoContext must be used within a MessageProvider') } return ctx } export function useMessageActionsContext() { const ctx = useContext(MessageActionsContext) if (!ctx) { throw Error('useMessageActionsContext must be used within a MessageProvider') } return ctx } export function MessageProvider({ messageInfo, messageActions, children, }: PropsWithChildren<{ messageInfo: MessageInfo; messageActions: MessageActions }>) { return ( {children} ) }