plan.md
backend/routes/generate_code.py)asyncio.gather() to wait for ALL tasks to completevariantIndex to route to correct variantfrontend/src/generateCode.ts: WebSocket client that only triggers onComplete when connection closesfrontend/src/App.tsx: Sets AppState.CODING during generation, blocking UIfrontend/src/components/variants/Variants.tsx: Only shows variants when generation is completeUser Request → Generate All Variants → Wait for All → Close WS → Show Results → Allow Interaction
User Request → Start Generation → Show First Complete → User Can Interact → Cancel Others if Needed
WebSocket Protocol Enhancement
"variantComplete" to signal individual variant completionpending, generating, complete, failed, cancelledGeneration Logic
# Instead of:
completions = await asyncio.gather(*tasks, return_exceptions=True)
# Use:
async def process_variants():
for index, task in enumerate(tasks):
try:
completion = await task
await send_message("variantComplete", index)
# Allow frontend to interact immediately
except Exception as e:
await send_message("variantFailed", index)
State Management
project-store.ts:
interface VariantState {
code: string;
status: 'pending' | 'generating' | 'complete' | 'failed' | 'cancelled';
generationTime?: number;
}
UI Updates
WebSocket Client
variantComplete message typeProgressive Loading
Update Flow
Visual Feedback
Phase 1: Backend Protocol (2-3 days)
Phase 2: Frontend State (2-3 days)
Phase 3: UI Components (2-3 days)
Phase 4: Testing & Polish (2 days)
Complexity: More state to manage
Race Conditions: User updates while variants generating
UI Confusion: Users might not understand partial results