From 725f2da8869cf415da24f7a3f9e3014756cd0041 Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Sat, 23 May 2026 12:29:20 -0700 Subject: [PATCH 1/2] Fix tests --- .claude/CLAUDE-KNOWLEDGE.md | 3 +++ apps/backend/src/lib/config.tsx | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.claude/CLAUDE-KNOWLEDGE.md b/.claude/CLAUDE-KNOWLEDGE.md index 175fc2296..c958c395c 100644 --- a/.claude/CLAUDE-KNOWLEDGE.md +++ b/.claude/CLAUDE-KNOWLEDGE.md @@ -544,3 +544,6 @@ A: `Project.createAndSwitch` should leave `backendContext.projectKeys` set to re ## Q: How should backend SMTP SSRF checks be rolled out? A: Keep the real outbound SMTP policy in `apps/backend/src/private/implementation/smtp-egress-policy.ts`, export it through `apps/backend/src/private/index.ts`, and provide a simple `implementation-fallback` function for self-hosters. It should allow only SMTP ports 25, 465, 587, 2465, 2587, and 2525, reject internal IP literals or DNS resolutions, and initially run report-only from `emails-low-level.tsx` via `captureError("smtp-egress-policy-report-only", ...)` before enforcing hard failures. + +## Q: What project-level `sourceOfTruth` config is supported? +A: Project config overrides only support the hosted `sourceOfTruth` shape. Legacy external source-of-truth overrides such as Postgres or Neon are removed by `migrateConfigOverride("project", ...)`, while raw schema validation should reject them. diff --git a/apps/backend/src/lib/config.tsx b/apps/backend/src/lib/config.tsx index 9c535d095..4c5dc1b45 100644 --- a/apps/backend/src/lib/config.tsx +++ b/apps/backend/src/lib/config.tsx @@ -772,22 +772,18 @@ import.meta.vitest?.test('_validateConfigOverrideSchemaImpl(...)', async ({ expe // Actual configs — advanced cases expect(await validateConfigOverrideSchema(projectConfigSchema, projectSchemaBase, { sourceOfTruth: { - type: 'postgres', - connectionString: 'postgres://user:pass@host:port/db', + type: 'hosted', }, })).toEqual(Result.ok(null)); expect(await validateConfigOverrideSchema(projectConfigSchema, projectSchemaBase, { sourceOfTruth: { type: 'postgres', + connectionString: 'postgres://user:pass@host:port/db', }, })).toEqual(Result.error(deindent` - [WARNING] sourceOfTruth is not matched by any of the provided schemas: + [ERROR] sourceOfTruth is not matched by any of the provided schemas: Schema 0: - sourceOfTruth.type must be one of the following values: hosted - Schema 1: - sourceOfTruth.connectionStrings must be defined - Schema 2: - sourceOfTruth.connectionString must be defined + sourceOfTruth contains unknown properties: connectionString `)); // Dot-notation keys that dot into nothing — detected by simulating the rendering pipeline From 10df9b2b7bf7077b45ced4fe57bb5e6dac4fe10a Mon Sep 17 00:00:00 2001 From: Mantra <87142457+mantrakp04@users.noreply.github.com> Date: Sat, 23 May 2026 12:34:37 -0700 Subject: [PATCH 2/2] Fix dashboard sandbox compile errors and switch smart model to Grok (#1476) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Forward Babel/JSX compile errors, runtime throws, and unhandled rejections from the AI dashboard sandbox iframe to the parent composer via `postMessage`, so users see actionable errors instead of a blank preview - Compile AI-generated dashboard source explicitly with `Babel.transform` + try/catch (stored in `text/plain` to avoid Babel's auto-handler swallowing parse errors) and add `crossorigin="anonymous"` on the Babel script for readable cross-origin error messages - Switch authenticated smart-tier model from `moonshotai/kimi-k2.6:nitro` to `x-ai/grok-build-0.1` ## Test plan - [ ] Generate a dashboard with valid AI code and confirm the preview still renders - [ ] Generate a dashboard with invalid JSX and confirm the composer shows the compile error (not a blank iframe) - [ ] Trigger a runtime error in generated dashboard code and confirm it reaches the parent error boundary - [ ] Verify authenticated smart-tier requests route to `x-ai/grok-build-0.1` Made with [Cursor](https://cursor.com) ## Summary by CodeRabbit * **Bug Fixes** * Embedded dashboards now show a clear “Dashboard failed to compile” message on compilation errors instead of a blank iframe. * Dashboard runtime errors and unhandled promise rejections are captured earlier and forwarded to the parent for improved visibility. * **Updates** * The authenticated AI model used for the "smart" quality has been changed, affecting model selection for authenticated requests. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/hexclave/stack-auth/pull/1476?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) --- apps/backend/src/lib/ai/models.ts | 4 +- .../dashboard-sandbox-host.tsx | 153 ++++++++++++------ 2 files changed, 104 insertions(+), 53 deletions(-) diff --git a/apps/backend/src/lib/ai/models.ts b/apps/backend/src/lib/ai/models.ts index 34e8df13a..d73391a50 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 ff3a4dc3e..9b5bf0e0c 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 @@ -179,15 +179,12 @@ function getDependencyScripts(esmVersion: string, esmFallbackVersion: string, da `; } -function escapeScriptContent(code: string): string { - return code - .replace(/<\/script/gi, "<\\/script") - .replace(//g, "--\\>"); +function encodeSourceForJsonScript(code: string): string { + return JSON.stringify(code).replace(/
- - - + + + + + + ${getDependencyScripts(esmVersion, esmFallbackVersion, dashboardUrl)} - + + +