SINGULARITY ACCURACY FIXES
Ecosistema completo para organización y gestión de contenido con interfaces espaciales
Singularity Logic Builder - Accuracy Fixes
Date: October 12, 2025 Status: ✅ Completed
Overview
Fixed critical accuracy issues in the Logic Builder where test inputs and port connection status were not reflecting the actual flow configuration.
Issue 1: Test Inputs Not Matching Block Requirements ❌→✅
Problem
The Flow Tester was showing generic test inputs (testValue, testString) instead of detecting the actual required inputs from the logic blocks (e.g., Calculate block needs a and b).
Root Cause
The detectFlowInputs() method was only looking at trigger blocks, not analyzing all blocks to find unconnected required input ports.
Solution
File: libs/singularity-lib/src/lib/components/logic-builder/components/flow-tester/flow-tester.component.ts
// Before: Only looked at trigger blocks
const triggers = f.blocks.filter(b => b.type === 'trigger');
// After: Analyzes ALL blocks for unconnected required inputs
// Create a set of connected input ports
const connectedInputs = new Set<string>();
f.connections.forEach(conn => {
connectedInputs.add(`${conn.targetBlockId}:${conn.targetPointId}`);
});
// Find all blocks with unconnected required input ports
f.blocks.forEach(block => {
block.inputs?.forEach(input => {
const inputKey = `${block.id}:${input.id}`;
// Only add if required and NOT connected
if (input.required && !connectedInputs.has(inputKey)) {
inputs.push({
name: input.name,
value: this.getDefaultValue(input.dataType),
type: this.mapDataType(input.dataType)
});
}
});
});
Result
- ✅ Test inputs now accurately reflect what the flow needs
- ✅ Calculate block shows
aandbas number inputs - ✅ Inputs update dynamically when flow changes
- ✅ Only unconnected required inputs appear in test panel
Issue 2: Port Connection Status Always "NOT AVAILABLE" ❌→✅
Problem
All logic block input/output ports were showing as "NOT AVAILABLE" even when they were connected, making it impossible to understand the flow's state.
Root Cause
The isPortConnected() method in logic-block.component.ts was hardcoded to return false:
// Before: Hardcoded to always return false
isPortConnected(port: ConnectionPoint): boolean {
return false;
}
Solution Implemented
1. Added Connections Input to LogicBlockComponent
File: libs/singularity-lib/src/lib/components/logic-builder/components/logic-block/logic-block.component.ts
// Import LogicConnection type
import { LogicBlock, ConnectionPoint, LogicConnection } from '../../../../types/logic-builder.types';
// Add connections input
@Input() connections: LogicConnection[] = [];
2. Fixed isPortConnected() Method
isPortConnected(port: ConnectionPoint): boolean {
if (!this.connections || this.connections.length === 0) {
return false;
}
// Check if this port is connected as either source or target
return this.connections.some(conn =>
// Check as target (input port)
(conn.targetBlockId === this.block.id && conn.targetPointId === port.id) ||
// Check as source (output port)
(conn.sourceBlockId === this.block.id && conn.sourcePointId === port.id)
);
}
3. Pass Connections from Parent
File: libs/singularity-lib/src/lib/components/logic-builder/logic-builder.component.html
<app-logic-block
[block]="block"
[connections]="canvasConnections()"
...other inputs...
/>
Result
- ✅ Input ports correctly show "AVAILABLE" when connected
- ✅ Input ports show "REQUIRED" badge only when unconnected and required
- ✅ Output ports accurately reflect connection state
- ✅ Visual feedback matches actual flow configuration
- ✅ Real-time updates as connections are added/removed
Additional Enhancement: Dynamic Test Input Updates
Added OnChanges Lifecycle
File: flow-tester.component.ts
export class FlowTesterComponent implements OnInit, OnChanges {
ngOnInit(): void {
this.detectFlowInputs();
}
ngOnChanges(): void {
// Re-detect inputs when flow changes
this.detectFlowInputs();
}
}
Benefit
- ✅ Test inputs automatically update when blocks are added/removed
- ✅ Test inputs update when connections change
- ✅ Always shows the most current required inputs
Testing Verification
Test Case 1: Calculate Block with Two Inputs
Setup:
- Button Click (trigger) → Calculate (function)
- Calculate has inputs:
a(number, required),b(number, required) - Both inputs unconnected
Expected:
- ✅ Flow Tester shows 2 inputs:
aandb(both numbers) - ✅ Calculate block shows both ports as "REQUIRED" and "NOT AVAILABLE"
Result: ✅ PASS
Test Case 2: Connected Button → Calculate
Setup:
- Button Click (trigger, outputs:
event) → Calculate (inputs:a,b) - Connection: Button
event→ Calculatea
Expected:
- ✅ Calculate port
ashows "AVAILABLE" (connected) - ✅ Calculate port
bshows "REQUIRED" and "NOT AVAILABLE" (not connected) - ✅ Flow Tester shows only 1 input:
b
Result: ✅ PASS
Test Case 3: Full Flow with All Connections
Setup:
- All blocks connected properly
Expected:
- ✅ All connected ports show "AVAILABLE"
- ✅ Flow Tester shows minimal/no required inputs
- ✅ "Run Test" executes with default or minimal inputs
Result: ✅ PASS
Files Modified
libs/singularity-lib/src/lib/components/logic-builder/components/flow-tester/flow-tester.component.ts- Enhanced
detectFlowInputs()to analyze all blocks - Added
OnChangesfor dynamic updates
- Enhanced
libs/singularity-lib/src/lib/components/logic-builder/components/logic-block/logic-block.component.ts- Added
connectionsinput - Implemented accurate
isPortConnected()logic
- Added
libs/singularity-lib/src/lib/components/logic-builder/logic-builder.component.html- Pass
canvasConnections()to all logic blocks
- Pass
Impact
Before ❌
- Generic test inputs unrelated to flow
- All ports showing "NOT AVAILABLE"
- Confusing user experience
- No way to understand flow requirements
After ✅
- Accurate, dynamic test inputs matching flow needs
- Correct port connection status
- Clear visual feedback
- Easy to understand what the flow requires
Next Steps
- ✅ Test inputs detection - COMPLETE
- ✅ Port connection status - COMPLETE
- ⏳ Variable passing between blocks during execution
- ⏳ Pre-built flow templates
- ⏳ Real-world usage examples
Status: 🎉 100% Accurate Data Display!
The Logic Builder now shows accurate, real-time information about:
- Required inputs for testing
- Port connection states
- Flow requirements
- Block configurations
All data is synchronized with the actual flow state and updates dynamically! 🚀