Skip to content

Fixed the hardcoded project root path - #82

Open
pysoserious wants to merge 1 commit into
codeworksh:mainfrom
pysoserious:main
Open

pysoserious wants to merge 1 commit into
codeworksh:mainfrom
pysoserious:main

Conversation

@pysoserious

Copy link
Copy Markdown
  1. Problem
    When launching the Electron desktop application (pnpm run dev:desktop), the initial File Explorer widget failed to load and threw:

text
Could not load files: Server.FsError: PlatformError: NotFound: FileSystem.readDirectory (/Users/sanchitrk/Developer/codeworksh/codework/)
This occurred because the file tree root path was hardcoded to a developer's local machine path in the default seed data.

  1. Root Cause

apps/web/src/wm/instances.ts
: The initial codework:explorer widget was seeded with props: { root: "/Users/sanchitrk/Developer/codeworksh/codework" }.

apps/server/src/mock.ts
: The mock project definition also hardcoded path: "~/Developer/codeworksh/codework".
The renderer web app had no mechanism to read the actual project root directory from Electron or the build environment.
3. Changes Made
Desktop IPC Bridge (

apps/desktop
):

Added a synchronous IPC channel codework:root (

apps/desktop/src/ipc.ts
).
Registered a handler in Electron main (

apps/desktop/src/main.ts
) that resolves the workspace root dynamically using process.env.CODEWORK_ROOT ?? path.resolve(app.getAppPath(), app.isPackaged ? ".." : "../..").
Exposed window.desktopBridge.root via the preload context bridge (

apps/desktop/src/preload.ts
).
Web Build & Fallback (

apps/web
):

Injected import.meta.env.VITE_PROJECT_ROOT during build/dev time in

apps/web/vite.config.ts
as a fallback for non-Electron/browser runs.
Updated TypeScript declarations in

apps/web/src/env.ts
to include root?: string on Window["desktopBridge"].
Updated

apps/web/src/wm/instances.ts
to populate props.root dynamically from window.desktopBridge?.root or import.meta.env.VITE_PROJECT_ROOT.
Server Mock Data (

apps/server
):

Updated

apps/server/src/mock.ts
to resolve repoRoot relative to import.meta.url (or CODEWORK_ROOT), ensuring sample project paths point to valid local directories on any developer's machine.
4. Impact & Result
Any user who clones the repository can immediately run pnpm run dev:desktop or pnpm --filter @codeworksh/web dev without manual configuration or path edits.
Users can optionally override the target folder using the CODEWORK_ROOT environment variable.

@sanchitrk

sanchitrk commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

@pysoserious desktop app is still in experimental and development stage. Not ready yet for use. If you are interested in developing Electron app then fork from branch: canary

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants