Repository navigation
fix(safe): desktop preload no longer bundles Effect so the bridge loads - #7
Merged
Merged
Conversation
The preload imported `managedPolicy` from @t3tools/shared, which pulled Effect (1.2 MB) into preload.cjs. Effect's top-level `const setImmediate` collides with the binding Electron's sandboxed-preload wrapper already declares, so the whole preload threw a SyntaxError, window.desktopBridge was never exposed and the app reported PrimaryEnvironmentProtocolUnsupportedError. The preload now reads the vite-injected __T3CODE_MANAGED_POLICY__ constant directly (null policy still allows everything); the bundle drops to ~32 KB with no Effect. verify-preload-bundle now runs the bundle inside an Electron-like function wrapper so duplicate declarations throw, only requires the clerk passkeys global when the baked policy allows t3Connect, and runs as part of the desktop `build` task so the release path cannot ship a dead bridge. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Packaged desktop app (safe.0–safe.2) opens to `PrimaryEnvironmentProtocolUnsupportedError`. `preload.ts` imported `managedPolicy`, which bundled Effect (1.2 MB) into `preload.cjs`. Effect's top-level `const setImmediate` collides with Electron's sandboxed-preload wrapper → SyntaxError → `window.desktopBridge` never exposed → renderer falls back to `t3safe://app`.
Fix
Verified
Stand-in Electron 44 harness (sandbox, privileged scheme): old preload → bridge `undefined`; new → `object`. Gate fails on old bundle, passes on new. Targeted tests, typecheck, lint, fmt, egress/dependency scans pass.
Not verified
Real DMG launch; artifact-host ledger (CI). Real-Electron smoke in CI is a follow-up.
🤖 Generated with Claude Code