life-efficient / life-efficient/bigbrain
Desktop onboarding fails because sandboxed preload cannot load Node path module
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Summary
The first page of the BigBrain desktop onboarding flow fails with:
Cannot read properties of undefined (reading 'state')
This blocks desktop onboarding. Existing brain data, the CLI, and the MCP service are unaffected.
Environment
- BigBrain: v0.15.0
- Electron: 42.5.0
- Platform: macOS
- Affected area: first page of desktop onboarding
Root cause
electron/preload.cjs imports Node built-ins:
const path = require('path');
const { fileURLToPath } = require('url');
The renderer uses Electron's sandbox. In that environment, require('path') is unavailable, so the preload terminates before it exposes window.bigbrainDesktop through contextBridge.
Electron reports:
Unable to load preload script: electron/preload.cjs
Error: module not found: path
The onboarding client then runs:
const api = window.bigbrainDesktop;
await api.state();
Because api is undefined, the user sees the .state error.
Reproduction
- Install or update to BigBrain v0.15.0 on macOS.
- Launch the BigBrain desktop app.
- Open the first onboarding page.
- Observe the
Cannot read properties of undefined (reading 'state')error. - In the Electron console, observe the preload failure and missing
pathmodule.
Proposed fix
Avoid unsupported Node built-ins in the sandboxed preload and use URL properties available in the renderer:
const { contextBridge, ipcRenderer } = require('electron');
const isDesktopShell = process.isMainFrame
&& location.protocol === 'file:'
&& location.pathname.endsWith('/electron/desktop.html');
This preserves the main-frame and file: restrictions while allowing the preload to complete.
Regression protection
Add a test confirming that the preload:
- identifies
electron/desktop.htmlusinglocation.pathname; - does not import
pathorurl.
An Electron integration test for the sandboxed preload would provide stronger coverage because the existing source-level assertions did not catch this runtime failure.
Verification
After applying the proposed change:
window.bigbrainDesktopis an object;window.bigbrainDesktop.stateis a function;- the first onboarding page renders normally in an isolated Electron run;
- the full BigBrain test suite passes: 208 passed, 6 skipped, 0 failed;
- BigBrain health reports zero findings.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with electron/preload.cjs and reproduce the sandboxed preload failure in the first desktop onboarding page. Verify that the preload no longer imports path or url, then run the relevant source-level or Electron integration checks. Done means window.bigbrainDesktop is exposed with a callable state function, onboarding renders normally, and the full test suite remains passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100