Phase 2 - Flow → Page Connection
Connect Singularity flows to Editor pages for interactive functionality
Phase 2: Flow → Page Connection
Priority: P1 - HIGH
Duration: 2-3 days
Status: 🟢 IN PROGRESS
Started: October 28, 2025
🎯 Objectives
Enable pages to have Singularity flows attached, creating interactive functionality and data pipelines.
Problems Being Solved
- Flows are isolated - Created in Singularity but not connected to pages
- No page interactivity - Pages are static without attached logic
- Manual wiring required - No easy way to connect flows to page events
- No visual feedback - Can't see which flows are attached to which pages
📋 Implementation Checklist
Files to Create
-
phase-2-flow-connection.md- This documentation -
libs/core-angular/src/lib/services/flow-attachment.service.ts -
libs/editor-ui/src/lib/components/flow-attachment/flow-attachment-panel.component.ts -
libs/editor-ui/src/lib/components/flow-attachment/flow-attachment-panel.component.html -
libs/editor-ui/src/lib/components/flow-attachment/flow-attachment-panel.component.scss -
libs/editor-ui/src/lib/components/flow-attachment/flow-list-item.component.ts
Files to Modify
-
libs/editor-ui/src/lib/components/editor-ui/editor-ui.component.ts- Add flow panel -
libs/editor-ui/src/lib/components/editor-ui/editor-ui.component.html- Add flow panel UI -
libs/core-angular/src/lib/services/index.ts- Export FlowAttachmentService -
libs/editor-ui/src/index.ts- Export flow components
🏗️ Architecture
FlowAttachmentService
@Injectable({ providedIn: 'root' })
export class FlowAttachmentService {
// Attach flow to page
async attachFlow(pageId: string, flowId: string, trigger?: FlowTrigger): Promise<void>
// Detach flow from page
async detachFlow(pageId: string, flowId: string): Promise<void>
// Get flows for page
getFlowsForPage(pageId: string): Signal<FlowWithMetadata[]>
// Get pages using flow
getPagesUsingFlow(flowId: string): Signal<WorldWithMetadata[]>
// Execute flow for page
async executeFlow(pageId: string, flowId: string, context: any): Promise<any>
}
Flow Triggers
Flows can be triggered by:
- Page Load - Execute when page loads
- Widget Event - Execute when widget fires event (button click, form submit, etc.)
- Timer - Execute on schedule
- External Event - Execute from external source (webhook, API call)
- Manual - Execute manually from UI
Flow Attachment UI
┌─────────────────────────────────────┐
│ 📊 Attached Flows (3) │
├─────────────────────────────────────┤
│ 🔵 User Authentication Flow │
│ Trigger: Page Load │
│ Status: ✅ Active │
│ [Edit] [Detach] │
├─────────────────────────────────────┤
│ 🟢 Form Submission Handler │
│ Trigger: Widget Event (submit) │
│ Status: ✅ Active │
│ [Edit] [Detach] │
├─────────────────────────────────────┤
│ + Attach Flow │
└─────────────────────────────────────┘
🔧 Implementation Details
Step 1: Create FlowAttachmentService
File: libs/core-angular/src/lib/services/flow-attachment.service.ts
Key Features:
- Uses UnifiedDataService for data access
- Manages flow-page relationships
- Persists attachments to storage
- Reactive signals for real-time updates
- Trigger configuration
- Flow execution coordination
Step 2: Create FlowAttachmentPanel Component
File: libs/editor-ui/src/lib/components/flow-attachment/flow-attachment-panel.component.ts
Features:
- List attached flows for current page
- Add new flow attachments
- Configure flow triggers
- Detach flows
- Test flow execution
- Visual status indicators
Step 3: Integrate into Editor
File: libs/editor-ui/src/lib/components/editor-ui/editor-ui.component.ts
Changes:
- Add flow panel to right sidebar
- Show flow count badge
- Enable flow panel toggle
- Pass current page context
Step 4: Flow Execution Engine
Coordinate with Singularity to execute flows:
// When flow is triggered
const result = await flowExecutionService.execute(flowId, {
pageId: currentPageId,
widgetId: triggerWidgetId,
eventData: eventData,
pageContext: pageContext
});
// Update widgets with flow output
await updateWidgetsFromFlowOutput(result);
✅ Acceptance Criteria
Flow Attachment
- Can attach flow to page from Editor
- Can detach flow from page
- Attachments persist to storage
- Can see all attached flows for page
Flow Triggers
- Can configure trigger type (page load, widget event, etc.)
- Can specify trigger widget for widget events
- Triggers are saved with attachment
Flow Execution
- Page load flows execute on page load
- Widget event flows execute on widget events
- Flow execution is logged
- Errors are caught and displayed
UI/UX
- Flow panel is accessible from Editor
- Flow count badge shows attached flow count
- Can browse available flows
- Can test flow execution manually
- Visual feedback for flow status
Data Integration
- UnifiedDataService shows attachedFlowCount
- Launch Station shows flow count per universe
- Modularity can package pages with flows
🧪 Testing Plan
Unit Tests
describe('FlowAttachmentService', () => {
it('should attach flow to page', async () => {
await service.attachFlow('page-1', 'flow-1');
expect(service.getFlowsForPage('page-1')().length).toBe(1);
});
it('should detach flow from page', async () => {
await service.detachFlow('page-1', 'flow-1');
expect(service.getFlowsForPage('page-1')().length).toBe(0);
});
});
Integration Tests
- Attach flow → verify in storage
- Refresh page → verify flows persist
- Execute flow → verify output
- Detach flow → verify removed
Manual Testing
- Open Editor
- Create a page
- Open Flow Attachment Panel
- Attach a flow
- Configure trigger
- Test execution
- Verify output
📊 Progress Tracking
Created Files
- flow-attachment.service.ts (0% - Not started)
- flow-attachment-panel.component.ts (0% - Not started)
- flow-attachment-panel.component.html (0% - Not started)
- flow-attachment-panel.component.scss (0% - Not started)
- flow-list-item.component.ts (0% - Not started)
Modified Files
- editor-ui.component.ts (0% - Not started)
- editor-ui.component.html (0% - Not started)
- core-angular/services/index.ts (0% - Not started)
- editor-ui/index.ts (0% - Not started)
Overall Progress: 0%
🐛 Known Issues & Blockers
None yet - just starting implementation
📝 Notes & Learnings
- World interface already has
attachedFlowIdsfield (added in Phase 1) - UnifiedDataService computes
attachedFlowCountautomatically - Flow execution will use existing Singularity engine
Last Updated: October 28, 2025 - Starting implementation
Next Checkpoint: FlowAttachmentService implementation complete