codeburn/app/electron
Resham Joshi 5d9d7a0b2f
fix(quota): one keychain prompt per action, exact ZCode token boundary, expired Gemini login reported once (#1904)
* 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.
2026-11-06 17:11:44 +01:00
..
quota fix(quota): one keychain prompt per action, exact ZCode token boundary, expired Gemini login reported once (#1904) 2026-11-06 17:11:44 +01:00
auto-update.test.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
auto-update.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
bridge-handlers.ts fix(desktop): keep the sessions answer under the pipe cap (#1889) 2026-11-05 22:55:40 +01:00
cli-win32-reap.test.ts fix: bound the serve drain, reap orphans on Windows, and de-flake the grace test 2026-08-22 10:36:58 -07:00
cli-win32-tree-kill.test.ts fix(app): actually kill the CLI process tree on Windows 2026-09-02 22:10:37 -07:00
cli.test.ts fix(desktop): decode CLI output as UTF-8, cap the decoded answer, stop rescanning the buffer (#1896) 2026-11-06 09:27:36 +01:00
cli.ts fix(desktop): decode CLI output as UTF-8, cap the decoded answer, stop rescanning the buffer (#1896) 2026-11-06 09:27:36 +01:00
companion-update.test.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
companion-update.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
mac-menubar.test.ts 0.9.25 round 2: fixes found testing the built apps (#1517) 2026-09-21 13:53:45 +02:00
mac-menubar.ts 0.9.25 round 2: fixes found testing the built apps (#1517) 2026-09-21 13:53:45 +02:00
main.test.ts fix(desktop): keep the sessions answer under the pipe cap (#1889) 2026-11-05 22:55:40 +01:00
main.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
menubar.test.ts Windows tray: fall back past a broken managed CLI to Volta and PATH installs (#1753) 2026-10-13 10:10:38 +02:00
menubar.ts Windows tray: fall back past a broken managed CLI to Volta and PATH installs (#1753) 2026-10-13 10:10:38 +02:00
optimize-store.test.ts 0.9.25: correctness, energy, menu bar and installer fixes (#1511) 2026-09-21 00:16:21 +02:00
optimize-store.ts 0.9.25: correctness, energy, menu bar and installer fixes (#1511) 2026-09-21 00:16:21 +02:00
preload.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00
telemetry.test.ts chore(telemetry): default on in every region (#1874) 2026-11-05 07:31:19 +01:00
telemetry.ts chore(telemetry): default on in every region (#1874) 2026-11-05 07:31:19 +01:00
tray-settings-atomic.test.ts fix(windows): wait out a reader when replacing a preference file 2026-09-03 11:10:33 -07:00
tray-settings-lock.test.ts fix(windows): close three holes in the cross-process preference lock 2026-09-03 10:28:05 -07:00
tray-settings.test.ts fix: keep a saved Capacity Dock provider across quota refreshes (#1768) 2026-10-31 03:48:01 +01:00
tray-settings.ts fix: keep a saved Capacity Dock provider across quota refreshes (#1768) 2026-10-31 03:48:01 +01:00
updates.test.ts fix(windows): Store installs get no GitHub update offer, and codeburn menubar opens the Store copy by its app id (#1520) (#1549) 2026-09-24 19:51:04 +02:00
updates.ts feat(update): desktop updates its companions and itself in one click (#1741) 2026-10-11 04:34:34 +02:00