Skip to content

feat(desktop): add SKIP_ENV_VALIDATION flag for dev mode#466

Merged
saddlepaddle merged 1 commit intomainfrom
feat/skip-env-validation
Dec 22, 2025
Merged

feat(desktop): add SKIP_ENV_VALIDATION flag for dev mode#466
saddlepaddle merged 1 commit intomainfrom
feat/skip-env-validation

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Dec 22, 2025

Summary

  • Add SKIP_ENV_VALIDATION=1 flag to skip env validation and auth screen in dev mode
  • Useful for local development without credentials configured
  • Add to Vite define blocks to ensure proper bundling in prod (empty string = falsy = validation runs)

Usage

SKIP_ENV_VALIDATION=1 bun run dev

Test plan

  • Run SKIP_ENV_VALIDATION=1 bun run dev from apps/desktop/ - should skip auth screen
  • Run bun run dev normally - should show auth screen as before
  • Build for production and verify env validation still runs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added a Development section with simplified instructions for running the app locally without external credentials.
  • Chores

    • Introduced an option to bypass environment validation for streamlined local development and tests.
    • Ensured this bypass is propagated across build configurations.
    • Adjusted local auth handling to allow skipping the sign-in flow during development.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 22, 2025

Walkthrough

Introduces a SKIP_ENV_VALIDATION environment flag propagated through Vite build defines and used to skip environment schema validation and the desktop renderer sign-in gating for local/dev runs; adds developer instructions to BUILDING.md and enables the flag in test and bunfig setups.

Changes

Cohort / File(s) Change Summary
Docs / Dev run
apps/desktop/BUILDING.md
Added a Development section instructing to run dev with SKIP_ENV_VALIDATION=1 bun run dev to skip env validation and sign-in for local development.
Vite / Build env propagation
apps/desktop/electron.vite.config.ts
Injected process.env.SKIP_ENV_VALIDATION into Vite define blocks for main, preload, and renderer so the flag is available at build/runtime.
Main env init
apps/desktop/src/main/env.main.ts
Added skipValidation: !!process.env.SKIP_ENV_VALIDATION to the object passed to createEnv.
Renderer env init
apps/desktop/src/renderer/env.renderer.ts
Conditionalized env parsing: when SKIP_ENV_VALIDATION is set, use rawEnv as z.infer<typeof envSchema>; otherwise call envSchema.parse(rawEnv).
Renderer auth gating
apps/desktop/src/renderer/screens/main/index.tsx
Auth state logic updated so isSignedIn is true and initial loading skipped when SKIP_ENV_VALIDATION is set, bypassing sign-in for dev.
TRPC env layer
packages/trpc/src/env.ts
Added skipValidation boolean (from SKIP_ENV_VALIDATION) to the createEnv argument.
Tests / config
apps/desktop/bunfig.toml, apps/desktop/test-setup.ts
Set SKIP_ENV_VALIDATION = "1" in test env and added the same var to test setup to skip env validation during tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review the renderer conditional parse to ensure no runtime type-unsafe assumptions remain where validated values are expected.
  • Verify SKIP_ENV_VALIDATION propagation in electron.vite.config.ts covers all build targets (main, preload, renderer).
  • Confirm test and bunfig changes don't unintentionally disable validation in CI or production builds.
  • Check that skipValidation handling in packages/trpc/src/env.ts aligns with other createEnv usages.

Possibly related PRs

Poem

🐰 In dev I nibble, tests go spry,
Skip the checks and wave goodbye,
Env flags twinkle, gates swing wide,
Local hops take me for a ride,
A tiny rabbit codes with pride. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a SKIP_ENV_VALIDATION flag for dev mode, which is the primary feature across all modified files.
Description check ✅ Passed The description covers the main purpose, usage example, and test plan, though it deviates from the template structure by omitting formal sections like 'Related Issues' and 'Type of Change'.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/skip-env-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 <noreply@anthropic.com>
@saddlepaddle saddlepaddle force-pushed the feat/skip-env-validation branch from 8244a97 to a1ef5ee Compare December 22, 2025 17:00
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/desktop/src/main/env.main.ts (1)

34-34: Verify API compatibility (duplicate concern).

Same concern as in packages/trpc/src/env.ts: verify that @t3-oss/env-core v0.13.8 supports the skipValidation option.

🧹 Nitpick comments (2)
apps/desktop/src/renderer/screens/main/index.tsx (1)

35-37: Consider adding NODE_ENV guard for defense in depth.

The authentication bypass using SKIP_ENV_VALIDATION works correctly, but could be hardened by also checking that NODE_ENV is "development". This adds an extra safeguard to prevent accidental authentication bypass in production builds.

🔎 Proposed enhancement
 const isSignedIn =
-  !!process.env.SKIP_ENV_VALIDATION || (authState?.isSignedIn ?? false);
- const isAuthLoading = !process.env.SKIP_ENV_VALIDATION && !authState;
+  (!!process.env.SKIP_ENV_VALIDATION && process.env.NODE_ENV === "development") || (authState?.isSignedIn ?? false);
+ const isAuthLoading = !(!!process.env.SKIP_ENV_VALIDATION && process.env.NODE_ENV === "development") && !authState;
apps/desktop/src/renderer/env.renderer.ts (1)

43-45: Consider NODE_ENV guard and document type safety implications.

The conditional validation bypass correctly implements the development workflow, but bypasses all runtime type checking when SKIP_ENV_VALIDATION is set. This could lead to runtime errors if environment variables are malformed.

Consider:

  1. Adding a NODE_ENV === "development" check for defense in depth (similar to the auth bypass)
  2. Adding a comment warning that malformed env vars will cause runtime errors when validation is skipped
🔎 Proposed enhancement
+/**
+ * Skip validation in development mode only.
+ * WARNING: When validation is skipped, malformed env vars will cause runtime errors.
+ */
 export const env = process.env.SKIP_ENV_VALIDATION
+  && process.env.NODE_ENV === "development"
   ? (rawEnv as z.infer<typeof envSchema>)
   : envSchema.parse(rawEnv);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2ffa7d and 8244a97.

📒 Files selected for processing (6)
  • apps/desktop/BUILDING.md
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/env.renderer.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • packages/trpc/src/env.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid using any type in TypeScript - maintain type safety unless absolutely necessary

Files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
  • packages/trpc/src/env.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Run Biome for formatting, linting, import organization, and safe fixes at the root level using bun run lint:fix

Files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
  • packages/trpc/src/env.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
apps/desktop/src/{main,renderer,preload}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type-safe IPC communication - define channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers

Files:

  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
apps/desktop/src/main/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Accept object parameters in IPC handlers - do not use positional parameters in ipcMain.handle()

Files:

  • apps/desktop/src/main/env.main.ts
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in renderer process or shared code - use only in main process (src/main/)

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
**/*.{tsx,css}

📄 CodeRabbit inference engine (AGENTS.md)

Use React + TailwindCSS v4 + shadcn/ui for UI development

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports

Applied to files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/env.renderer.ts
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Applies to apps/desktop/src/renderer/**/*.{ts,tsx} : Never import Node.js modules in renderer process or shared code - use only in main process (src/main/)

Applied to files:

  • apps/desktop/src/renderer/env.renderer.ts
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Use Bun as the package manager exclusively - do not use npm, yarn, or pnpm

Applied to files:

  • apps/desktop/BUILDING.md
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Run bun run lint to check for lint issues without making changes

Applied to files:

  • apps/desktop/BUILDING.md
🧬 Code graph analysis (1)
apps/desktop/src/renderer/env.renderer.ts (3)
apps/desktop/src/main/env.main.ts (1)
  • env (12-38)
packages/trpc/src/env.ts (1)
  • env (4-14)
apps/desktop/src/shared/env.shared.ts (1)
  • env (28-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy Marketing
  • GitHub Check: Deploy Admin
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy API
  • GitHub Check: Build
🔇 Additional comments (3)
apps/desktop/BUILDING.md (1)

1-9: LGTM!

The development instructions are clear and correctly document the SKIP_ENV_VALIDATION flag usage. The documentation properly uses Bun as the package manager, consistent with project standards.

apps/desktop/electron.vite.config.ts (1)

61-63: LGTM!

The SKIP_ENV_VALIDATION environment variable is correctly propagated across all Vite define blocks (main, preload, and renderer). The pattern JSON.stringify(process.env.SKIP_ENV_VALIDATION || "") ensures that when the variable is not set, it defaults to an empty string, which is falsy in JavaScript. This means validation will run by default in production builds where the variable is not defined.

Also applies to: 110-112, 129-131

packages/trpc/src/env.ts (1)

13-13: @t3-oss/env-core version 0.13.8 supports the skipValidation option. The skipValidation property is documented in BaseOptions for version 0.13.8 and determines whether to skip validation of environment variables.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 22, 2025

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

Service Status
Neon Database (Neon)

Thank you for your contribution! 🎉


Preview resources have been processed for cleanup

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/index.tsx (1)

35-37: Auth bypass logic is correct.

The logic correctly bypasses authentication when SKIP_ENV_VALIDATION is set, allowing development without credentials.

Optional: Consider adding a comment for clarity
+	// When SKIP_ENV_VALIDATION is set, bypass auth for local development
 	const isSignedIn =
 		!!process.env.SKIP_ENV_VALIDATION || (authState?.isSignedIn ?? false);
 	const isAuthLoading = !process.env.SKIP_ENV_VALIDATION && !authState;
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8244a97 and a1ef5ee.

📒 Files selected for processing (8)
  • apps/desktop/BUILDING.md
  • apps/desktop/bunfig.toml
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/main/env.main.ts
  • apps/desktop/src/renderer/env.renderer.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/test-setup.ts
  • packages/trpc/src/env.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/desktop/src/renderer/env.renderer.ts
  • apps/desktop/src/main/env.main.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid using any type in TypeScript - maintain type safety unless absolutely necessary

Files:

  • packages/trpc/src/env.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/test-setup.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Run Biome for formatting, linting, import organization, and safe fixes at the root level using bun run lint:fix

Files:

  • packages/trpc/src/env.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/test-setup.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/test-setup.ts
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in renderer process or shared code - use only in main process (src/main/)

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
apps/desktop/src/{main,renderer,preload}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type-safe IPC communication - define channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
**/*.{tsx,css}

📄 CodeRabbit inference engine (AGENTS.md)

Use React + TailwindCSS v4 + shadcn/ui for UI development

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports

Applied to files:

  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/test-setup.ts
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Use Bun as the package manager exclusively - do not use npm, yarn, or pnpm

Applied to files:

  • apps/desktop/BUILDING.md
📚 Learning: 2025-12-18T23:19:10.415Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.415Z
Learning: Run bun run lint to check for lint issues without making changes

Applied to files:

  • apps/desktop/BUILDING.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy Admin
  • GitHub Check: Deploy Marketing
  • GitHub Check: Build
🔇 Additional comments (5)
apps/desktop/bunfig.toml (1)

7-7: LGTM!

Setting SKIP_ENV_VALIDATION = "1" in the test environment is appropriate and aligns with the test setup in test-setup.ts.

apps/desktop/test-setup.ts (1)

17-17: LGTM!

Setting SKIP_ENV_VALIDATION = "1" in the test setup correctly bypasses environment validation during tests, consistent with the test configuration in bunfig.toml.

apps/desktop/electron.vite.config.ts (1)

61-63: LGTM!

The SKIP_ENV_VALIDATION flag is correctly propagated to all build contexts (main, preload, and renderer) with a safe default of an empty string, ensuring validation runs in production builds when the flag is not explicitly set.

Also applies to: 110-112, 129-131

apps/desktop/BUILDING.md (1)

1-9: LGTM!

The development instructions are clear and correctly document the SKIP_ENV_VALIDATION=1 bun run dev usage pattern for local development without credentials.

packages/trpc/src/env.ts (1)

13-13: No issues found. The skipValidation option is supported in @t3-oss/env-core version 0.13.8 and will work as expected.

@saddlepaddle saddlepaddle merged commit eeed2fc into main Dec 22, 2025
12 checks passed
@Kitenite Kitenite deleted the feat/skip-env-validation branch December 28, 2025 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant