From 955a63a131984d4d06372bc171ad064bffba604d Mon Sep 17 00:00:00 2001 From: chihlasm Date: Fri, 6 Mar 2026 23:27:22 -0500 Subject: [PATCH] feat: add TypeScript types for editor-embedded AI Co-Authored-By: Claude Opus 4.6 --- frontend/src/types/editor-ai.ts | 62 +++++++++++++++++++++++++++++++++ frontend/src/types/index.ts | 11 ++++++ 2 files changed, 73 insertions(+) create mode 100644 frontend/src/types/editor-ai.ts diff --git a/frontend/src/types/editor-ai.ts b/frontend/src/types/editor-ai.ts new file mode 100644 index 00000000..9170a6a4 --- /dev/null +++ b/frontend/src/types/editor-ai.ts @@ -0,0 +1,62 @@ +export type AIActionType = + | 'generate_full' + | 'generate_branch' + | 'modify_node' + | 'add_steps' + | 'quick_action' + | 'open_chat' + | 'variable_inference' + +export interface AIDelta { + action: 'add' | 'modify' | 'delete' + target_node_id: string + nodes: Record[] + explanation: string +} + +export interface AISuggestion { + id: string + action_type: AIActionType + target_node_id: string | null + changes_json: { + before?: Record + after?: Record + delta?: AIDelta + } + status: 'pending' | 'accepted' | 'dismissed' + created_at: string + resolved_at: string | null +} + +export interface EditorAIChatMessage { + role: 'user' | 'assistant' + content: string + timestamp: string + action_type?: AIActionType + delta?: AIDelta + knowledge?: KnowledgeCitation[] +} + +export interface KnowledgeCitation { + title: string + url: string + excerpt: string +} + +export interface ContextMenuAction { + id: string + label: string + icon: string + action_type: AIActionType + description?: string +} + +export interface ContextMenuPosition { + x: number + y: number +} + +export interface SuggestionMarker { + _suggestion?: true + _suggestion_id?: string +} diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 9a2cde9f..71225693 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -71,3 +71,14 @@ export type { FlowExportCategory, FlowImportResponse, } from './flowTransfer' + +export type { + AIActionType, + AIDelta, + AISuggestion, + EditorAIChatMessage, + KnowledgeCitation, + ContextMenuAction, + ContextMenuPosition, + SuggestionMarker, +} from './editor-ai'