IPC migration phase 1: remove direct process reads from Tier 1 renderer files#22
Merged
Merged
Conversation
Copilot created this pull request from a session on behalf of
NamecoinGithub
July 10, 2026 13:52
View session
NamecoinGithub
approved these changes
Jul 11, 2026
NamecoinGithub
marked this pull request as ready for review
July 11, 2026 02:59
There was a problem hiding this comment.
Pull request overview
This PR introduces a renderer-safe environment accessor (lib/nexusEnv) backed by the preload bridge (window.nexusEnv) and migrates a first batch of “process-only” Tier 1 renderer files off direct process.* reads, supporting future re-enablement of contextIsolation.
Changes:
- Extend
src/main/preload.jsto expose additional environment/platform fields viawindow.nexusEnv. - Add
src/shared/lib/nexusEnv.tsas a typed renderer helper for accessingwindow.nexusEnv(plusisDevelopment). - Replace
process.platform/process.env.NODE_ENVchecks withnexusEnv.platform/isDevelopmentin the migrated renderer files.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/shared/lib/wallet.ts | Replaces process.platform usage with nexusEnv.platform for macOS-specific behavior. |
| src/shared/lib/store.tsx | Switches dev-mode detection from process.env.NODE_ENV to isDevelopment. |
| src/shared/lib/nexusEnv.ts | Adds a typed accessor module for preload-injected env/platform values. |
| src/shared/lib/appMenu.ts | Replaces dev-mode checks and macOS menu branching to use nexusEnv instead of process. |
| src/main/preload.js | Extends window.nexusEnv bridge with platform/arch and home-directory related fields. |
| src/App/Settings/Style/BackgroundPicker.tsx | Replaces Windows path normalization branch to use nexusEnv.platform. |
| src/App/Settings/Core/EmbeddedCoreSettings.tsx | Replaces Windows filter selection branch to use nexusEnv.platform. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+13
to
+30
| /** Mirrors `process.platform` from the main process. */ | ||
| platform: NodeJS.Platform; | ||
| /** Mirrors `process.arch` from the main process. */ | ||
| arch: string; | ||
| /** Mirrors `process.env.HOME`; populated on macOS/Linux. */ | ||
| HOME: string; | ||
| /** Mirrors `process.env.USERPROFILE`; populated on Windows. */ | ||
| USERPROFILE: string; | ||
| } | ||
|
|
||
| const fallbackNexusEnv: NexusEnv = { | ||
| NODE_ENV: 'production', | ||
| PORT: '', | ||
| platform: 'linux', | ||
| arch: '', | ||
| HOME: '', | ||
| USERPROFILE: '', | ||
| }; |
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.
contextIsolation:truewas previously reverted on the main window after it caused a blank/black GUI, because renderer code across ~29 files reads Node globals (process) and core modules (fs,http, etc.) directly — something that only works withcontextIsolation:false. This PR lands the first, lowest-risk wave of the incremental migration needed to safely re-enablecontextIsolationin the future: files that only readprocess.platform/process.env, with nofs/httpinvolved.Preload bridge
window.nexusEnv(exposed bysrc/main/preload.js) to includeplatform,arch,HOME, andUSERPROFILE, in addition to the existingNODE_ENV/PORT.src/shared/lib/nexusEnv.ts, a typed helper renderer code should use instead of the rawprocessglobal. Logs an error rather than silently defaulting if the bridge is unexpectedly missing.Migrated files
Replaced direct
process.platform/process.env.NODE_ENVreads with thenexusEnvbridge in:src/shared/lib/store.tsxsrc/shared/lib/appMenu.tssrc/shared/lib/wallet.tssrc/App/Settings/Style/BackgroundPicker.tsxsrc/App/Settings/Core/EmbeddedCoreSettings.tsxScope correction
ExternalIcon.tsx,ModuleIcon.tsx, andWebView.tsxwere initially assumed to be simpleprocess-only files, but they also perform directfsreads — they need real IPC channels, not just the bridge, so they're deferred to the next (Tier 2) migration phase.Not in this PR
contextIsolationremainsfalseon the main window. The remaining Tier 2 (fs/path helpers, e.g.consts/paths.ts,geoip.ts,theme.ts) and Tier 3 (api.ts,core.ts,bootstrap.ts, module install pipeline,updater) files still read Node modules directly and require IPC conversion before the flag can be flipped and fully regression-tested.