FLOW COMPOSER PHASE 1 2 COMPLETE

Documentation for Plans

๐Ÿš— Flow Composer - Phase 1 & 2 Complete!

Date: October 13, 2025
Status: โœ… PHASES 1-2 COMPLETE


๐ŸŽ‰ What's Been Implemented

โœ… Phase 1: Real Port Extraction

File: libs/singularity-lib/src/lib/services/flow-composition.service.ts

Intelligent Port Detection

Key Methods

extractInputPorts(flow): FlowPort[]  // Finds all trigger blocks
extractOutputPorts(flow): FlowPort[] // Finds all output blocks

Result


โœ… Phase 2: Flow Node Dragging

Files:

Drag Functionality

Technical Implementation

// Drag state tracking
isDraggingNode = signal(false)
draggedNodeId = signal<string | null>(null)
dragOffset = signal<{ x: number; y: number }>({ x: 0, y: 0 })

// Mouse event handlers
onFlowNodeMouseDown(event, node)  // Start drag
onFlowNodeDrag(event)             // Continue drag
onFlowNodeDragEnd()               // End drag

Visual Polish

.flow-node.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 1000;
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

๐Ÿงช How to Test

Test 1: Port Extraction

  1. Open Flow Composer (/singularity/flow-composer)
  2. Drag a flow onto the canvas
  3. โœ… Verify: Flow node shows:
    • Real port names (not "INPUTS")
    • Input ports from trigger blocks
    • Output ports from output blocks
    • Port data types displayed

Test 2: Flow Node Dragging

  1. Open Flow Composer
  2. Drag a flow onto canvas
  3. Click and hold on the flow node
  4. Drag the node around the canvas
  5. โœ… Verify:
    • Node follows mouse smoothly
    • Node opacity changes to 0.8
    • Node scales to 1.05x
    • Shadow increases
    • Cursor changes to "grabbing"
  6. Release mouse
  7. โœ… Verify:
    • Node stays in new position
    • Node returns to normal appearance
    • Position persists after save

Test 3: Grid Snapping

  1. Enable grid in canvas controls
  2. Drag a node
  3. โœ… Verify: Node snaps to grid points (20px intervals)

Test 4: Multiple Nodes

  1. Drag 3+ flows onto canvas
  2. Drag each node to different positions
  3. โœ… Verify: All nodes can be dragged independently

Test 5: Undo/Redo

  1. Drag a node
  2. Press Ctrl+Z to undo
  3. โœ… Verify: Node returns to previous position
  4. Press Ctrl+Y to redo
  5. โœ… Verify: Node returns to dragged position

๐Ÿ“Š Current Capabilities

Feature Status Notes
Load flows from storage โœ… Working Fixed storage-system integration
Drag flows FROM library โœ… Working Original functionality
Drag flows ONTO canvas โœ… Working Original functionality
Extract real ports โœ… NEW Trigger & output blocks detected
Drag nodes ON canvas โœ… NEW Smooth, grid-snapped dragging
Visual drag feedback โœ… NEW Opacity, scale, shadow
Undo/Redo dragging โœ… NEW Position history tracking
Connect flows โŒ Next Phase 3
SVG connections โŒ Next Phase 3
Validate connections โŒ Next Phase 3

๐ŸŽฏ What's Next: Phase 3

Connection System Implementation

Will enable:

Estimated Time: 3-4 hours


๐Ÿ”ง Technical Details

Drag Implementation Pattern

// 1. Start drag on mousedown
onFlowNodeMouseDown(event, node) {
  // Calculate mouse offset from node position
  // Set isDraggingNode = true
  // Store draggedNodeId
}

// 2. Update position on mousemove
onFlowNodeDrag(event) {
  // Calculate new canvas position
  // Apply grid snapping if enabled
  // Update node position in flowNodes()
}

// 3. End drag on mouseup
onFlowNodeDragEnd() {
  // Save to history for undo/redo
  // Reset drag state
}

Canvas Coordinate System

// Screen โ†’ Canvas coordinates
const canvasX = (screenX - rect.left - offset.x) / zoom;
const canvasY = (screenY - rect.top - offset.y) / zoom;

// Grid snapping (20px)
const snappedX = Math.round(canvasX / 20) * 20;
const snappedY = Math.round(canvasY / 20) * 20;

๐Ÿ“ Files Modified

Services

Components


๐Ÿ› Issues Fixed

  1. Port extraction was using mock data

    • โœ… Now extracts real ports from flow blocks
  2. Nodes couldn't be moved after placement

    • โœ… Full drag support with smooth animations
  3. No visual feedback during interactions

    • โœ… Opacity, scale, cursor changes implemented

๐ŸŽ“ Architecture Lessons

Signal-Based Reactivity

All drag state managed through Angular signals:

Event Delegation

Coordinate Math


Status: โœ… READY TO TEST

Test the new functionality and we'll move on to Phase 3: Connection System! ๐Ÿš€