Repository navigation
Fixed the hardcoded project root path - #82
Open
pysoserious wants to merge 1 commit into
Open
pysoserious wants to merge 1 commit into
pysoserious wants to merge 1 commit into
Conversation
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
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.
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.
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.