Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Fix malformed Anthropic JSON
Abi Rajac15dd057d6e5
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.pyindex dfa511a6..8fc969ca 100644--- a/backend/routes/generate_code.py+++ b/backend/routes/generate_code.py@@ -366,10 +366,11 @@ class ModelSelectionStage:) -> List[Llm]:"""Select appropriate models based on available API keys"""try:+ num_variants = 2 if generation_type == "update" else NUM_VARIANTSvariant_models = self._get_variant_models(generation_type,input_mode,- NUM_VARIANTS,+ num_variants,openai_api_key,anthropic_api_key,gemini_api_key,@@ -409,6 +410,14 @@ class ModelSelectionStage:)return list(VIDEO_VARIANT_MODELS)+ # Edit/update mode prefers one Gemini + one OpenAI model for fast,+ # complementary deltas.+ if generation_type == "update" and gemini_api_key and openai_api_key:+ return [+ Llm.GEMINI_3_FLASH_PREVIEW_MINIMAL,+ Llm.GPT_5_2_CODEX_LOW,+ ]+# Define models based on available API keysif gemini_api_key and anthropic_api_key and openai_api_key:if input_mode == "text" and generation_type == "create":@@ -684,10 +693,16 @@ class StatusBroadcastMiddleware(Middleware):async def process(self, context: PipelineContext, next_func: Callable[[], Awaitable[None]]) -> None:- # Determine variant count based on input mode+ # Determine variant count based on input mode and generation type.+ # Edit/update flows use two variants to keep latency and cost down.assert context.extracted_params is not Noneis_video_mode = context.extracted_params.input_mode == "video"- num_variants = NUM_VARIANTS_VIDEO if is_video_mode else NUM_VARIANTS+ is_update = context.extracted_params.generation_type == "update"+ num_variants = (+ NUM_VARIANTS_VIDEO+ if is_video_mode+ else 2 if is_update else NUM_VARIANTS+ )# Tell frontend how many variants we're usingawait context.send_message("variantCount", str(num_variants), 0)diff --git a/backend/routes/model_choice_sets.py b/backend/routes/model_choice_sets.pyindex b1e4ffae..ac9b487b 100644--- a/backend/routes/model_choice_sets.py+++ b/backend/routes/model_choice_sets.py@@ -15,8 +15,6 @@ ALL_KEYS_MODELS_TEXT_CREATE = ()ALL_KEYS_MODELS_UPDATE = (Llm.GEMINI_3_FLASH_PREVIEW_MINIMAL,- Llm.GPT_5_2_CODEX_HIGH,- Llm.CLAUDE_SONNET_4_6,Llm.GPT_5_2_CODEX_LOW,)ALL_KEYS_MODELS_DEFAULT = (diff --git a/backend/tests/test_model_selection.py b/backend/tests/test_model_selection.pyindex 72be4cd1..5dfbb73e 100644--- a/backend/tests/test_model_selection.py+++ b/backend/tests/test_model_selection.py@@ -33,7 +33,7 @@ class TestModelSelectionAllKeys:@pytest.mark.asyncioasync def test_gemini_anthropic_update_text(self):- """All keys text update: uses edit-specific model mix."""+ """All keys text update: uses two fast edit variants."""models = await self.model_selector.select_models(generation_type="update",input_mode="text",@@ -44,15 +44,13 @@ class TestModelSelectionAllKeys:expected = [Llm.GEMINI_3_FLASH_PREVIEW_MINIMAL,- Llm.GPT_5_2_CODEX_HIGH,- Llm.CLAUDE_SONNET_4_6,Llm.GPT_5_2_CODEX_LOW,]assert models == expected@pytest.mark.asyncioasync def test_gemini_anthropic_update(self):- """All keys update: uses edit-specific model mix."""+ """All keys image update: uses two fast edit variants."""models = await self.model_selector.select_models(generation_type="update",input_mode="image",@@ -63,8 +61,6 @@ class TestModelSelectionAllKeys:expected = [Llm.GEMINI_3_FLASH_PREVIEW_MINIMAL,- Llm.GPT_5_2_CODEX_HIGH,- Llm.CLAUDE_SONNET_4_6,Llm.GPT_5_2_CODEX_LOW,]assert models == expecteddiff --git a/backend/tests/test_status_broadcast.py b/backend/tests/test_status_broadcast.pyindex 1024e4af..b5093513 100644--- a/backend/tests/test_status_broadcast.py+++ b/backend/tests/test_status_broadcast.py@@ -60,3 +60,54 @@ async def test_video_update_broadcasts_two_variants() -> None:assert len(status_messages) == 2assert [m[2] for m in status_messages] == [0, 1]assert next_called is True+++async def test_image_update_broadcasts_two_variants() -> None:+ sent_messages: list[tuple[str, str | None, int]] = []++ async def send_message(+ msg_type: str,+ value: str | None,+ variant_index: int,+ data=None,+ eventId=None,+ ) -> None:+ sent_messages.append((msg_type, value, variant_index))++ context = PipelineContext(websocket=MagicMock())+ context.ws_comm = cast(+ Any,+ SimpleNamespace(+ send_message=send_message,+ throw_error=AsyncMock(),+ ),+ )+ context.extracted_params = ExtractedParams(+ stack="html_tailwind",+ input_mode="image",+ should_generate_images=True,+ openai_api_key="key",+ anthropic_api_key="key",+ openai_base_url=None,+ generation_type="update",+ prompt={"text": "Edit this screenshot", "images": ["data:image/png;base64,abc"], "videos": []},+ history=[],+ file_state={"path": "index.html", "content": "<html></html>"},+ option_codes=[],+ )++ middleware = StatusBroadcastMiddleware()+ next_called = False++ async def next_func() -> None:+ nonlocal next_called+ next_called = True++ await middleware.process(context, next_func)++ assert sent_messages[0] == ("variantCount", "2", 0)+ status_messages = [m for m in sent_messages if m[0] == "status"]+ assert len(status_messages) == 2+ assert [m[2] for m in status_messages] == [0, 1]+ assert next_called is True