import { UISchema } from '../types'; /** * Role of a chat message participant */ export type MessageRole = 'system' | 'user' | 'assistant'; /** * Status of a chat message */ export type MessageStatus = 'pending' | 'streaming' | 'complete' | 'error'; /** * A single chat message in a conversation (UI state) * Note: This extends the basic ChatMessage from llm-service with UI-specific fields */ export interface ConversationMessage { /** Unique identifier for the message */ id: string; /** Role of the message sender */ role: MessageRole; /** Message content */ content: string; /** Timestamp when the message was created */ timestamp: number; /** Message status */ status: MessageStatus; /** Extracted UISchema from assistant messages (if any) */ extractedSchema?: UISchema; /** Error message if status is 'error' */ error?: string; } /** * A conversation containing multiple messages */ export interface Conversation { /** Unique identifier for the conversation */ id: string; /** Conversation title (usually derived from first user message) */ title: string; /** Array of messages in chronological order */ messages: ConversationMessage[]; /** Timestamp when the conversation was created */ createdAt: number; /** Timestamp when the conversation was last updated */ updatedAt: number; /** The latest UISchema generated in this conversation */ latestSchema?: UISchema; } /** * Chat state containing all conversations */ export interface ChatState { /** All conversations indexed by ID */ conversations: Record; /** ID of the currently active conversation */ activeConversationId: string | null; /** Order of conversation IDs (most recent first) */ conversationOrder: string[]; } /** * Generates a unique ID */ export declare function generateId(): string; /** * Creates an initial empty chat state */ export declare function createInitialChatState(): ChatState; /** * Creates a new chat message */ export declare function createMessage(role: MessageRole, content: string, options?: { id?: string; status?: MessageStatus; extractedSchema?: UISchema; }): ConversationMessage; /** * Creates a new conversation */ export declare function createConversation(title?: string, id?: string): Conversation; /** * Adds a message to a conversation */ export declare function addMessageToConversation(conversation: Conversation, message: ConversationMessage): Conversation; /** * Updates a message in a conversation */ export declare function updateMessageInConversation(conversation: Conversation, messageId: string, updates: Partial>): Conversation; /** * Adds a conversation to the chat state */ export declare function addConversationToState(state: ChatState, conversation: Conversation): ChatState; /** * Updates a conversation in the chat state */ export declare function updateConversationInState(state: ChatState, conversation: Conversation): ChatState; /** * Removes a conversation from the chat state */ export declare function removeConversationFromState(state: ChatState, conversationId: string): ChatState; /** * Sets the active conversation */ export declare function setActiveConversation(state: ChatState, conversationId: string | null): ChatState; /** * Gets the active conversation */ export declare function getActiveConversation(state: ChatState): Conversation | null; /** * Gets all conversations in order (most recent first) */ export declare function getConversationsInOrder(state: ChatState): Conversation[]; /** * Gets the message count for a conversation */ export declare function getMessageCount(conversation: Conversation): number; /** * Gets all messages from a conversation */ export declare function getMessages(conversation: Conversation): ConversationMessage[]; /** * Parse status for JSON content */ export type ParseStatus = 'valid' | 'invalid' | 'empty'; /** * Editor state for JSON Schema editing */ export interface EditorState { /** Raw JSON content in the editor */ content: string; /** Parse status of the content */ parseStatus: ParseStatus; /** Parsed UISchema if content is valid */ parsedSchema: UISchema | null; /** Parse error message if content is invalid */ parseError: string | null; /** Whether the content has unsaved changes */ isDirty: boolean; /** Cursor position in the editor */ cursorPosition?: { line: number; column: number; }; } /** * Creates an initial empty editor state */ export declare function createInitialEditorState(): EditorState; /** * Updates editor content and synchronizes parse state */ export declare function updateEditorContent(state: EditorState, content: string): EditorState; /** * Sets editor content from a UISchema */ export declare function setEditorSchema(state: EditorState, schema: UISchema, pretty?: boolean): EditorState; /** * Marks editor content as saved */ export declare function markEditorSaved(state: EditorState): EditorState; /** * Updates cursor position */ export declare function updateCursorPosition(state: EditorState, line: number, column: number): EditorState; /** * Panel identifiers */ export type PanelId = 'chat' | 'editor' | 'preview'; /** * Layout state for the three-column layout */ export interface LayoutState { /** Width percentages for each panel (should sum to 100) */ panelWidths: { chat: number; editor: number; preview: number; }; /** Collapsed state for each panel */ collapsedPanels: { chat: boolean; editor: boolean; preview: boolean; }; /** Active tab in mobile/narrow view */ activeTab: PanelId; /** Whether the layout is in narrow/mobile mode */ isNarrowMode: boolean; /** Theme preference */ theme: 'light' | 'dark' | 'system'; } /** * Storage key for layout state persistence */ export declare const LAYOUT_STORAGE_KEY = "llm2ui-layout-state"; /** * Default layout state */ export declare const DEFAULT_LAYOUT_STATE: LayoutState; /** * Creates an initial layout state */ export declare function createInitialLayoutState(): LayoutState; /** * Updates panel width */ export declare function updatePanelWidth(state: LayoutState, panelId: PanelId, width: number): LayoutState; /** * Toggles panel collapsed state */ export declare function togglePanelCollapsed(state: LayoutState, panelId: PanelId): LayoutState; /** * Sets panel collapsed state */ export declare function setPanelCollapsed(state: LayoutState, panelId: PanelId, collapsed: boolean): LayoutState; /** * Sets the active tab (for narrow mode) */ export declare function setActiveTab(state: LayoutState, tab: PanelId): LayoutState; /** * Sets narrow mode */ export declare function setNarrowMode(state: LayoutState, isNarrow: boolean): LayoutState; /** * Sets theme preference */ export declare function setTheme(state: LayoutState, theme: 'light' | 'dark' | 'system'): LayoutState; /** * Saves layout state to localStorage */ export declare function saveLayoutState(state: LayoutState): boolean; /** * Loads layout state from localStorage */ export declare function loadLayoutState(): LayoutState | null; /** * Clears layout state from localStorage */ export declare function clearLayoutState(): void; /** * Gets layout state, loading from storage or returning default */ export declare function getOrCreateLayoutState(): LayoutState; //# sourceMappingURL=state-management.d.ts.map