-
Notifications
You must be signed in to change notification settings - Fork 490
fix: use distribution flags for desktop detection #8627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe PR prefixes the Electron dev script with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 02/07/2026, 09:59:37 AM UTC 🔗 Links🎉 Your Storybook is ready for review! |
🎭 Playwright Tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes the runtime isElectron() check from the isDesktop distribution flag, implementing a TODO that was previously in the code. The change makes isDesktop a pure compile-time constant based on the DISTRIBUTION environment variable, enabling better tree-shaking and build optimization.
Changes:
- Removed runtime
isElectron()check fromisDesktopdefinition in distribution types - Updated
dev:electronscript to explicitly setDISTRIBUTION=desktopenvironment variable - Removed unused import of
isElectronfrom distribution types file
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/platform/distribution/types.ts | Simplified isDesktop to use only compile-time DISTRIBUTION constant, removing runtime isElectron() check |
| package.json | Added DISTRIBUTION=desktop env var to dev:electron script to ensure correct build-time flag during electron development |
4d9b015 to
507500a
Compare
The base branch was changed.
a8df879 to
e38875c
Compare
4d9b015 to
dd4d36d
Compare
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 22.2 kB (baseline 22.2 kB) • 🟢 -9 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 854 kB (baseline 854 kB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 68.8 kB (baseline 69 kB) • 🟢 -210 BTop-level views, pages, and routed surfaces
Status: 11 added / 11 removed Panels & Settings — 409 kB (baseline 409 kB) • 🟢 -240 BConfiguration panels, inspectors, and settings screens
Status: 12 added / 12 removed User & Accounts — 16 kB (baseline 16.1 kB) • 🟢 -90 BAuthentication, profile, and account management bundles
Status: 6 added / 6 removed Editors & Dialogs — 751 B (baseline 781 B) • 🟢 -30 BModals, dialogs, drawers, and in-app editors
Status: 1 added / 1 removed UI Components — 36.6 kB (baseline 36.7 kB) • 🟢 -60 BReusable component library chunks
Status: 9 added / 9 removed Data & Services — 2.11 MB (baseline 2.11 MB) • 🟢 -96 BStores, services, APIs, and repositories
Status: 13 added / 13 removed Utilities & Hooks — 237 kB (baseline 237 kB) • 🟢 -90 BHelpers, composables, and utility bundles
Status: 18 added / 18 removed Vendor & Third-Party — 8.77 MB (baseline 8.77 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Status: 8 added / 8 removed Other — 7.15 MB (baseline 7.15 MB) • 🟢 -1.05 kBBundles that do not match a named category
Status: 82 added / 82 removed |
…tant (#8710) ## Summary Replace all runtime `isElectron()` function calls with the build-time `isDesktop` constant from `@/platform/distribution/types`, enabling dead-code elimination in non-desktop builds. ## Changes - **What**: Migrate 30 files from runtime `isElectron()` detection (checking `window.electronAPI`) to the compile-time `isDesktop` constant (driven by `__DISTRIBUTION__` Vite define). Remove `isElectron` from `envUtil.ts`. Update `isNativeWindow()` to use `isDesktop`. Guard `electronAPI()` calls behind `isDesktop` checks in stores. Update 7 test files to use `vi.hoisted` + getter mock pattern for per-test `isDesktop` toggling. Add `DISTRIBUTION=desktop` to `dev:electron` script. ## Review Focus - The `electronDownloadStore.ts` now guards the top-level `electronAPI()` call behind `isDesktop` to prevent crashes on non-desktop builds. - Test mocking pattern uses `vi.hoisted` with a getter to allow per-test toggling of the `isDesktop` value. - Pre-existing issues not addressed: `as ElectronAPI` cast in `envUtil.ts`, `:class="[]"` in `BaseViewTemplate.vue`, `@ts-expect-error` in `ModelLibrarySidebarTab.vue`. - This subsumes PR #8627 and renders PR #6122 and PR #7374 obsolete. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8710-refactor-replace-runtime-isElectron-with-build-time-isDesktop-constant-3006d73d365081c08037f0e61c2f6c77) by [Unito](https://www.unito.io)
|
Replaced by #8710 |

Summary
Use distribution flags as the sole source of desktop detection so environment checks are deterministic across builds and local dev.
Changes
isDesktopand rely only on the desktop distribution flag (DISTRIBUTION).dev:electronto setDISTRIBUTION=desktopso local Electron dev preserves desktop behavior.Review Focus
isElectron()for desktop detection.Screenshots (if applicable)
N/A (no UI changes)