life-efficient / life-efficient/bigbrain

Desktop onboarding fails because sandboxed preload cannot load Node path module

Open Beginner friendly
#2 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Install or update to BigBrain v0.15.0 on macOS.
  2. Launch the BigBrain desktop app.
  3. Open the first onboarding page.
  4. Observe the Cannot read properties of undefined (reading 'state') error.
  5. In the Electron console, observe the preload failure and missing path module.

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.html using location.pathname;
  • does not import path or url.

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.bigbrainDesktop is an object;
  • window.bigbrainDesktop.state is 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.