* fix(quota): stop at the first keychain Deny instead of prompting again for the same item A refused or unanswered lookup on the user account fell through to the service-only lookup, which matches the same item and raised a second prompt. An unanswered dialog then waited twice, past the quota timeout, and ended as "Timed out." The reader now returns accessDenied at the first refusal; only a genuine miss tries the next account. The CLI row says the access was denied or not answered. * fix(quota): end the ZCode token at its journal frame length The token was read greedily up to the first non-token byte, so when the login ended a write batch the next record's checksum bytes could be appended to it, and every poll sent a corrupted token and reported a false "Login expired". The reader now decodes the value's varint length and slices exactly the string after the encoding flag. * fix(quota): report an expired Gemini login as needing the user Without a refresh client an expired Gemini CLI token was sent as-is and the 401 read as a transient failure on every poll, so the row stayed "Temporarily unavailable" and never said what to do. A 401 on a token whose expiry has passed and that nothing refreshed is now terminal, with a footer to run Gemini CLI once, as Claude already does. * fix(quota): stop only at a keychain Deny or unanswered prompt, and remember it for the run An error that showed no prompt (an I/O failure, interaction not allowed) moves on to the next account again, as before. A Deny or a prompt left open until the timeout ends the lookup, and the CLI keeps that refusal for the rest of the process, so a second read of the same service answers without a prompt. Nothing is persisted, so the next run asks once. The Claude row now says which it was: denied, or not answered. * fix(quota): treat a rejected Gemini login without a refresher as terminal The stored expiry can be missing or skewed, so it no longer decides: with no client credentials or refresh token nothing here can mint a new token, and the 401 needs the user to run Gemini CLI. With a refresher configured the 401 stays transient. * fix(quota): pick the newest ZCode login by journal position across encodings Latin-1 matches were preferred over UTF-16LE ones, so a rotation that changed the string encoding returned the older token. The last write by offset now wins regardless of encoding. * fix(quota): remember a keychain refusal per account and classify only our own timeout as unanswered The run's refusal memo is keyed by service and account, so denying one account no longer hides another account's item. Only the kill from our own timeout counts as an unanswered prompt; any other signal is an ordinary error that moves on. A string exit code is normalised, so "128" is a Deny like 128. * fix(quota): report a ZCode login the app cleared as expired An empty newest write for the key means the app cleared the login. It used to be skipped, so an older token in the same or an older journal was sent instead. It now reads as an expired login without a request. * fix(quota): skip a refused keychain account, time prompts with our own timer, and remember refusals in the desktop app A refusal remembered for one account now skips that account (and the service-only lookup, which can match the same item) and goes on to the next named account, instead of ending the read. An unanswered prompt is now only our own 90 s timer firing: the lookup runs under an AbortSignal whose timer sets a flag, and a kill or signal we did not cause is an ordinary error that moves on. The desktop app keeps the same service-plus-account refusals; a keychain-allowed refresh, which is the user acting again, clears them, so one action asks at most once per item. * fix(quota): treat a malformed newest ZCode write as unreadable, not as the older token Only the newest write of the key is read now. If its frame does not parse (no length, zero length, a length past the end of the file, an unknown flag, or bytes that are not a token) the poll reports a transient failure without a request, instead of falling back to an older token the app already replaced. This cannot be narrowed to in-progress writes: the leveldb log splits a record that crosses a 32 KiB block boundary with a 7-byte header, so a complete write can also fail to parse as one contiguous frame, and a torn tail after a crash looks the same. Both are treated as unreadable for this poll. * fix(quota): count only real leveldb records of the ZCode key as writes The newest write was the last place the key name appeared, so another entry whose value mentions the key (a settings blob, say) was read as a newer, malformed write and the login was reported unreadable. A token value itself cannot hold the key, since ':' is outside the token alphabet. An occurrence now counts only when it ends the key of a leveldb record: tag, varint key length, then `_`, origin, NUL, string flag and the name. A delete record of the key reads as a cleared login. * fix(desktop): say whether the Claude keychain prompt was denied or left unanswered The desktop keychain reader now carries the same refusal reason as the CLI's, and the Claude adapter turns it into the same footer line. The Plans card and the Settings row show that line in place of the generic keychain message for an access-denied row, keeping the generic copy when no reason is known. * fix(quota): read the ZCode key only under its own origin and reject odd UTF-16 frames A record now counts as a write of the login only when its key is ZCode's own origin prefix (`_https://zcode.z.ai`, a NUL, the string flag) followed by the key name, as in the recorded journal from #1347 (tag 01, key length 2b, `_https://zcode.z.ai`, 00 01, `oauth:zai:access_token`); the same key under another origin is ignored. A UTF-16 value with an odd byte count was trimmed by the decoder and could still look like a token; it is now read as unreadable for this poll, with no request and no older token. Not changed: a counterfeit record header embedded inside another entry's value. The journal is ZCode's own local storage on the user's machine, not input from anyone else; whoever can write those bytes already holds the account, and with the origin check a forged record would also have to carry ZCode's exact origin prefix and a matching key length. * fix(quota): skip a later service-only keychain lookup once an account of the service was refused A service-only lookup can match the item the user just refused, so a refusal for any account now also marks the service-only lookup as refused for the run. A later read with only the service-only candidate answers from memory instead of prompting again. Named accounts that were not refused are still read. Not changed: a Deny for one account still ends that read without trying the next account. That is deliberate: the consent policy is stop at Deny, and prompting for the next account right after the user declined is the double prompt this branch exists to remove. |
||
|---|---|---|
| .. | ||
| 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 | ||
| vite.vscode.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.
Refresh tiers
Not every call runs at the same cadence. The headline overview is the only live poll; it asks for neither optimize findings nor a fresh act report. act report refreshes on mount, on a manual refresh, and every 10 minutes; yield every 5. The optimize scan runs at most once a day per query scope, is stored in userData with the time it was computed, is reused only on the same local day, and is forced fresh by the Optimize page or a manual refresh. A figure that is not live is shown with its age. On battery the live interval doubles. While the window is hidden the app stops polling and animating altogether, and catches up immediately when it comes back.
The CLI is spawned once as a resident codeburn serve --stdio child rather than per request. After 15 idle minutes it is retired and the next request starts a new resident; CODEBURN_SERVE_IDLE_MS tunes or disables that.
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 a macOS .dmg/.zip (arm64 and x64) via electron-builder. Release builds are signed with a Developer ID Application certificate and notarized by Apple (ad-hoc signing is only a fallback when no signing identity is configured). 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 notarization process.
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 a
codeburn desktoplauncher subcommand. - Implement in-app pairing, approve, pull, and visibility mutations currently shown as M2 affordances.
- Build the Models Compare sheet.
- Expand
codeburn optimize --format jsonwith evidence and fix commands so Optimize can show richer actionable fixes.