Skip to main content
neutral

Phase 23 — Visual Workflow Builder (Full Rewrite)

Replaces the existing flow builder (components/flow/) with an n8n-style visual workflow builder featuring schema-driven node configuration, live execution visualization, expression-based data mapping, Postgres persistence with versioning, dynamic MCP tool palette, and comprehensive test coverage.

Status: Not Started Depends on: Phase 22 (UI Remediation), Phase 20 (React UI), Phase 14 (Production API) Migrations: NNNN_workflow_definitions.sql (new tables) Branch: feature-react-ui


Why Now

Phase 20 delivered a functional flow builder with 8 node types, React Flow canvas, Zustand state, validation, serialization, and GitHub-backed persistence. However, the builder has significant architectural limitations that prevent it from reaching n8n-level usability:

  1. No schema-driven configuration. The PropertyPanel uses hardcoded fields per node type. Adding a new tool requires modifying React code rather than simply registering a JSON schema.

  2. No expression/data mapping engine. Nodes cannot reference output from upstream nodes. The condition field is a plain text input with no parsing, validation, or autocomplete.

  3. No live execution visualization. Preview is a synchronous request/response cycle. There is no real-time SSE streaming of per-node execution states.

  4. No execution history. Only git commit history exists. Users cannot view past workflow runs, drill into per-node results, or replay executions.

  5. No dynamic tool discovery. The palette is static with 3 hardcoded groups. It does not discover tools from the MCP registry or tool registry API.

  6. Missing node types. LLM decision nodes, supervisor nodes (7 patterns), and trigger nodes are absent.

  7. Limited canvas features. No grid snapping, minimap, clipboard (copy/paste), or keyboard shortcuts beyond delete.

Phase 23 performs a full rewrite in a new components/flow-v2/ directory, preserving the existing flow builder until the rewrite is complete.


Architecture

Phase 23 follows a layered architecture with clean separation of concerns:

  1. Canvas Layer (23A): React Flow canvas with custom node/edge components, Zustand state management with undo/redo, drag-and-drop palette, and keyboard shortcuts.

  2. Configuration Layer (23B): Generic SchemaFormRenderer that reads JSON Schema and generates form fields. Per-node configuration panels with tabs (Parameters, Settings, Output). Expression editor with autocomplete.

  3. Execution Layer (23C): Workflow execution via Temporal, SSE streaming of per-node states, visual execution overlay, result inspection drawer.

  4. Persistence Layer (23D): Postgres-backed CRUD, workflow versioning (draft/published), execution history, graph compiler/decompiler for GraphDSL ↔ visual canvas.

  5. Discovery Layer (23E): Dynamic palette populated from tool registry and MCP servers. Template gallery. Node grouping/subgraph support.

  6. Quality Layer (23F): Unit tests (vitest, 80%+), integration tests (Go), E2E tests (Playwright), SonarQube frontend coverage.


Sub-Phases

Sub-PhaseNamePromptsDepends On
23ACanvas Architecture & Node Framework5
23BSchema-Driven Node Configuration623A
23CExecution Engine & Live Visualization523A, 23B
23DPersistence, Versioning & History523A, 23C
23EDynamic Palette & MCP Integration423A, 23B
23FTest Coverage & Quality523A–23E

Total: 6 sub-phases, 30 prompts

Dependency Graph

23A (Canvas Architecture) ─────────┬──→ 23B (Schema Config) ──┬──→ 23C (Execution) ──→ 23D (Persistence)
│ │ │
└──→ 23E (Dynamic Palette) ─┘ │

23F (Tests)

23A is the foundation. 23B and 23E can start after 23A. 23C needs 23A+23B. 23D needs 23A+23C. 23F is last.


Sub-Phase Details

23A: Canvas Architecture & Node Framework

Builds the new React Flow canvas with infinite pan/zoom, grid snapping, minimap, new node component architecture with typed input/output ports, connection type validation, Zustand state with undo/redo and clipboard, categorized palette sidebar with search and drag-and-drop, keyboard shortcuts, and the new serialization format.

23B: Schema-Driven Node Configuration

Builds the generic SchemaFormRenderer component that reads JSON Schema and generates form fields. Creates per-node configuration panels with tabs (Parameters, Settings, Output). Implements the expression editor with {{nodes.<id>.output.<path>}} syntax and autocomplete. Covers all node types: tool nodes, LLM decision nodes, control flow nodes, approval/HITL nodes, supervisor nodes (7 patterns), and start/end/trigger nodes.

23C: Execution Engine & Live Visualization

Implements workflow execution from canvas (full run and execute-to-node). Adds the backend /api/workflows/\{id\}/execute endpoint that submits the graph to Temporal. Streams per-node execution state via SSE/NATS. Adds visual execution states (idle → pending → running → success/error), result badges, node result drawer, execution log timeline, and cancel button.

23D: Persistence, Versioning & History

Adds Postgres-backed workflow CRUD (create, read, update, delete, duplicate). Implements workflow versioning with immutable published versions and draft editing. Adds execution history view with per-node result drill-down and read-only replay mode. Builds the graph compiler (visual → Graph DSL) and decompiler (Graph DSL → visual). Includes SQL migration.

23E: Dynamic Palette & MCP Integration

Auto-discovers MCP tools from the registry and generates palette entries dynamically. Generates node configuration panels from MCP tool schemas using SchemaFormRenderer. Adds node grouping/subgraph support (collapse selected nodes). Creates template gallery with 5–8 pre-built workflow templates.

23F: Test Coverage & Quality

Achieves 80%+ test coverage across all Phase 23 code. Unit tests for canvas components, SchemaFormRenderer, expression parser, flow compiler/decompiler. Integration tests for all new backend endpoints. E2E tests for the full workflow builder user journey. SonarQube frontend coverage configuration.


Files Overview

New Files

FileSub-PhaseDescription
cmd/ui/frontend/src/components/flow-v2/23ANew flow builder component directory
cmd/ui/frontend/src/components/flow-v2/Canvas.tsx23AMain React Flow canvas
cmd/ui/frontend/src/components/flow-v2/Toolbar.tsx23ATop toolbar with actions
cmd/ui/frontend/src/components/flow-v2/nodes/23ANode components (FlowNode, per-type)
cmd/ui/frontend/src/components/flow-v2/edges/23AEdge components
cmd/ui/frontend/src/components/flow-v2/palette/NodePalette.tsx23ACategorized palette sidebar
cmd/ui/frontend/src/stores/flow-builder.ts23ANew Zustand store
cmd/ui/frontend/src/types/flow-builder.ts23ANew type definitions
cmd/ui/frontend/src/lib/flow-graph-schema.json23AVisual graph JSON schema
cmd/ui/frontend/src/components/flow-v2/config/SchemaFormRenderer.tsx23BSchema → form field renderer
cmd/ui/frontend/src/components/flow-v2/config/ExpressionEditor.tsx23BExpression editor with autocomplete
cmd/ui/frontend/src/components/flow-v2/config/panels/23BPer-node-type config panels
cmd/ui/frontend/src/lib/schema-to-form.ts23BSchema → field mapping logic
cmd/ui/frontend/src/lib/expression-parser.ts23BExpression parsing and evaluation
cmd/ui/frontend/src/components/flow-v2/execution/ExecutionOverlay.tsx23CVisual execution state overlay
cmd/ui/frontend/src/components/flow-v2/execution/NodeResultDrawer.tsx23CPer-node result inspection
cmd/ui/frontend/src/components/flow-v2/execution/ExecutionTimeline.tsx23CExecution log timeline
cmd/ui/frontend/src/api/workflow-execution.ts23CExecution API client
cmd/ui/workflow_execution_handler.go23CBackend execution handler
cmd/ui/frontend/src/api/workflow-crud.ts23DWorkflow CRUD API client
cmd/ui/frontend/src/components/flow-v2/history/ExecutionHistoryPanel.tsx23DExecution history view
cmd/ui/frontend/src/components/flow-v2/history/RunReplayOverlay.tsx23DRead-only run replay
cmd/ui/frontend/src/lib/flow-compiler.ts23DVisual → Graph DSL compiler
cmd/ui/frontend/src/lib/flow-decompiler.ts23DGraph DSL → visual decompiler
cmd/ui/workflow_crud_handler.go23DBackend CRUD handler
internal/store/workflow_store.go23DPostgres workflow store
migrations/NNNN_workflow_definitions.sql23DDatabase migration
cmd/ui/frontend/src/components/flow-v2/palette/DynamicNodePalette.tsx23EMCP-aware dynamic palette
cmd/ui/frontend/src/components/flow-v2/palette/TemplateGallery.tsx23ETemplate browser
cmd/ui/frontend/src/components/flow-v2/grouping/NodeGrouping.tsx23ENode grouping/subgraph
cmd/ui/frontend/src/api/tool-schemas.ts23ETool schema API client
cmd/ui/tool_schemas_handler.go23EBackend tool schema handler
cmd/ui/frontend/src/__tests__/flow-v2/23FUnit test directory
cmd/ui/frontend/e2e/flow-builder-v2.spec.ts23FE2E test spec
cmd/ui/workflow_execution_handler_test.go23FBackend handler tests
cmd/ui/workflow_crud_handler_test.go23FBackend CRUD handler tests
cmd/ui/tool_schemas_handler_test.go23FBackend schema handler tests
internal/store/workflow_store_test.go23FPostgres store tests

Modified Files

FileSub-PhaseChange
cmd/ui/main.go23C, 23D, 23ERegister new API endpoints
cmd/ui/phase20_routes.go23C, 23D, 23EAdd new route registrations
cmd/ui/frontend/src/App.tsx23AAdd flow builder v2 route
cmd/ui/frontend/src/components/layout/Sidebar.tsx23AUpdate flows nav item to use v2
cmd/ui/frontend/vitest.config.ts23FAdd coverage configuration
sonar-project.properties23FAdd JS/TS coverage paths

Success Metrics

MetricTarget
Node types supported>= 12 (start, end, tool, route, parallel, join, subgraph, approval, llm_decision, supervisor, trigger, group)
Tool schema coverage100% of registered tools have palette entries
Schema → form fieldsAll JSON Schema types mapped (string, number, boolean, enum, object, array, code)
Expression autocompleteUpstream node outputs resolved with path completion
Execution visualizationReal-time SSE per-node state updates
PersistencePostgres CRUD with versioning (draft/published)
Graph DSL round-tripCompiler + decompiler produce equivalent graphs
Frontend unit coverage>= 80% (flow-v2 components)
Backend handler coverage>= 80% (new handlers)
E2E coverageFull create → configure → execute → verify journey
Canvas UXGrid snap, minimap, undo/redo, copy/paste, keyboard shortcuts
npm run buildPasses without errors
go build ./cmd/ui/Passes without errors

Code Quality Requirements

  • ESLint: All new .tsx files pass existing ESLint config without warnings.
  • TypeScript: Strict mode — no any types, discriminated unions for node types, explicit return types on API functions.
  • Vitest: Coverage reporter configured with v8 provider, lcov output for SonarQube.
  • SonarQube: sonar.javascript.lcov.reportPaths set to frontend coverage output.
  • Go: All new backend code passes go vet, staticcheck, and existing CI checks.
  • Bundle size: Flow builder v2 page chunk under 100KB gzipped (canvas + React Flow + Monaco lazy-loaded).
  • Accessibility: All form fields have labels, keyboard-navigable palette, focus management in panels.

Risk Mitigation

RiskMitigation
React Flow performance with large graphs (100+ nodes)Implement node virtualization, memoize node components, lazy-render off-screen nodes
Monaco editor bundle sizeLazy-load Monaco via dynamic import; only load when code/expression fields are opened
Expression parser complexityStart with simple path expression syntax; defer function calls to a later phase
Graph DSL round-trip fidelity23F includes compiler/decompiler round-trip unit tests with property-based testing
Existing flow builder disruptionv2 lives in components/flow-v2/; existing builder remains functional until v2 is complete
Database migration riskMigration is additive (new tables only); no existing tables modified
SSE connection managementReuse existing hooks/useSSE.ts pattern; add reconnection and heartbeat

Relationship to Other Phases

PhaseRelationship
Phase 20 (React UI)23 replaces 20's flow builder; reuses 20's routing, components, API client patterns
Phase 22 (UI Remediation)23 builds on 22's test infrastructure and component library improvements
Phase 14 (Production API)23 backend handlers follow Phase 14 route patterns
Phase 7F (Graph DSL)23D compiler targets the Graph DSL from Phase 7F
Phase 10 (Supervisor)23B supervisor node panels reflect Phase 10's 7 patterns
Phase 9 (Tool Registry)23E dynamic palette consumes Phase 9's tool registry
Phase 12 (Events)23C execution streaming uses Phase 12's NATS/SSE infrastructure
Phase 16 (Test Coverage)23F extends Phase 16's coverage patterns to the flow builder

Investigation Notes


Progress Notes

(none yet)