Architecture: How should the PhaseOrchestrator SSE output reach the fronte...
Documentation for Sessions
🏗️ Architecture: How should the PhaseOrchestrator SSE output reach the fronte...
Date: 2026-02-06
Time: 02:18:31 UTC
Session: editor2-95.4
Agent: backend
Confidence: 92%
Status: ✅ Documented
📋 Decision Context
Question:
How should the PhaseOrchestrator SSE output reach the frontend Module Workbench?
Task: P0-A: Wire PhaseOrchestrator → adapter → API → frontend
🎯 Decision Made
Chosen:
Enrich the orchestration_complete SSE event with full moduleContext + generatedFiles inline. Also add 3 REST endpoints (GET /modules/:id/context, GET /modules/:id/files, GET /modules/recent) as fallback. Create AIModuleReceiverService on frontend that handles both inline and fetch-based reception, saves to ModuleStorageService, exposes lastReceivedModuleId signal.
Options Considered:
- Enrich SSE + REST fallback + dedicated receiver service
- WebSocket push only
- Polling from frontend
💭 Reasoning
The SSE event already fires but was empty. By enriching it with the adapted ModuleContext inline, the frontend can process it immediately without a second round-trip. The REST endpoints serve as fallback for page reloads, loading recent modules, and the case where the SSE event was missed. The AIModuleReceiverService decouples the SSE transport from the Workbench UI — it handles reception, persistence, and signaling independently.
📁 Files Involved
apis/backend-ai-api/src/app/workflow/phase-executor/phase-orchestrator.service.tsapis/backend-ai-api/src/app/workflow/workflow.controller.tslibs/libs-structural/modularity-lib/src/lib/services/ai-module-receiver.service.ts
🔗 Related
- Decision ID:
dev_1770344311084_zvh6o2t - Session: 95
- Workspace: editor2
Auto-generated by MCP Smart Consolidation