Skip to main content
FlowDrop uses Svelte 5 rune-based stores for state management. There are no module-level store functions — every store lives on the per-mount FlowDropInstance.
Reaching a storeResolve the owning instance with getInstance() inside a FlowDrop component (it resolves the page-default instance for single-editor embeds), or hold the mount handle’s .instance outside the component tree. Exports from @flowdrop/flowdrop/editor: createFlowDropInstance, getInstance, provideInstance, the FlowDropInstance type, and the store classes WorkflowStore, HistoryStore, HistoryService, PortCoordinateStore (PlaygroundStore and InterruptStore export from @flowdrop/flowdrop/playground). See the multiple instances guide.
import { getInstance } from '@flowdrop/flowdrop/editor';
const fd = getInstance();

fd.workflow (WorkflowStore)

The primary store for workflow state, dirty tracking, and node/edge mutations.

Reactive getters

GetterReturnsDescription
fd.workflow.currentWorkflow | nullCurrent workflow object
fd.workflow.isDirtybooleanWhether workflow has unsaved changes
fd.workflow.idstring | nullCurrent workflow ID
fd.workflow.namestringWorkflow display name
fd.workflow.nodesWorkflowNode[]All nodes
fd.workflow.edgesWorkflowEdge[]All edges
fd.workflow.metadataWorkflowMetadataMetadata (created, updated, schemaVersion)
fd.workflow.formatstringWorkflow format identifier
fd.workflow.validation{hasNodes, hasEdges, nodeCount, edgeCount, isValid}Validation summary
fd.workflow.connectedHandlesSet<string>Set of connected port handle IDs

Non-reactive utilities

const dirty = fd.workflow.isDirty; // current value
fd.workflow.markAsSaved(); // Clears dirty flag

Workflow actions

const { actions } = fd.workflow;
MethodParametersDescription
initialize(workflow)WorkflowLoad a workflow into the store
updateWorkflow(workflow)WorkflowReplace the entire workflow
addNode(node)WorkflowNodeAdd a node
removeNode(nodeId)stringRemove a node by ID
updateNode(nodeId, updates)string, Partial<WorkflowNode>Update node properties
addEdge(edge)WorkflowEdgeAdd an edge
removeEdge(edgeId)stringRemove an edge by ID
updateNodes(nodes)WorkflowNode[]Replace all nodes
updateEdges(edges)WorkflowEdge[]Replace all edges
updateName(name)stringChange workflow name
updateMetadata(metadata)Partial<Workflow['metadata']>Update metadata fields
batchUpdate(updates){nodes?, edges?, name?, description?, metadata?}Apply multiple changes atomically
clear()Reset the store
pushHistory(description?)string?Manually push a history snapshot

Change callbacks

fd.workflow.setOnDirtyStateChange((isDirty) => {
  console.log('Dirty state:', isDirty);
});

fd.workflow.setOnWorkflowChange((workflow, changeType) => {
  console.log('Changed:', changeType);
});

fd.historyBindings (HistoryStore)

Manages undo/redo with snapshot-based history — the reactive rune wrapper around fd.history (the underlying HistoryService).

Reactive getters

GetterReturnsDescription
fd.historyBindings.canUndobooleanWhether undo is available
fd.historyBindings.canRedobooleanWhether redo is available

History actions

MethodReturnsDescription
undo()booleanUndo last change
redo()booleanRedo last undone change
clear(currentWorkflow?)voidClear all history
startTransaction(workflow, description?)voidBegin grouping changes
commitTransaction()voidCommit grouped changes as one step
cancelTransaction()voidRevert grouped changes
pushState(workflow, options?)voidManually push a snapshot
initialize(workflow)voidInitialize with a starting state
fd.historyBindings.undo();
fd.historyBindings.startTransaction(fd.workflow.current, 'Rearrange');

settingsStore

Manages editor settings with localStorage persistence and optional API sync. Settings are page-global by design — not instance-scoped, so they remain module-level functions.

Reactive getters

import {
  getSettings,
  themeSettings,
  editorSettings,
  uiSettings,
  behaviorSettings,
  apiSettings,
  theme,
  resolvedTheme,
  syncStatusStore
} from '@flowdrop/flowdrop/settings'; // theme/resolvedTheme also on /core
FunctionReturnsDescription
getSettings()FlowDropSettingsAll settings
themeSettings()ThemeSettingsTheme preferences
editorSettings()EditorSettingsEditor behavior settings
uiSettings()UISettingsUI preferences
behaviorSettings()BehaviorSettingsBehavior flags
apiSettings()ApiSettingsAPI configuration
theme()ThemePreference'light' | 'dark' | 'auto'
resolvedTheme()ResolvedTheme'light' | 'dark' (after resolving auto)
syncStatusStore(){status, lastSyncedAt, error}API sync state

Settings updates

import { updateSettings, resetSettings } from '@flowdrop/flowdrop/settings';

updateSettings({ theme: { preference: 'dark' } });
resetSettings(['theme', 'editor']); // Reset specific categories

Theme functions

import { setTheme, toggleTheme, cycleTheme } from '@flowdrop/flowdrop/core';

setTheme('dark'); // Set explicit theme
toggleTheme(); // Toggle light/dark
cycleTheme(); // Cycle light → dark → auto

Change listener

import { onSettingsChange } from '@flowdrop/flowdrop/settings';

const unsubscribe = onSettingsChange((newSettings, oldSettings) => {
  console.log('Settings changed');
});

// Later: unsubscribe();

fd.playground (PlaygroundStore)

Manages playground sessions, messages, and execution state.

Reactive getters

GetterReturnsDescription
fd.playground.currentSessionPlaygroundSession | nullActive session
fd.playground.sessionsPlaygroundSession[]All sessions
fd.playground.messagesPlaygroundMessage[]All messages in current session
fd.playground.isExecutingbooleanWhether a workflow is running
fd.playground.isLoadingbooleanWhether data is loading
fd.playground.errorstring | nullCurrent error message
fd.playground.messageCountnumberTotal message count
fd.playground.chatMessagesPlaygroundMessage[]Chat-type messages only
fd.playground.logMessagesPlaygroundMessage[]Log-type messages only
fd.playground.inputFieldsPlaygroundInputField[]Available input fields
fd.playground.sessionCountnumberTotal session count

Playground actions

const { actions } = fd.playground;
MethodDescription
setCurrentSession(session)Set the active session
addSession(session)Add a new session
removeSession(sessionId)Remove a session
switchSession(sessionId)Switch to a different session
addMessage(message)Add a message
addMessages(messages)Add multiple messages
clearMessages()Clear all messages
updateSessionStatus(sessionId, status)Update a session’s status (drives isExecuting)
setLoading(loading)Set loading state
setError(error)Set error message
reset()Reset all playground state

fd.interrupts (InterruptStore)

Manages human-in-the-loop interrupts with a state machine for each interrupt’s lifecycle.

Query methods

MethodReturnsDescription
fd.interrupts.getPending()InterruptWithState[]Interrupts awaiting action
fd.interrupts.getPendingCount()numberCount of pending interrupts
fd.interrupts.getResolved()InterruptWithState[]Completed interrupts
fd.interrupts.getIsAnySubmitting()booleanWhether any interrupt is being submitted
fd.interrupts.getInterrupt(id)InterruptWithState | undefinedGet interrupt by ID
fd.interrupts.isPending(id)booleanCheck if specific interrupt is pending
fd.interrupts.isSubmitting(id)booleanCheck if specific interrupt is submitting

Interrupt actions

const { actions } = fd.interrupts;
MethodDescription
addInterrupt(interrupt)Add an interrupt
addInterrupts(interrupts)Add multiple interrupts
startSubmit(id, value)Begin submitting a response
submitSuccess(id)Mark submission as successful
submitFailure(id, error)Mark submission as failed
startCancel(id)Begin cancelling an interrupt
retry(id)Retry a failed submission
resolveInterrupt(id, value)Resolve an interrupt
cancelInterrupt(id)Cancel an interrupt
clearInterrupts()Clear all interrupts
reset()Reset the store

State machine

Each interrupt transitions through these states:
pending → submitting → resolved
                    → error → submitting (retry)
pending → cancelling → cancelled

fd.categories (CategoriesStore)

Manages node category definitions.
MemberReturnsDescription
fd.categories.categoriesCategoryDefinition[]All categories sorted by weight
fd.categories.getLabel(category)stringDisplay label for a category
fd.categories.getIcon(category)stringIconify icon ID for a category
fd.categories.getColor(category)stringCSS color for a category
fd.categories.getDefinition(category)CategoryDefinition | undefinedFull definition
fd.categories.initialize(categories)voidLoad categories from API

Next steps