Portal Community

enterExecutionMode

enterExecutionMode: (executionId: string) => void

// Called when:
// - User clicks Run (starts a new execution)
// - User opens a past execution from the run history panel

const { enterExecutionMode } = useDesignerModeStore.getState();
enterExecutionMode('exec-abc-123');

// What happens:
// 1. currentMode  = "execution"
// 2. executionId  = "exec-abc-123"
// 3. isReadonly   = true
// 4. nodeStatuses = {}  (cleared — fresh slate for this run)
// 5. runProgress  = { totalNodes: nodes.length, completedNodes: 0, failedNodes: 0, progressPct: 0 }
// 6. If past run: bulk-loads statuses from API immediately after

exitExecutionMode

exitExecutionMode: () => void

// Called when:
// - User clicks "Back to Design" in the canvas toolbar
// - Execution completes and user dismisses the result overlay

const { exitExecutionMode } = useDesignerModeStore.getState();
exitExecutionMode();

// What happens:
// 1. currentMode  = "design"
// 2. executionId  = null
// 3. isReadonly   = false
// 4. nodeStatuses = {}  (cleared)
// 5. runProgress  reset to zeros
// 6. SignalR connection for this execution is disconnected

enterReadonly

enterReadonly: () => void

// Called when:
// - User with Viewer role opens the canvas
// - Workflow is embedded in a read-only context

const { enterReadonly } = useDesignerModeStore.getState();
enterReadonly();

// What happens:
// 1. currentMode = "readonly"
// 2. isReadonly  = true
// 3. executionId remains null
// 4. nodeStatuses unchanged (may be pre-populated for display)

exitReadonly

exitReadonly: () => void

// Called when user's role is elevated (e.g., granted Editor access mid-session)
const { exitReadonly } = useDesignerModeStore.getState();
exitReadonly();

// What happens:
// 1. currentMode = "design"
// 2. isReadonly  = false

Transition Sequence for Run and Return

// 1. User clicks Run
enterExecutionMode(newExecutionId);

// 2. SignalR events update nodeStatuses in real time as nodes execute
// ... setNodeStatus, updateRunProgress called by SignalR handler ...

// 3. Execution ends — SignalR sends ExecutionCompleted event

// 4. User dismisses result overlay (or clicks "Back to Design")
exitExecutionMode();
enterExecutionMode clears nodeStatuses. If a component is currently reading statuses from the old execution, it will briefly see an empty map. Components should handle an empty nodeStatuses gracefully — showing "pending" for all nodes is the correct fallback until statuses arrive.