Skip to content

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

Python

Fix video mode updates discarding history

Abi Raja91f2b1f6a6e6
diff --git a/backend/prompts/__init__.py b/backend/prompts/__init__.py
index b31d925e..58b5e4d3 100644
--- a/backend/prompts/__init__.py
+++ b/backend/prompts/__init__.py
@@ -46,6 +46,21 @@ async def create_prompt(
prompt_messages = assemble_prompt(image_url, stack, text_prompt)
elif input_mode == "text":
prompt_messages = assemble_text_prompt(prompt["text"], stack)
+ elif input_mode == "video":
+ # For video mode initial creation, extract screenshots from video
+ # For updates, we use the history which already contains the generated code
+ if generation_type == "create":
+ video_data_url = prompt["images"][0]
+ prompt_messages = await assemble_claude_prompt_video(video_data_url)
+ else:
+ # For video mode updates, use the screenshot system prompt
+ # since we're now working with the generated code, not the video
+ prompt_messages = [
+ {
+ "role": "system",
+ "content": SYSTEM_PROMPTS[stack],
+ }
+ ]
else:
# Default to image mode for backward compatibility
image_url = prompt["images"][0]
@@ -61,10 +76,6 @@ async def create_prompt(
image_cache = create_alt_url_mapping(history[-2]["text"])
- if input_mode == "video":
- video_data_url = prompt["images"][0]
- prompt_messages = await assemble_claude_prompt_video(video_data_url)
-
return prompt_messages, image_cache
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index e6ced60b..757d4239 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -923,8 +923,14 @@ class CodeGenerationMiddleware(Middleware):
else:
try:
assert context.extracted_params is not None
- if context.extracted_params.input_mode == "video":
- # Use video generation for video mode
+ # Use video generation stage only for initial video creation
+ # For video updates, use the normal parallel generation path
+ is_video_create = (
+ context.extracted_params.input_mode == "video" and
+ context.extracted_params.generation_type == "create"
+ )
+ if is_video_create:
+ # Use video generation for initial video mode creation
video_stage = VideoGenerationStage(
context.send_message, context.throw_error
)