Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

fix bug with history not being updated if image generation fails

Abi Rajaf1a9859384a1
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index d34f8616..b260cc0a 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -254,6 +254,9 @@ async def stream_code(websocket: WebSocket):
except Exception as e:
traceback.print_exc()
print("Image generation failed", e)
+ # Send set code even if image generation fails since that triggers
+ # the frontend to update history
+ await websocket.send_json({"type": "setCode", "value": completion})
await websocket.send_json(
{"type": "status", "value": "Image generation failed but code is complete."}
)