Skip to content

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

Python

Remove debug logging

Abi Raja88ad7c31dcab
diff --git a/backend/codegen/utils.py b/backend/codegen/utils.py
index 4b983973..7bd0844a 100644
--- a/backend/codegen/utils.py
+++ b/backend/codegen/utils.py
@@ -11,20 +11,15 @@ def extract_html_content(text: str):
r"(<!DOCTYPE\s+html[^>]*>.*?<html.*?>.*?</html>)", text, re.DOTALL | re.IGNORECASE
)
if match_with_doctype:
- extracted = match_with_doctype.group(1)
- print(f"[HTML Extraction] Successfully extracted {len(extracted)} chars of HTML (with DOCTYPE)")
- return extracted
+ return match_with_doctype.group(1)
# Fall back to just <html> tags
match = re.search(r"(<html.*?>.*?</html>)", text, re.DOTALL)
if match:
- extracted = match.group(1)
- print(f"[HTML Extraction] Successfully extracted {len(extracted)} chars of HTML")
- return extracted
+ return match.group(1)
else:
# Otherwise, we just send the previous HTML over
print(
- "[HTML Extraction] No <html> tags found in the generated content (length: "
- + str(len(text)) + " chars). First 500 chars: " + text[:500]
+ "[HTML Extraction] No <html> tags found in the generated content"
)
return text
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index 9a723c63..757d4239 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -797,11 +797,6 @@ class ParallelGenerationStage:
completion = await task
print(f"{model.value} completion took {completion['duration']:.2f} seconds")
- print(f"[DEBUG] Completion code length: {len(completion['code'])} chars")
- if len(completion['code']) < 200:
- print(f"[DEBUG] Full completion: {completion['code']}")
- else:
- print(f"[DEBUG] First 200 chars: {completion['code'][:200]}")
variant_completions[index] = completion["code"]
try:
diff --git a/frontend/src/generateCode.ts b/frontend/src/generateCode.ts
index d8decc74..410b0216 100644
--- a/frontend/src/generateCode.ts
+++ b/frontend/src/generateCode.ts
@@ -54,28 +54,23 @@ export function generateCode(
ws.addEventListener("message", async (event: MessageEvent) => {
const response = JSON.parse(event.data) as WebSocketResponse;
- try {
- if (response.type === "chunk") {
- callbacks.onChange(response.value, response.variantIndex);
- } else if (response.type === "status") {
- callbacks.onStatusUpdate(response.value, response.variantIndex);
- } else if (response.type === "setCode") {
- console.log(`[WS] Received setCode for variant ${response.variantIndex}, code length: ${response.value.length}`);
- callbacks.onSetCode(response.value, response.variantIndex);
- } else if (response.type === "variantComplete") {
- callbacks.onVariantComplete(response.variantIndex);
- } else if (response.type === "variantError") {
- callbacks.onVariantError(response.variantIndex, response.value);
- } else if (response.type === "variantCount") {
- callbacks.onVariantCount(parseInt(response.value));
- } else if (response.type === "thinking") {
- callbacks.onThinking(response.value, response.variantIndex);
- } else if (response.type === "error") {
- console.error("Error generating code", response.value);
- toast.error(response.value);
- }
- } catch (error) {
- console.error(`[WS] Error processing ${response.type} message:`, error);
+ if (response.type === "chunk") {
+ callbacks.onChange(response.value, response.variantIndex);
+ } else if (response.type === "status") {
+ callbacks.onStatusUpdate(response.value, response.variantIndex);
+ } else if (response.type === "setCode") {
+ callbacks.onSetCode(response.value, response.variantIndex);
+ } else if (response.type === "variantComplete") {
+ callbacks.onVariantComplete(response.variantIndex);
+ } else if (response.type === "variantError") {
+ callbacks.onVariantError(response.variantIndex, response.value);
+ } else if (response.type === "variantCount") {
+ callbacks.onVariantCount(parseInt(response.value));
+ } else if (response.type === "thinking") {
+ callbacks.onThinking(response.value, response.variantIndex);
+ } else if (response.type === "error") {
+ console.error("Error generating code", response.value);
+ toast.error(response.value);
}
});
diff --git a/frontend/src/store/project-store.ts b/frontend/src/store/project-store.ts
index ed4ce5da..b19899c1 100644
--- a/frontend/src/store/project-store.ts
+++ b/frontend/src/store/project-store.ts
@@ -104,13 +104,11 @@ export const useProjectStore = create<ProjectStore>((set) => ({
set((state) => {
const commit = state.commits[hash];
if (!commit) {
- console.error(`[Store] appendCommitCode: Commit not found for hash: ${hash}`);
return state;
}
// Don't update if the commit is already committed
if (commit.isCommitted) {
- console.error(`[Store] appendCommitCode: Attempted to append code to a committed commit: ${hash}`);
- return state; // Return unchanged state instead of throwing
+ return state;
}
const variant = commit.variants[numVariant];
const isFirstCode = !variant.code && variant.thinkingStartTime;
@@ -158,17 +156,13 @@ export const useProjectStore = create<ProjectStore>((set) => ({
setCommitCode: (hash: CommitHash, numVariant: number, code: string) =>
set((state) => {
const commit = state.commits[hash];
- console.log(`[Store] setCommitCode called for hash=${hash}, variant=${numVariant}, code length=${code.length}`);
if (!commit) {
- console.error(`[Store] Commit not found for hash: ${hash}`);
return state;
}
// Don't update if the commit is already committed
if (commit.isCommitted) {
- console.error(`[Store] Attempted to set code of a committed commit: ${hash}`);
- return state; // Return unchanged state instead of throwing
+ return state;
}
- console.log(`[Store] Setting code for variant ${numVariant}`);
return {
commits: {
...state.commits,