From a1ef5eedb809229bba5cb8d1a69ce758af82c63e Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Mon, 22 Dec 2025 11:56:01 -0500 Subject: [PATCH] feat(desktop): add SKIP_ENV_VALIDATION flag for dev mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip env validation and auth screen when SKIP_ENV_VALIDATION=1 is set, useful for local development without credentials. - Add skipValidation to desktop env files and trpc/env.ts - Add SKIP_ENV_VALIDATION to Vite define blocks for proper bundling - Skip auth screen in MainScreen when flag is set - Document usage in BUILDING.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/desktop/BUILDING.md | 14 +++++++++++++- apps/desktop/bunfig.toml | 1 + apps/desktop/electron.vite.config.ts | 9 +++++++++ apps/desktop/src/main/env.main.ts | 1 + apps/desktop/src/renderer/env.renderer.ts | 4 +++- apps/desktop/src/renderer/screens/main/index.tsx | 5 +++-- apps/desktop/test-setup.ts | 1 + packages/trpc/src/env.ts | 1 + 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/desktop/BUILDING.md b/apps/desktop/BUILDING.md index 9c2f5bb1db5..ba5d48da336 100644 --- a/apps/desktop/BUILDING.md +++ b/apps/desktop/BUILDING.md @@ -1 +1,13 @@ -when building for release, make sure node-pty is built for the correct architecture with `bun install:deps` and then run `bun release` \ No newline at end of file +# Development + +Run the dev server without env validation or auth: + +```bash +SKIP_ENV_VALIDATION=1 bun run dev +``` + +This skips environment variable validation and the sign-in screen, useful for local development without credentials. + +# Release + +When building for release, make sure node-pty is built for the correct architecture with `bun install:deps` and then run `bun release` \ No newline at end of file diff --git a/apps/desktop/bunfig.toml b/apps/desktop/bunfig.toml index 908c8d00878..e2789a31158 100644 --- a/apps/desktop/bunfig.toml +++ b/apps/desktop/bunfig.toml @@ -4,3 +4,4 @@ preload = ["./test-setup.ts"] [test.env] NODE_ENV = "test" +SKIP_ENV_VALIDATION = "1" diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts index ee3ba2b302f..be10b0fabf0 100644 --- a/apps/desktop/electron.vite.config.ts +++ b/apps/desktop/electron.vite.config.ts @@ -58,6 +58,9 @@ export default defineConfig({ "process.env.NODE_ENV": JSON.stringify( process.env.NODE_ENV || "production", ), + "process.env.SKIP_ENV_VALIDATION": JSON.stringify( + process.env.SKIP_ENV_VALIDATION || "", + ), // API URLs - baked in at build time for main process "process.env.NEXT_PUBLIC_API_URL": JSON.stringify( process.env.NEXT_PUBLIC_API_URL || "https://api.superset.sh", @@ -104,6 +107,9 @@ export default defineConfig({ "process.env.NODE_ENV": JSON.stringify( process.env.NODE_ENV || "production", ), + "process.env.SKIP_ENV_VALIDATION": JSON.stringify( + process.env.SKIP_ENV_VALIDATION || "", + ), }, build: { @@ -120,6 +126,9 @@ export default defineConfig({ define: { // Core env vars - Vite replaces these at build time "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), + "process.env.SKIP_ENV_VALIDATION": JSON.stringify( + process.env.SKIP_ENV_VALIDATION || "", + ), "process.platform": JSON.stringify(process.platform), // API URLs - available in renderer if needed "process.env.NEXT_PUBLIC_API_URL": JSON.stringify( diff --git a/apps/desktop/src/main/env.main.ts b/apps/desktop/src/main/env.main.ts index 6f8bc42dd94..f5a0d1519d0 100644 --- a/apps/desktop/src/main/env.main.ts +++ b/apps/desktop/src/main/env.main.ts @@ -31,6 +31,7 @@ export const env = createEnv({ GH_CLIENT_ID: process.env.GH_CLIENT_ID, }, emptyStringAsUndefined: true, + skipValidation: !!process.env.SKIP_ENV_VALIDATION, // Main process runs in trusted Node.js environment isServer: true, diff --git a/apps/desktop/src/renderer/env.renderer.ts b/apps/desktop/src/renderer/env.renderer.ts index e2fe439c95f..af27ba9fe27 100644 --- a/apps/desktop/src/renderer/env.renderer.ts +++ b/apps/desktop/src/renderer/env.renderer.ts @@ -40,4 +40,6 @@ const rawEnv = { | undefined, }; -export const env = envSchema.parse(rawEnv); +export const env = process.env.SKIP_ENV_VALIDATION + ? (rawEnv as z.infer) + : envSchema.parse(rawEnv); diff --git a/apps/desktop/src/renderer/screens/main/index.tsx b/apps/desktop/src/renderer/screens/main/index.tsx index 0fc34dd3b23..d73c70db7f4 100644 --- a/apps/desktop/src/renderer/screens/main/index.tsx +++ b/apps/desktop/src/renderer/screens/main/index.tsx @@ -32,8 +32,9 @@ function LoadingSpinner() { export function MainScreen() { const utils = trpc.useUtils(); const { data: authState } = trpc.auth.getState.useQuery(); - const isSignedIn = authState?.isSignedIn ?? false; - const isAuthLoading = !authState; + const isSignedIn = + !!process.env.SKIP_ENV_VALIDATION || (authState?.isSignedIn ?? false); + const isAuthLoading = !process.env.SKIP_ENV_VALIDATION && !authState; // Subscribe to auth state changes trpc.auth.onStateChange.useSubscription(undefined, { diff --git a/apps/desktop/test-setup.ts b/apps/desktop/test-setup.ts index e9282ae35b4..fd4cc7189ec 100644 --- a/apps/desktop/test-setup.ts +++ b/apps/desktop/test-setup.ts @@ -14,6 +14,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; process.env.NODE_ENV = "test"; +process.env.SKIP_ENV_VALIDATION = "1"; process.env.GOOGLE_CLIENT_ID = "test-google-client-id"; process.env.GH_CLIENT_ID = "test-github-client-id"; diff --git a/packages/trpc/src/env.ts b/packages/trpc/src/env.ts index 5a3282fcff3..40cc12f8f4f 100644 --- a/packages/trpc/src/env.ts +++ b/packages/trpc/src/env.ts @@ -10,4 +10,5 @@ export const env = createEnv({ client: {}, runtimeEnv: process.env, emptyStringAsUndefined: true, + skipValidation: !!process.env.SKIP_ENV_VALIDATION, });