From 8685ca02e5f0bebd1c7868df3b6a50f9f33a1e59 Mon Sep 17 00:00:00 2001 From: mantrakp04 Date: Fri, 22 May 2026 16:24:35 -0700 Subject: [PATCH 1/7] Fix dashboard sandbox compile errors and switch smart model to Grok. Forward Babel/JSX parse failures from the AI dashboard iframe to the parent composer instead of showing a blank preview, and use x-ai/grok-build-0.1 for authenticated smart-tier requests. --- apps/backend/src/lib/ai/models.ts | 4 +- .../dashboard-sandbox-host.tsx | 80 ++++++++++++++++--- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/apps/backend/src/lib/ai/models.ts b/apps/backend/src/lib/ai/models.ts index 34e8df13a3..d73391a50b 100644 --- a/apps/backend/src/lib/ai/models.ts +++ b/apps/backend/src/lib/ai/models.ts @@ -28,11 +28,11 @@ const MODEL_SELECTION_MATRIX: Record< }, smart: { slow: { - authenticated: { modelId: "moonshotai/kimi-k2.6:nitro" }, + authenticated: { modelId: "x-ai/grok-build-0.1" }, unauthenticated: { modelId: "deepseek/deepseek-v4-flash" }, }, fast: { - authenticated: { modelId: "moonshotai/kimi-k2.6:nitro" }, + authenticated: { modelId: "x-ai/grok-build-0.1" }, unauthenticated: { modelId: "deepseek/deepseek-v4-flash:nitro" }, }, }, diff --git a/apps/dashboard/src/components/commands/create-dashboard/dashboard-sandbox-host.tsx b/apps/dashboard/src/components/commands/create-dashboard/dashboard-sandbox-host.tsx index ff3a4dc3e3..a2085c1693 100644 --- a/apps/dashboard/src/components/commands/create-dashboard/dashboard-sandbox-host.tsx +++ b/apps/dashboard/src/components/commands/create-dashboard/dashboard-sandbox-host.tsx @@ -337,11 +337,49 @@ function getSandboxDocument(artifact: DashboardArtifact, baseUrl: string, dashbo
- - - + + + + + + ${getDependencyScripts(esmVersion, esmFallbackVersion, dashboardUrl)} - + + + + `; } -function escapeScriptContent(code: string): string { - return code - .replace(/<\/script/gi, "<\\/script") - .replace(//g, "--\\>"); +function encodeSourceForJsonScript(code: string): string { + return JSON.stringify(code).replace(/ handler does NOT run it — that handler - swallows parse errors. The plumbing script below compiles this with a - try/catch and forwards any SyntaxError to the parent composer. --> - +