LOGIC BUILDER ENHANCEMENT PLAN

Ecosistema completo para organización y gestión de contenido con interfaces espaciales

Logic Builder Enhancement Plan

Status: 📋 PLANNED - Ready for Implementation
Date: October 23, 2025
Goal: Make Logic Builder easier to use, more modern, and production-ready


✅ Recent Fixes

1. Test Inputs Now Working

Problem: Test inputs (a=4, b=2) were not reaching the Calculate block.
Fix:

Result: Calculate block now correctly computes 4 + 2 = 6 instead of 0 + 0 = 0 ✅


🎯 Enhancement Categories

1. Block Configuration & Persistence (CRITICAL)

2. User Experience Improvements

3. Advanced Block Features

4. Export/Import/Sharing (JSON)

5. Visual Enhancements

6. Debugging & Testing Tools


1. Block Configuration & Persistence (CRITICAL)

🔴 Issue: Block Inputs Not Configurable

Currently, blocks like "Calculate" have hardcoded input values (0) instead of configurable inputs.

Solution: Enhanced Block Configuration Model

interface LogicBlock {
  id: string;
  name: string;
  type: BlockType;
  category: string;
  
  // ✅ NEW: Comprehensive configuration
  config: {
    // Input configuration
    inputs: {
      [inputName: string]: {
        type: 'variable' | 'constant' | 'connection';
        value?: any;  // For constants
        variableName?: string;  // For variable references
        connectionId?: string;  // For port connections
        defaultValue?: any;
      };
    };
    
    // Output configuration
    outputs: {
      [outputName: string]: {
        variableName?: string;  // Where to store result
      };
    };
    
    // Block-specific settings
    settings: {
      operation?: string;  // For Calculate: 'add', 'subtract', etc.
      [key: string]: any;
    };
    
    // UI/Visual settings
    ui: {
      color?: string;
      icon?: string;
      collapsed?: boolean;
    };
  };
  
  // Existing fields
  position?: { x: number; y: number };
  metadata?: any;
}

Implementation Steps

  1. Add Configuration Panel to Blocks

    • Double-click block → Opens config modal
    • Configure inputs: Choose between:
      • Variable: $a (reads from context)
      • Constant: 5 (hardcoded value)
      • Connection: From another block's output port
    • Configure operation (for Calculate: add/subtract/multiply/etc.)
    • Save configuration to block.config
  2. Update Execution Engine

    • Read block.config.inputs to determine input sources
    • Apply configuration during execution
    • Store outputs according to block.config.outputs
  3. Persist Configuration

    • All configuration stored in LogicBlock JSON
    • Survives save/load/export/import
    • Shareable between users

2. User Experience Improvements

A. Block Templates with Pre-configured Blocks

Current: All blocks start with default/empty configuration
Proposed: Template library with ready-to-use configured blocks

Examples

Math Templates:

String Templates:

Logic Templates:

Benefits


B. Smart Variable Suggestions

Current: User must manually type variable names
Proposed: Auto-suggest available variables

Features

// When configuring input "a":
Available Variables:
  ✅ a (number) = 4
  ✅ b (number) = 2
  ✅ username (string) = "john"
  ⚠️ total (undefined)

C. Block Search & Filtering

Current: Scroll through categories
Proposed: Powerful search

Features


D. Inline Quick Config

Current: Must open config modal for everything
Proposed: Quick actions on block

┌─────────────────────────────┐
│  Calculate                  │
│  [+] ↕ [×] [÷] [%] [^]     │ ← Quick operation selector
│                             │
│  ⚡ a: [   4  ] ⚡           │ ← Inline input editors
│  ⚡ b: [   2  ] ⚡           │
│                             │
│  ➔ result = 6               │ ← Live preview
└─────────────────────────────┘

3. Advanced Block Features

A. Multi-Step Blocks (Composite Blocks)

Concept: Package multiple blocks into a single reusable unit

┌────────────────────────────┐
│  Calculate Total Price      │
│  [Composite Block]          │
│                             │
│  Internal Flow:             │
│  1. Multiply (price × qty)  │
│  2. Calculate Tax           │
│  3. Add Shipping            │
│  4. Apply Discount          │
│                             │
│  Input: price, qty          │
│  Output: totalPrice         │
└────────────────────────────┘

Benefits


B. Conditional Execution

Current: All blocks execute sequentially
Proposed: Conditional branches

interface LogicBlock {
  config: {
    // NEW: Execution conditions
    executionCondition?: {
      type: 'always' | 'conditional';
      condition?: string;  // "$age >= 18"
      skipIfFalse?: boolean;
      alternativeBlockId?: string;  // Execute different block if false
    };
  };
}

UI

┌─────────────────────────────┐
│  Verify Age                 │
│  🔀 if ($age >= 18)         │ ← Conditional indicator
│                             │
│  ✅ → Adult Path            │
│  ❌ → Minor Path            │
└─────────────────────────────┘

C. Loop Blocks

Current: No iteration support
Proposed: Loop over arrays/ranges

┌─────────────────────────────┐
│  🔁 For Each Product        │
│                             │
│  Array: $products           │
│  Item: $product             │
│  Index: $i                  │
│                             │
│  ➔ Calculate Price          │
│  ➔ Add to Cart              │
└─────────────────────────────┘

D. Async/Await Blocks

Current: All operations synchronous
Proposed: Real async operations

┌─────────────────────────────┐
│  ⏳ Fetch User Data         │
│  [Async Block]              │
│                             │
│  URL: /api/users/$userId    │
│  Method: GET                │
│                             │
│  ✅ Success → $userData     │
│  ❌ Error → $error          │
└─────────────────────────────┘

4. Export/Import/Sharing (JSON)

Current State

Flows are stored in local storage as JSON ✅
But not easy to share or export.

Enhancement: Complete Export/Import System

A. Export Flow as JSON

interface ExportedFlow {
  version: '1.0.0';
  flowId: string;
  flowName: string;
  description: string;
  author: string;
  created: string;
  modified: string;
  
  // Complete flow data
  blocks: LogicBlock[];
  connections: LogicConnection[];
  
  // Metadata for import
  requiredVariables: string[];  // Variables this flow expects
  outputVariables: string[];    // Variables this flow produces
  dependencies: string[];       // External dependencies (if any)
  
  // Visual state
  canvasState: {
    zoom: number;
    panX: number;
    panY: number;
  };
}

B. Export Options

  1. Export to File (JSON)

    // ecommerce-order-flow.json
    {
      "version": "1.0.0",
      "flowName": "E-commerce Order Processing",
      "blocks": [...]
    }
    
  2. Export to Clipboard (Share URL)

    https://gograb.space/singularity/import?flow=eyJ2ZXJzaW9u...
    
  3. Export to Library (Save as Template)

    • Save to "My Templates"
    • Share with team
    • Publish to community (future)

C. Import Features

  1. Import from File

    • Drag & drop .json file
    • Validates flow structure
    • Resolves naming conflicts
    • Preserves all configurations
  2. Import from URL

    • Paste share link
    • Preview before import
    • Choose import location
  3. Merge Options

    • Replace: Replace current flow
    • Merge: Add to current canvas
    • New Flow: Create new flow

5. Visual Enhancements

A. Block Themes & Colors

Current: All blocks look similar
Proposed: Color-coded by category

🟦 Math Blocks     → Blue
🟩 String Blocks   → Green
🟨 Logic Blocks    → Yellow
🟧 Storage Blocks  → Orange
🟪 API Blocks      → Purple
🟥 Error Blocks    → Red

Custom Colors


B. Connection Styles

Current: Single line style
Proposed: Multiple connection types

─────────  Normal (data flow)
═══════   Strong (primary path)
┄┄┄┄┄┄┄   Conditional (if/else)
─ ─ ─ ─   Error handling
➜➜➜➜➜➜➜   Loop iteration

C. Minimap

Current: Hard to navigate large flows
Proposed: Minimap in corner

┌────────────────────────────────┐
│  Logic Builder                 │
│                                │
│  [Large Canvas]                │
│                                │
│           ┌──────────┐         │
│           │ [Minimap]│ ← Here │
│           │   .  .   │         │
│           │  .    .  │         │
│           └──────────┘         │
└────────────────────────────────┘

D. Block Execution Visualization

Current: No visual feedback during execution
Proposed: Animated execution flow

1. Block turns yellow when executing
2. Connection animates (flowing dots)
3. Block turns green on success / red on error
4. Result badge shows output value

6. Debugging & Testing Tools

A. Enhanced Flow Tester

Current: Basic input/output testing ✅
Enhancements:

  1. Step-by-Step Execution

    [▶ Play] [⏸ Pause] [⏭ Step] [⏹ Stop]
    
    Current Block: Calculate
    Variables: { a: 4, b: 2 }
    Output: 6
    
  2. Breakpoints

    • Click block gutter → Set breakpoint
    • Execution pauses at breakpoint
    • Inspect variables at that point
  3. Variable Watch

    Watch List:
    ✅ a = 4
    ✅ b = 2
    ✅ result = 6
    ⚠️ total = undefined
    
  4. Execution History

    1. Calculate → 2ms → Success → result=6
    2. Store Data → 5ms → Success
    3. Send Email → 150ms → Success
    

B. Flow Validation

Proposed: Validate flow before execution

Checks

UI

Flow Validation Results:
  ❌ 2 errors
  ⚠️ 3 warnings
  
  Error: Block "Calculate" missing input "b"
  Error: Variable "$total" undefined
  
  Warning: Block "Log" is not connected

C. Performance Profiler

Proposed: Analyze flow performance

Performance Report:
  Total Time: 157ms
  
  Slowest Blocks:
  1. Send Email     150ms  (95.5%)
  2. Store Data      5ms   (3.2%)
  3. Calculate       2ms   (1.3%)
  
  Recommendations:
  - Consider async execution for "Send Email"
  - Cache "Store Data" results

7. Smart Features (AI-Powered - Phase 2)

A. AI Block Configuration

User: "I want to add two numbers"
AI: Creates Calculate block pre-configured with:


B. Flow Suggestions

AI Analyzes: Current flow with Calculate → Store Data
AI Suggests:


C. Natural Language to Flow

User Types: "Get user by ID, calculate age, send birthday email if age is 21"

AI Generates:

1. [API Call] Get User → $user
2. [Calculate] Age from birthdate → $age
3. [Condition] if $age === 21
4. [Email] Send birthday email

🚀 Implementation Priority

Phase 1: Foundation (THIS SPRINT) ✅

Phase 2: Enhanced UX

Phase 3: Advanced Features

Phase 4: Testing & Debugging

Phase 5: AI Integration


📊 Technical Specifications

Storage Structure

// Complete flow stored in GgStorage
{
  "flow_1234567890": {
    "id": "flow_1234567890",
    "name": "My Flow",
    "version": "1.0.0",
    "blocks": [
      {
        "id": "block_001",
        "name": "Calculate",
        "type": "function",
        "category": "math",
        "config": {
          "inputs": {
            "a": { "type": "variable", "variableName": "a" },
            "b": { "type": "constant", "value": 5 }
          },
          "outputs": {
            "result": { "variableName": "total" }
          },
          "settings": {
            "operation": "add"
          },
          "ui": {
            "color": "#3B82F6",
            "collapsed": false
          }
        },
        "position": { "x": 100, "y": 200 }
      }
    ],
    "connections": [
      {
        "id": "conn_001",
        "sourceBlockId": "block_001",
        "sourcePortId": "output",
        "targetBlockId": "block_002",
        "targetPortId": "input"
      }
    ],
    "metadata": {
      "created": "2025-10-23T...",
      "modified": "2025-10-23T...",
      "author": "demo-user",
      "description": "Calculate and store total",
      "tags": ["math", "calculation"]
    }
  }
}

✅ Success Metrics

User Experience

Technical

Functionality


🎯 Next Steps

  1. Implement Block Configuration Modal

    • Design UI mockup
    • Create component
    • Wire up to block.config
  2. Add Export/Import Buttons

    • "Export Flow" button → Download JSON
    • "Import Flow" button → Upload JSON
    • Validate on import
  3. Create Template Library

    • Define 10 useful templates
    • Add "Templates" sidebar
    • Drag & drop to canvas
  4. Enhanced Flow Tester

    • Add step-by-step mode
    • Show variable inspector
    • Add execution history

📚 Resources