The Electron app. Main hosts the window, serves the UI from apps/web and starts the app server from apps/server as a child process. It is a client: agents run on a CodeWork RPC server, never here.
- The window and its scheme. Main serves the built UI from
codework://appwhen packaged andcodeworkdev://appfrom the repo, or proxies to a web dev server whenCODEWORK_WEB_URLis set. - The app server's lifetime. Main runs it with Electron's own binary and
ELECTRON_RUN_AS_NODE, so no system Node is needed. If the app server exits, the app quits, and quitting waits for it to stop. - The bridge. The renderer is sandboxed and sees only the narrow
desktopBridgefrom the preload: the app server's URL and token, the home folder, a folder picker and reveal. - Channels. Each channel (
latest,dev,canary, andlocalfrom the repo) installs side by side with its own identity and data.
Main holds no CodeWork state and makes no RPC calls of its own. Everything the UI shows comes through the app server, so the app keeps one owner for app.db and one client of each host.
src/main.ts: app lifecycle, the custom scheme, the window and the single-instance lock.src/server.ts: starts the app server and reads its ready line.src/preload.ts: thedesktopBridgethe renderer sees.src/ipc.ts: IPC channel names shared by main and preload.src/manifest.ts: the packaged manifest and the current channel.electron.config.ts: electron-builder config, one identity per channel.scripts/dev.mjs: the dev loop behindvp run dev:desktop.scripts/package.mjs: builds the web app, the app server and this app, then packages them.
From the repository root, with a dev home exported:
vp run dev:desktopThis starts the UI on Vite, watches the Electron and app server bundles, and opens Electron as CodeWork Local. To package a build, run this from apps/desktop:
vp run package <canary|dev|latest> [electron-builder args] # e.g. latest --mac --arm64 --dirSee development for the dev home and run order, and desktop internals for processes, channels and data.