Windows has no shebang. CreateProcess starts executables, and both shapes a codeburn install takes here are scripts: dist/cli.js in dev, and the codeburn.cmd that a global npm install puts on PATH. Spawning either with shell: false is EFTYPE, so nothing the desktop app ran ever ran on this platform. The throw came out of startServe inside whenReady and took the rest of it with it, which is why `npm run dev` never even opened a window, and why 49 of this file's own tests failed here. Each script now gets a runner that can start it. A .js goes through this process's own binary as Node, the same shape the bundled CLI already used. A .cmd goes through cmd.exe as one command line, because that is the only way to start a batch file, and the line is built rather than handed to shell: true, which does not escape anything: two parsers read it, cmd first and then whatever splits a command line back into argv, and a .cmd re-expands its own arguments through %*, so the arguments are escaped for both readings. That is cross-spawn's rule, restated here rather than depended on, since the main process ships no npm dependencies. An .exe and a POSIX codeburn are spawned exactly as before. Two things follow from the cmd.exe route. The PATH lookup asks for codeburn.cmd before bare codeburn, because npm writes both into the same directory and the bare one is a shell script Windows cannot start. And killing such a child means killing the tree: the shim exits as soon as it has started node, so the handle we hold is the shim's, and taskkill /T is what reaches the generation below. Five tests do not run on Windows now rather than failing there. They assert catchable SIGTERM: a grace window, a cleanup handler, a child that ignores the first signal, a resident closing its own stdin. child.kill on Windows is TerminateProcess, so those are things the platform does not have rather than things this code gets wrong, and the POSIX expectations are untouched. Three assertions that hard-coded ":" as the PATH separator now use the platform's. |
||
|---|---|---|
| .. | ||
| build | ||
| electron | ||
| flathub | ||
| renderer | ||
| scripts | ||
| .gitignore | ||
| demo-bridge.mjs | ||
| DISTRIBUTION.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.electron.json | ||
| tsconfig.json | ||
| vite.config.ts | ||
| vitest.config.ts | ||
CodeBurn Desktop
Electron desktop shell for CodeBurn's local-first usage views. M1 runs as a developer app and reads data by spawning the installed codeburn CLI; it does not run a daemon or HTTP server.
Development
npm --prefix app install
npm --prefix app run dev
Validation:
npm --prefix app run test
npm --prefix app run typecheck
CLI Dependency
Packaged builds ship their own version-matched copy of the codeburn CLI and require nothing installed — the app spawns the bundled CLI with Electron's own binary as Node (ELECTRON_RUN_AS_NODE). In development (Vite dev server) the app uses the repo's freshly-built CLI, and either can be overridden with CODEBURN_BIN or a persisted path file. See DISTRIBUTION.md for the bundling and resolution details. Electron resolves and spawns the CLI from the main process, then sends decoded JSON through the secure preload bridge into the renderer.
This follows the menubar pattern:
contextIsolation: true,nodeIntegration: false, andsandbox: true.- Renderer code calls
window.codeburnonly throughapp/renderer/lib/ipc.ts. - Main process handlers return JSON envelopes so structured CLI errors survive IPC.
- Missing CLI, bad JSON, timeout, and nonzero exits are surfaced as honest UI states.
- The renderer never imports CodeBurn engine code from
src/; the data contract is spawn CLI, decode JSON, poll.
Data Contract
Current bridge calls:
- Overview:
codeburn status --format menubar-json --period <period> [--provider <provider>] - Plans:
codeburn status --format json --period <period> - Models:
codeburn models --format json --period <period> [--provider <provider>] [--by-task] - Optimize:
codeburn yield --format json --period <period> - Spend flow:
codeburn spend --format flow-json --period <period> [--provider <provider>] - Devices:
codeburn devices --format json --period <period> - Device scan:
codeburn devices scan --format json - Share status:
codeburn share status --format json - Identity:
codeburn identity --format json
Supported M1 periods are today, week, 30days, month, and all. Provider filtering is passed through where the CLI command supports it.
Sections
- Overview: daily spend, spend stats, waste summary, and expensive sessions from
menubar-json. - Spend: project/activity/tool/MCP/subagent lenses plus model-to-project flow.
- Optimize: waste findings from
menubar-jsonand reverted/abandoned yield data. - Models: model and task tables from
models --format json. - Plans: plan pacing from
status --format json. - Settings: device identity, nearby scan results, paired-device usage, and M2 visual affordances.
Packaging
npm run package produces an ad-hoc-signed macOS .dmg/.zip (arm64 and x64) via electron-builder, no paid Apple Developer account required. Packaging rebuilds the root CLI and bundles it into the app (Resources/cli), so installs need nothing on the target machine. See DISTRIBUTION.md for build instructions, the bundled-CLI mechanism, artifact locations, and the Gatekeeper first-open story.
M2 Backlog
- Add Electron
autoUpdater(the app already bundles its own version-matched CLI, so end-user installs need nothing on the machine; auto-update is the remaining piece). - Keep npm as a separate CLI-user channel at the same version as the desktop app.
- Add macOS code signing with a paid Developer ID and notarization (ad-hoc packaging exists today; see
DISTRIBUTION.md). - Add a
codeburn desktoplauncher subcommand. - Implement in-app pairing, approve, pull, and visibility mutations currently shown as M2 affordances.
- Build the Models Compare sheet.
- Add light theme support.
- Expand
codeburn optimize --format jsonwith evidence and fix commands so Optimize can show richer actionable fixes.