Commit graph

351 commits

Author SHA1 Message Date
iamtoruk
b94338a75c feat(menubar): add a language picker to Settings
Settings > General > Language offers System, English and 简体中文. It writes
AppleLanguages into the app's own preferences domain, the same key System
Settings > Language & Region > Applications writes, so the two surfaces are one
setting. The current value is read back from that domain rather than through
UserDefaults.standard, which falls through to the global domain and would
report the system language as CodeBurn's own override: System could then never
show as selected. An inline row offers the relaunch that applies it.
2026-09-12 16:12:11 -07:00
iamtoruk
20f151faa4 fix(menubar): budget the second row by the width it draws
The 24-unit budget was a Character count, so "GitHub Copilot 剩余 12% · 6 小时
2 分" fitted it at 24 Characters while drawing 31 cells: a third wider than
the first row it is not allowed to exceed. abbreviate now measures East Asian
wide and fullwidth scalars as two. All-Latin rows are unchanged.
2026-09-12 16:12:11 -07:00
iamtoruk
82b02faa4f fix(menubar): keep the English weekday row two letters wide
veryShortWeekdaySymbols gives en "M T W T F S S": two ambiguous pairs, and
two duplicate ForEach ids. shortWeekdaySymbols clipped to two units keeps
"Mo Tu We" in English and reads 周一 周二 in zh-Hans, 19.9pt in a 30pt cell.
2026-09-12 16:12:11 -07:00
iamtoruk
f995593f2a fix(menubar): carry the localization catalog onto current main
Rebase resolution for #1289 onto main (#1306, #1313, #1314, #1315, #1328,
#1329). Conflicts kept both intents: main's second-row title composition,
glance-window accessibility actions, cache-read line, host field and merged
Notifications section keep their behaviour and now resolve through L(…).

Adds 14 keys to both tables, drops 4 that no longer have a call site, and
retranslates the two Copilot explanations main rewrote.
2026-09-12 16:12:11 -07:00
ozymandiashh
e8ae6cb9c4 feat(menubar): translate the strings the two new menubar features added
and #1286's Copilot host fix all shipped user-facing copy that bypasses the
catalog — neither of the first two PRs' diffs contains a single `L(` call. In a
zh-Hans build those strings render in English.

Sweeping mac/Sources the way the original extraction did brings 18 new keys,
and retires 2 that main reworded (the Copilot help paragraph gained the
GitHub Enterprise Cloud host rule; the connection detail now names the host
that answered rather than hardcoding api.github.com). 533 keys become 551.

Routed here:

- Second row: the Settings toggle, the metric picker and its four option
  names, the help paragraph, and the row text itself — today's cost, today's
  tokens, and the quota row with and without a provider label. The reset
  countdown reuses the popover's own `%lldd %lldh` / `%lldh %lldm` / `%lldm`
  keys rather than minting a second set, so the two countdowns cannot
  disagree in a translated build.
- Capacity Dock glance: the switch hint and the named VoiceOver action.
- Copilot: the reworded help paragraph and the host-aware connection detail.

Kept verbatim, per the rules in the catalog header: provider, model and plan
names; `tok`; the `%.2f` amount and its currency symbol; and the window label
the gauge reports, which is provider data and doubles as the matching needle
in CapacityDockGlanceWindow — translating the generic fallback alone would
make one VoiceOver sentence half-Chinese depending on the provider selected.

Also localizes CodexUsage's credit-limit labels. Those are not new, they were
missed by the original extraction and the guard test in the next commit finds
them; leaving them would mean shipping a test that fails on main.

Verified with a standalone swiftc harness over both tables (`swift test`
cannot run on this host): key parity, no blank values, en identity, and
argument/literal-percent specifier parity, plus the new rows formatting
correctly in both locales.
2026-09-12 15:22:47 -07:00
ozymandiashh
9eebfda627 feat(menubar): add Simplified Chinese (zh-Hans) localization
All 533 catalog keys translated into zh-Hans, so the menubar app now follows
the system language with no setting to find and no third-party library. AppKit
picks the table: `CFBundleLocalizations` in both packaging scripts advertises
`en` and `zh-Hans`, which is also what puts the app under System Settings >
Language & Region so a user can override the language for CodeBurn alone.

Wording follows macOS system apps rather than a literal gloss: 立即刷新,
断开连接, 存储并连接, 载入配额, 再试一次. Product nouns stay as users
already know them: provider, model and plan names (Claude, Codex, Gemini,
Opus, Sonnet, Antigravity), Token, Dock, API, OAuth, shell commands and file
paths, currency codes.

Format specifiers are identical to the English entry in count and argument
order. `%%` is a literal percent sign and not an argument, so it may move where
Chinese word order demands it ("%@ · %@ 达到 100%%"); the argument-consuming
specifiers may not, because String(format:) binds them positionally. The next
commit's test enforces exactly that distinction.

Numbers, dates and currency are untouched: they already went through
NumberFormatter / DateFormatter / asCurrency(), and `L(_:_:)` only substitutes
values those produced.
2026-09-12 15:21:49 -07:00
ozymandiashh
d62857ea4e feat(menubar): route every user-facing string through a strings catalog
Groundwork for #1219. The menubar app hardcoded ~530 English strings across
Views/, the presentation structs, the status-item menu and the update alerts,
so there was nothing for a translator to translate.

Every user-facing literal now goes through `L(_:)` / `L(_:_:)`, which look the
string up in `Localizable.strings` in the SwiftPM target resource bundle. The
key *is* the English copy, so English stays the development language and a
missing translation degrades to correct English instead of a dotted
identifier. `en.lproj` is therefore an identity table; it exists so the bundle
advertises `en` and so a translation can be diffed against it.

Why the lookups are explicit rather than relying on SwiftUI's implicit
`LocalizedStringKey`: SwiftPM emits target resources into a sibling bundle
(`CodeBurnMenubar_CodeBurnMenubar.bundle`) that the packaging scripts copy into
`Contents/Resources`. `Bundle.main` has no `.lproj` at all, so `Text("literal")`
would always miss. Naming `Bundle.module` is the one form that resolves the
same way in `swift run`, in `swift test` and in the packaged `.app`.

Enum raw values that double as identity (`Period`, `MenubarScope`,
`InsightMode`, `AccentPreset`, `ProviderFilter`) keep their raw value and gain
a `displayLabel`, so persistence and cache keys are untouched by translation.

Three display-only date formatters that were pinned to `en_US_POSIX` with fixed
patterns now use `setLocalizedDateFormatFromTemplate`, and the calendar
popover's weekday row comes from the locale's own symbols. The `yyyy-MM-dd`
formatter stays POSIX: it parses and builds data keys, not display text.

Not extracted, deliberately: provider, model and plan names; units; currency
codes; shell commands and paths; quota window labels that policy code matches
on by English substring (`QuotaSummary.headlineWindow`); and anything the
`codeburn` CLI produces.

Also copies the SwiftPM resource bundle into the app in build-local.sh, using
the named-bundle + `[[ -d ]]` pattern package-app.sh already uses. Without it
the assembled app finds no strings table (and already trapped on first icon
load, the resource-bundle half of #1262).
2026-09-12 15:21:49 -07:00
iamtoruk
cbcd984929 fix(mac): say what a usage-drop early reset actually did
Both early-reset signals shared one sentence, so a window whose counter
the vendor emptied mid-cycle was announced as "reset 18h early" even
though its reset time had not moved and the cycle still ended when it
always would have. Replaying this Mac's own 30 days of snapshots through
the monitor produces exactly that: on 2026-09-01 the weekly counter went
81% to 0% with resets_at still at 2026-09-04T07:00:00Z, and the copy
promised a new window that was not coming.

usageDropped now gets its own title, body, band and help text; the
reset-moved-forward wording is unchanged. lead() rounds to the unit it
prints instead of truncating, so a 1h57m lead reads "2h", not "1h".

Tests pin both, assert a usage-drop event never says "reset early", and
pin the notice expiry and the cycle anchor tolerance by value rather
than by reading the constants back.
2026-09-12 14:58:42 -07:00
ozymandiashh
55e4bc643e feat(mac): tell the user when a quota reset came early
Detection rides the refresh lifecycle that already runs: it happens where
each successful Claude fetch is captured into the snapshot store, before
the store is written, so it costs no request. Issue #725 names "no new
network polling loops" a hard non-goal, and this adds none.

Three surfaces, because the user can be looking at any of them. A system
notification names the provider, the window and the lead. The Capacity
Dock carries a band saying the same for twelve hours after the reset was
seen, drawn and reserved exactly like the staleness notice, because the
panel's frame is computed rather than fitted. The quota hover card gains
this Mac's own pattern next to the pace captions.

The state before the fetch decides whether the stored baseline can be
compared against it: a provider coming back from a terminal failure, a
fresh bootstrap or no credentials has a baseline from the far side of a
gap, where stale state looks like a jump. A window the API did not report
this time is passed as absent rather than omitted, so a window that comes
and goes is never read as a reset. Disconnect drops the baseline along
with the snapshots, so a reconnect under another account starts clean.

The Settings switch is on by default, and turning it off withholds only
the notification — the dock band still appears, since it is a caption on
data the user is already looking at rather than an interruption.
2026-09-12 14:58:42 -07:00
ozymandiashh
c9e8547dae feat(mac): decide early quota resets in pure, testable types
Vendors sometimes reset a usage window ahead of schedule as a goodwill
gesture. Nothing in the app noticed, so the capacity that was handed back
went unused.

The decision is two pure pieces so it can be tested without a view or a
network: a detector that takes the previous and current reading of one
window and returns an optional event, and a summariser that reads a
window's early-reset pattern out of the snapshots already on disk.

Detection needs both signals to be defensible on their own. A reset time
that jumps to a genuinely new cycle while the stored one still had time
to run is one; usage emptying while the advertised reset time stands
still is the other, for vendors that grant the reset without moving the
time. Both carry the same identity for the cycle they cut short, so the
second cannot re-announce what the first already said.

The thresholds are deliberately conservative, because a false "you have
your capacity back" is worse than silence. Inside a cycle reported usage
only rises, moving down by a point or two of rounding, so the drop signal
asks for a fall of at least 40 points that lands at or under 10% — far
outside rounding, with room for a refresh interval of real use after the
reset. A new cycle cannot start before our last look at the old one, so
its reset time must sit about a window past that look; a reset time that
merely creeps forward is a rolling window, not a reset.

Silence is the answer for a scheduled reset, a plan change, clock or
timestamp skew (the discipline QuotaPace already applies), a window
appearing or disappearing, a window's first observation, a reconnect
after a failure, and a reading that is missing or malformed.

The monitor around it keeps the previous fetch's readings, the plan label
and the reset times it has already announced, and delivers through the
existing UpdateNotifier rather than a second notification stack. The
snapshot store keeps each cycle's highest reading, which is right for
"what did the cycle end at" and wrong for "what did the last fetch say",
so the baseline is kept alongside the announcement record instead.

History is derived from the stored reset times alone: a fixed window
starting at t ends at t + length, so a cycle ending sooner than a full
window after the previous cycle's scheduled end began early by the
difference. No network, no external feed.
2026-09-12 14:58:17 -07:00
iamtoruk
84934ca71f fix(macos): only install an update when the update notice is tapped
The notification delegate ran performFullUpdate() for any notification
tapped. With a second notification kind, tapping "Codex banked a limit
reset" would start a CLI and app update.

Gate the handler on the UpdateChecker identifier prefix, shared as a
constant so the poster and the handler cannot drift.
2026-09-12 14:48:50 -07:00
ozymandiashh
6be422ac52 feat(quota): show Codex limit resets in the Plan tab, hover card and CLI
The Plan tab row #724 added showed a count and an expiry. It now also shows how
many of those credits can be applied right now and when the most recent one
landed, which is what a user deciding whether to push through or throttle back
actually needs. The same sentence appears in the agent-tab quota hover card and
in `codeburn quota`.

One formatter produces it, mirrored line for line in Swift and TypeScript, down
to the compact-age rules — deliberately not RelativeDateTimeFormatter or
Intl.RelativeTimeFormat, because the two surfaces have to print the same
characters, and a locale-aware formatter would not. `codeburn quota` grows a
`notes` channel for provider facts that are not a window; only Codex sets it, so
every other provider's output is byte-identical to before.

The CLI reads the credits off the `rate_limit_reset_credits` block of the usage
response it already fetches and never calls the companion endpoint, so it prints
the count without the grant and expiry captions that only the per-credit list
carries.

Refs #725. No new polling loop and no new data source: this reads fields from a
response already fetched on the existing cadence.
2026-09-12 14:37:24 -07:00
ozymandiashh
79d1482951 feat(codex): notify once when OpenAI banks a limit reset
A banked reset is the one capacity signal a user can act on before it is spent,
and it arrives silently. CodeBurn already sees it: the reset-credit inventory
rides every successful Codex quota refresh. Comparing that inventory against the
previous reading is all it takes to notice a grant, so there is no new endpoint,
no new cadence and no new data source here.

The detection is a pure function over an observation and the state it is judged
against, which is what makes the awkward cases testable rather than hopeful:

- The first-ever observation is a baseline. Everything the account already holds
  is history, not a burst of notifications.
- A credit that disappears was spent or expired, and is never an event. Its id
  is kept for the retention window so a payload that lists it again — a flicker,
  not a grant — cannot re-announce it.
- An absent or malformed credits payload is *no opinion*: no event, and no state
  change at all. Treating it as an empty account would re-baseline on every
  failed fetch and re-announce the whole inventory on reconnect.

Seen ids persist to `codex-banked-resets.json` in the CodeBurn cache directory,
written through SafeFile behind an actor exactly the way SubscriptionSnapshotStore
writes its snapshots — the same mechanism, not a second one — so a relaunch does
not repeat a notice. State is written before the post, not after: a notice we
drop is a smaller failure than one that repeats forever. Disconnecting clears the
file, so a reconnect under another account baselines again.

The notification goes out on the existing UpdateNotifier path, one per new
credit, naming what was granted, when, and how many are usable. Never the credit
id, never a token. Settings gains a toggle, default on; with it off the state is
still recorded, so turning it back on does not release a backlog.

Nothing here ever spends a credit. It is a notice.
2026-09-12 14:37:24 -07:00
ozymandiashh
53dd90a4a7 feat(codex): read the per-credit fields the reset-credits payload already carries
The reset-credits decoder kept only `available_count` and the soonest expiry,
and the inline block on the usage payload kept only `available_count`. The
response has always carried more: `id`, `reset_type` and `granted_at` per
credit, and `applicable_available_count` alongside the total. Those are exactly
the fields needed to tell a newly granted credit from one the account was
already holding, so they are decoded now instead of discarded.

Identity comes first: a credit is reduced to a grant only if it carries an `id`
or, failing that, a `granted_at` to be named by. One that carries neither still
counts toward the server's authoritative total but never becomes a grant,
because it could not be told apart from the next one and would re-announce
itself on every refresh. Only `status == "available"` credits become grants, so
a redeemed one is spent history rather than news.

`applicable_available_count` is unknown when absent, never zero. The companion
endpoint does not always send it and the usage payload sometimes does, so the
usage response we are already holding fills it in when — and only when — the
authoritative source said nothing. No extra request either way.
2026-09-12 14:37:24 -07:00
Resham Joshi
9715637bec
Merge pull request #1314 from getagentseal/fix/dock-pace-followups
feat(menubar): cache-read usage and quota pace in the Capacity Dock
2026-09-12 22:40:46 +03:00
Resham Joshi
d5e2d22880 fix(menubar): stop the dock resizing and claiming a refresh it is not doing
Reserving the pace slot only while connected made the panel relayout on
every refresh: the slot collapsed and the staleness band appeared. The
reservation is a property of the window shape, so it no longer asks the
connection. Windows block on the real Claude shapes, connected vs stale:
91/77 -> 91/91 at one and two windows, 164/136 -> 164/164 at three.

A Claude or Codex summary now reads stale on sample age alone, and the
manual cadence never refreshes, so "Last known usage - refreshing" and
the Settings "Refreshing..." became permanent lies. Both now ask whether
a fetch is actually in flight.
2026-09-12 12:19:29 -07:00
ozymandiashh
53cd44daf2 fix(menubar): give the pasted Copilot token a GitHub host of its own
The last rung of the chain is a token the user pastes into Settings, and an
enterprise personal access token pasted there was still sent to
api.github.com. Settings now takes the host beside the token, defaulting to
github.com, and saves both in the same provider Keychain record so the host a
request is addressed to always comes from the entry that carried the token.

A host no endpoint can be derived from is refused at the field instead of
being stored and reported later as a terminal fetch failure, and the crafted
values #1286 guarded against are refused there too. Clearing the token clears
the host with it, so a stale tenant can never be paired with the next token.

The record's decoding moves into an extension and reads every key with
decodeIfPresent: Swift's synthesized init(from:) ignores a property's default
and throws on a missing key, so adding a field would otherwise make every
credential saved before it unreadable — for every provider, not just Copilot.

The dormant connection row no longer promises api.github.com before anything
has been fetched; it names a host only once one has answered.

Tests cover the three new host sources with a hostile value each, the rung
wiring for all five rungs, the gh hosts.yml key scan, and that a record
written before the host field still decodes.
2026-09-12 12:02:13 -07:00
ozymandiashh
1b4c00f8d5 fix(menubar): follow GH_HOST and gh's own host for the Copilot env and gh rungs
#1286 taught the credential files to carry the GitHub host their token came
from, but the environment and `gh auth token` rungs carried none, so they were
always addressed to api.github.com. A user whose only Copilot credential is a
GitHub Enterprise Cloud login — GH_TOKEN exported alongside GH_HOST, or
`gh auth login --hostname <tenant>.ghe.com` — got a 401 and a terminal failure
with nothing to act on.

The environment rung now reads GH_HOST out of the same environment as the
token. The gh rung resolves the host from gh's own hosts.yml, found via
GH_CONFIG_DIR, then XDG_CONFIG_HOME/gh, then ~/.config/gh, and picked the way
gh picks the host for `gh auth token`: GH_HOST, else the single configured
host, else dotcom. That is a file read rather than a second `gh auth status`
spawn, because gh writes hosts.yml for every login, keyring-backed ones
included.

Both are new untrusted inputs, so they stay raw all the way to
`apiHost(for:)`, where #1286's character validation refuses a crafted value
such as `evil.com?.ghe.com` before any URL exists — that host passes the
`.ghe.com` suffix check but builds a URL whose host is api.evil.com, which
would then receive the Authorization header.
2026-09-12 12:02:13 -07:00
ozymandiashh
610cae48c7 feat(menubar): plain pace verdict, also on the agent-tab quota card
Ports the two parts of #1287 the maintainer asked to keep, expressed
through this branch's `QuotaPacePresentation` rather than through
`QuotaPace.Verdict`:

- Placement: `QuotaDetailRow` in the agent-tab quota hover card becomes
  a VStack and draws the pace line under the bar, indented past the
  label column, with the three tones the dock already uses. The card is
  fitted, so a silent caption collapses there instead of reserving a
  slot the way the dock's computed frame must.
- Wording: the long-window caption drops "est. N% at reset" /
  "est. out in X" for the plain "Lasts until reset" / "Runs out in X",
  and the exhausted state becomes "Limit reached". The projected
  percentage it came from stays in the hover text, which has room for
  the reasoning. Short windows keep the on-pace / deficit / reserve
  stage (#726), and the freshness, connection and duration gates are
  untouched.

`QuotaPace.inferredWindowSeconds(label:)` is deliberately NOT ported.
Grok Build chooses its window label from the distance to the reset, so
a monthly cycle passing through the 4-12 day band is labeled "Weekly"
and a label round trip paces a month's budget against seven days. The
adapter's real `windowSeconds` is the only source here, and a new test
pins that shape: 72% used with six days to a monthly reset reads
"Lasts until reset", while the same sample against an inferred 7-day
window overflows and would have printed "Runs out in 9h 20m". The same
test asserts a window with no duration metadata stays silent rather
than falling back to its label.

Verified with a standalone swiftc harness over QuotaPace,
QuotaPacePresentation and QuotaSummary: this host has Command Line
Tools only, so `swift test` cannot load the Testing module.

Closes #1267
2026-09-12 20:32:14 +03:00
ozymandiashh
a0d08c81f0 fix(menubar): pick the second row's provider by its worst quota window
The "quota remaining" row selected each provider's headline window, which
is a billing horizon: weekly, else monthly, and only then the busiest
window. That is the right number for the Capacity Dock rail and the wrong
one for a row whose whole job is to name the provider nearest its limit.
On a real machine it discarded Cursor's API window at 100% and Claude's
5-hour window at 18% in favour of Monthly 9.5% and Weekly 5%, so the row
read as if nothing were near a limit — while the flame beside it was
tinting off the worst window across every provider. The comment claiming
the row followed the flame was wrong on both counts.

Each provider now contributes its worst window, per-model rows included,
which is exactly the rule aggregateQuotaStatus tints by, so the row and
the flame agree and README, CHANGELOG and the Settings help become true
as written. A provider in transientFailure keeps its last-known window
instead of dropping out, matching the dock, which shows the same data
dimmed during a backoff: the row no longer vanishes and resizes the
status item for the length of a retry.

Three smaller fixes from the same review: the row is capped at 24
characters — about the widest the single row gets at 13pt, since the
second line renders at 9pt — shortening a long provider name rather than
letting "GitHub Copilot 12% left · 6d 3h" more than double the item's
width; the two-line title gets a VoiceOver label that reads as one phrase
instead of a string with a newline in it; and the snapshot feeding the
row is no longer built on refreshes where the feature is off. With the
setting off the title is byte-for-byte the single-row composition it has
always been.

Closes #1310
2026-09-12 20:29:35 +03:00
ozymandiashh
75f537e974 Merge origin/main into cache-read and quota pace
Main took render revision 6 for `sessionCountBasis` and changed the
provider-slice session fold from a sum to a per-day max. Both had to
survive the merge, so the resolutions are unions rather than sides:

- `addProviderSlice` keeps main's `Math.max` for `sessions` (per-day
  ticks are not distinct identities) and adds the cache-read sum beside
  it, with a comment saying why one is additive and the other is not.
- `ProviderSliceTotal`, `ProviderCost`, `providerDetails` and the Swift
  `ProviderDetail` carry both `sessionCountBasis` and `cacheReadTokens`.
- The snapshot revision stays 7, which is still the next free number
  above main's 6. Its doc comment said v6 was PR1265's per-model counts;
  it is main's `sessionCountBasis`, so the comment now says that.

The status-menubar suite hard-codes render revisions. Main's assertion
that a rejected v5 snapshot is rewritten as `:render-6:` auto-merged
cleanly while this branch moved the current revision to 7, which would
have failed silently on the next bump too. Those assertions now derive
the tag from `STATUS_SNAPSHOT_RENDER_VERSION`, so the current and
previous revisions follow the constant; the deliberately historical
`:render-5:` and `:render-2:` plants stay literal.
2026-09-12 20:27:33 +03:00
ozymandiashh
5b5dc5aceb feat(menubar): switch the Capacity Dock gauge between usage windows
The resting rail shows one number per provider, and that number was always
the weekly (else monthly) billing window. A user watching Claude's 5-hour
limit had to expand the dock and read the glance card every time, which
defeats the point of an always-visible usage monitor.

Clicking the provider that already rests in the rail now switches its gauge
to the provider's short rolling window and back. The preference is stored per
provider rather than as a Claude-only switch: the dock's collapsed row is
provider-agnostic, and Codex publishes a 5-hour and a weekly window too, so
the question is "which horizon for this provider", stored under
CodeBurnCapacityDockGlanceWindows alongside the other dock preferences.

The two horizons are named rather than labelled, so the policy works for any
adapter: billing reuses QuotaSummary.headlineWindow, the app's single
definition of the weekly/monthly glance, and burst matches the short rolling
rows the adapters emit (5-hour, Hourly, Daily, session) while excluding
anything weekly or monthly, so Claude's per-model "Weekly · Opus" row can
never be read as a short window. CapacityDockGlanceWindow keeps that policy
pure and testable, including the fallbacks: a provider with one window shows
it whichever horizon is stored, and a stored horizon the provider stops
reporting resolves to the one it does report instead of blanking the gauge.

The click cannot fight the hover expansion: this branch only ever pins, never
collapses, and it is reached only when the provider actually has two windows,
so a single-window provider keeps the existing click-to-pin toggle. Escape
and an outside click still unpin. Keyboard and VoiceOver users get the same
switch as a named accessibility action on the provider cell, and the cell's
accessibility value now names the window feeding the ring. The rail's
geometry is untouched.

Closes #1243
2026-09-12 06:38:34 -07:00
ozymandiashh
a08dfec842 fix(menubar): make the two-row height a fit contract, not an exact figure
CI's swift test on macos-latest measured the two-row title at 21pt where this
machine measures 20pt, so the exact-equality assertion failed 16 times. The
figure is release-dependent: SF Symbol metrics and line rounding move between
macOS versions. Nothing positions the rows off it — AppKit's button cell
centres whatever it measures inside the status item — so 21pt is centred just
as correctly as 20pt, and the requirement was always "fits a 22pt menu bar",
not "measures exactly 20pt". The test now asserts that band, and
twoRowMeasuredHeight is replaced by twoRowMaximumHeight (the bar) and
twoRowMinimumHeight (a floor, so a lost paragraph clamp or a dropped second
line is still caught rather than passing as "fits").

The 1pt delta does expose a real risk the constant was hiding: the first line's
height follows the flame image, and the image size for a point size is the
system's business. A release that renders it taller could push the title past
the bar. The two-row attachment box is now computed by
twoRowAttachmentBounds(imageSize:), which scales the image down to the clamped
line height — never up — so the first line cannot outgrow its clamp. Verified
by composing the real title with the flame forced to 11, 13, 16 and 24pt tall:
every combination still lays out at 20pt here. The single-row path keeps the
raw image size and its -3pt offset, so it stays byte-identical.
2026-09-12 06:37:46 -07:00
ozymandiashh
016b8edaef feat(menubar): optional second row in the macOS menu bar item
The menu bar item could show one figure, so seeing subscription quota and
today's local usage at the same time meant opening the popover. This adds an
optional second line, off by default, configured from the existing
Settings > General > Display section: a "Second row" toggle plus a picker for
what it shows. All four metrics are figures the app already computes for the
popover, so nothing here adds a fetch or a refresh cadence: quota remaining
with its reset countdown for whichever connected provider is nearest its limit
(the same provider the flame already tints for), today's all-provider cost,
today's total tokens, or running sessions.

The rows are one attributed title. A paragraph style clamps text line height
but not an attachment, so the inline flame at the text's own point size dragged
the title to 24pt and AppKit clipped the second line away; the flame is
requested at 8pt and seated back inside the line, which puts every row
combination at exactly 20pt inside the standard 22pt menu bar, centred with 1pt
of slack above and below. Measured with NSAttributedString.boundingRect and
asserted in the tests, since those four numbers only work together.

With the setting off, or whenever the chosen metric has no data yet (no
connected provider with a quota window, no today payload, a CLI that predates
the liveSessions block), the title falls back to the previous single-row
composition unchanged: same font, same attributes, no paragraph style. The row
formatting is a pure type over the row settings and a plain-value payload
snapshot, so it is covered without an AppStore or a status item.

This is a deliberately reduced slice of the request. Not included: the layout
editor, presets, live preview, a third row, multiple items or aligned columns
per row, per-item provider/period/scope, optional labels, decimal precision,
reordering and text size. Keeping the formatter pure leaves room for those
later without touching the rendering path.

Closes #1252
2026-09-12 06:37:46 -07:00
iamtoruk
0225088984 fix(quota): reject a Copilot host carrying a URL delimiter
The `.ghe.com` suffix check ran on a normalized string that still allowed
`?`, `#`, `\` and spaces, and that string was interpolated straight into
the request URL. `evil.com?.ghe.com` in a hosts.json key passes the
suffix check but builds a URL whose host is `api.evil.com`, so the
Authorization header lands on a host that was never approved. Verified
on macOS: URL(string:) parses it as host `api.evil.com`, path `/`.

Both readers now require the normalized host to look like a DNS name
before an endpoint is derived; anything else fails as an unsupported
host, with no request sent.
2026-09-12 06:14:26 -07:00
ozymandiashh
8b5bd3ed4c fix(menubar): follow the credential's GitHub host for Copilot quota
Both Copilot quota readers hardcoded
https://api.github.com/copilot_internal/user and dropped the host their
credential was read from, so an enterprise on a GitHub Enterprise Cloud
data-residency host (<tenant>.ghe.com) could only ever report
"Temporarily unavailable": its token is not a dotcom token, and dotcom is
not an endpoint it may be sent to.

A discovered credential now carries its host. hosts.json is keyed by
GitHub host and newer apps.json files key by "<host>:<app id>", so the
token and the host always come from the same entry; the rungs that carry
no host of their own (an app-name apps.json key, COPILOT_GITHUB_TOKEN /
GH_TOKEN / GITHUB_TOKEN, gh auth token, a pasted token) mean dotcom. The
endpoint follows the host: api.github.com for github.com, and
api.<tenant>.ghe.com for an Enterprise Cloud host. With several hosts
signed in github.com wins, otherwise the first .ghe.com tenant in sorted
order, which keeps the pick stable across reads; with exactly one, that
host is used.

A host neither rule can address, such as a self-hosted GitHub Enterprise
Server install, fails with a message naming that host instead of falling
back to dotcom, and network and HTTP failures name the host that was
tried. macOS Settings now says which host answered in the Copilot
connection row. Tokens are still never logged and sanitizeForUI is
unchanged.

Closes #1286
2026-09-12 05:56:05 -07:00
iamtoruk
8b3cb68255 fix(mac): keep dock quota fresh when the payload tick is skipped
The background tick skips the whole refresh when local session files are
unchanged, but quota is server-side state, so the dock rings went stale
until the popover was opened. Run the quota half on skipped ticks, still
throttled by the subscription cadence.

Also refresh the dock providers before the Claude/Codex awaits so a slow
provider cannot delay them, anchor lastCodexRefreshAt on attempt like its
siblings, and query display sleep live instead of latching a flag that a
missed wake notification leaves stuck.
2026-09-12 03:47:46 -07:00
iamtoruk
5e8236f77f feat(mac): notify when an update is available 2026-09-10 12:39:38 -07:00
Resham Joshi
0fea397d14
Merge pull request #1278 from avs-io/codex/copilot-disconnect-1273-20260909
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
fix(mac): preserve explicit Copilot disconnect
2026-09-10 08:52:49 +03:00
iamtoruk
1ffa3ec6c6 fix(mac): drop the post-await disconnect guards the refresh generation already covers 2026-09-09 22:45:35 -07:00
Aditya Vikram Singh
541829998b fix(mac): stop Dock OAuth copy after Copilot disconnect
Nil-quota Capacity Dock used generic OAuth retry copy. Explicit
Disconnect leaves credentials, so reuse the existing disconnected
Settings detail for Copilot only.
2026-09-10 00:45:21 +05:30
Aditya Vikram Singh
8b9aca34e5 fix(mac): stop labeling selected-range Stats as today
Stats cards bind payload.current sessions/calls, which follow the
selected period, but the labels said today. Use period-neutral copy.
2026-09-10 00:39:58 +05:30
Aditya Vikram Singh
94218bf173 fix(mac): show honest Copilot copy after explicit disconnect
Plan and Settings treated sticky .notBootstrapped after Disconnect as
missing credentials. Keep first-use and real noCredentials sign-in copy;
disconnected state says quota tracking is off, credentials untouched,
and Connect resumes.
2026-09-09 22:59:56 +05:30
Aditya Vikram Singh
9794e94e44 fix(mac): preserve explicit Copilot disconnect across refreshes 2026-09-09 16:17:15 +05:30
iamtoruk
df38e63849 fix(usage): fold Windows case in spend identity, qualify --json counts, drop scratch tests 2026-09-07 14:56:32 -07:00
Aditya Vikram Singh
f5fd47e83d fix(usage): preserve project identity and qualify incomplete session counts 2026-09-07 22:02:54 +05:30
ozymandiashh
654583e4f0 Add cache-read usage and quota pace to Capacity Dock 2026-09-07 05:22:35 +03:00
Yishun Tang · CrazyAnt
87a01c25f5 fix(mac): prefer the node beside the CLI over a version manager's default
The app built PATH by appending its curated directories after the
inherited value, so whichever `node` came first won -- on an nvm machine
that is the default alias, which can be an older major than the one the
CLI was installed under. Every spawn then died on the engine gate
("codeburn requires Node.js >= 22.13.0 (current: v20.20.2)") and the
popover showed "Could not load Today" with nothing pointing at Node.

augmentedPath now takes the resolved CLI path and, when an executable
node sits in the same directory, moves that directory to the front of
PATH -- promoting it if already present, dropping nothing. That
interpreter is the one that installed the CLI and satisfies its engine
range. A bare `codeburn` or a CLI with no sibling node leaves the
inherited order untouched, so #1263's Nix layout is unaffected.

makeProcess resolved the CLI twice, once for PATH and once for argv; it
now resolves once and passes the same value to both.

Three tests cover the reorder, the promote-not-duplicate case, and the
untouched case; removing only the reorder block makes the first two fail
with the reported shape while every pre-existing test still passes.
2026-09-07 10:16:48 +08:00
sm0keyyy
dda323460b
fix(mac): resolve a Nix-provided node when spawning the codeburn CLI
On a nix-darwin machine node lives only in /etc/profiles/per-user/$USER/bin,
which appears in neither additionalPathEntries nor userNodePaths. The CLI shim
begins '#!/usr/bin/env node', so the spawn dies with
'env: node: No such file or directory' and exit status 127.

GUI apps normally inherit those directories from 'launchctl config user path',
stored in /var/db/com.apple.xpc.launchd/config/user.plist, which a macOS system
update deletes. Re-applying it is not durable, so name the Nix locations in
userNodePaths instead. That feeds both installedArgv() discovery and
augmentedPath() interpreter resolution.

Also adds ~/.local/bin, the bin directory for the common 'prefix = ~/.local'
npm configuration, which installedArgv() could not otherwise discover.

Entries are appended, so existing matches keep their precedence.
2026-09-05 22:56:57 -04:00
iamtoruk
bc9460951a fix(mac): scope Grok's omitted-percent-is-zero rule to unified billing; finish the fixture scrub
An omitted creditUsagePercent inside an open billing window was read as 0%
for every Grok account. That contract only holds for unified-billing users;
for anyone else it now stays unknown instead of showing a fabricated 0%.

The wireframe mockup still carried the one device name #1250 replaced
everywhere else.
2026-09-04 01:38:08 -07:00
Resham Joshi
7307b080cd
Merge pull request #1242 from mh7whmyz6z-alt/fix/grok-unified-billing-omitted-percent
fix(mac): treat omitted Grok credit percent as 0% in an active window
2026-09-03 13:46:59 -07:00
iamtoruk
eb992ff62c fix(dock): a tile can stand for more than one provider row
The glance's Today row was scoped to the hovered provider by matching one
catalog id against one payload row. Cursor read $0.00 with 14 calls
recorded, because the CLI splits that one subscription into `cursor` for
the editor and `cursor-agent` for the agent, and the tile saw only the
first. Droid read zero for a plainer reason: the tile carries the account's
id, `factory`, while the CLI records the product, `droid`.

A tile now maps to a list of payload rows and sums them: Cursor over both
its surfaces, ClinePass over `cline` and `cline-cli`, Droid onto `droid`.
Every other tile still stands for exactly one row, and no row belongs to
two tiles, so the per-tile figures still reconcile to the machine total.

A summed tile keeps a token field absent unless some row reports it, so an
older CLI that sends no per-provider tokens still reads as "no breakdown"
rather than as a zero the account did not earn.

Checked every one of the 69 tiles against the provider registry by id and
by display name; these three were the only mismatches. Mistral and Qwen
Cloud look similar but are not confirmed to be the same account as the
CLI's `mistral-vibe` and `qwen`, so they are left alone deliberately.
2026-09-03 09:21:23 -07:00
iamtoruk
8cfaa358ac fix(dock): scope the glance Today row to the hovered provider
The Capacity Dock's glance popover rendered the machine-wide Today block in
every provider's card, so hovering Claude showed the total across every
provider as if it were Claude's.

CLI (add-only): ProviderCost and providerDetails now carry optional
inputTokens, outputTokens and sessions, summed per provider in all three
branches that build the provider list. They stay ABSENT when no day in the
period reported a breakdown, so a consumer can tell "no data" from zero.
STATUS_SNAPSHOT_RENDER_VERSION 4 -> 5, since a v4 snapshot's payload predates
the new fields; the daily cache already holds the tokens, so its version is
untouched.

App: the Today row reads the hovered provider's row out of providerDetails
(matched on the CLI provider id, which the dock's kimi entry bridges to
kimicode). Against a CLI that omits per-provider tokens the arrows drop out
rather than falling back to the global pair; a provider absent from a
breakdown that IS present reads as a real $0.00. The row keeps its fixed
frame, so the panel's computed height is unchanged either way.
2026-09-03 08:32:20 -07:00
iamtoruk
7e74dcd426 Merge remote-tracking branch 'origin/main' into fix/glance-notice-section 2026-09-03 07:32:50 -07:00
iamtoruk
393b160688 fix(mac): give the glance's staleness line a section of its own
The line reading "Last known usage · refreshing" sat crammed against the
header with the blocks below pushed into it. Its height was reserved, but
only as 16 points: a bare 10pt line box with no padding, no side inset of
its own and no separator, while every other block in the glance carries
8 or 10 points of padding and a 16 point inset.

It is a section now, with the same inset, its own padding and a divider,
and the reservation grows from 16 to 27 to match so nothing below is
squeezed. Only the two in-progress states change; disconnected and
reconnect keep their own blocks with the action button.

The new test pins both halves: the reservation equals the band's height
for every in-progress connection, and the total stays whole at every
scale, since a fractional panel height re-runs the window's layout at
display cadence for as long as the dock is up.
2026-09-03 07:19:35 -07:00
iamtoruk
95abfde791 Merge main into fix/dock-detail-integral-height
The glance popover replaced the row-counted one while this branch was
parked, so `detailHeight` grew three parameters and this branch's copy of
the old body went with main's. The branch's assertion that the popover's
height is whole is now covered better by CapacityDockGlanceTests, across
every scale and against the new signature, so it goes rather than being
ported.

What the branch's remaining test caught is a live regression on main. Every
dock metric must be a whole number of points: a fractional panel length
re-runs the window's layout at display cadence for as long as the dock is
up, which is the drain #1210 fixed. `points` still rounds each base metric,
but the eased flare compensation added afterwards put the fraction straight
back, so the rail padding measured 30.6 and the panel 111.2 and 225.2
through the whole attach animation. Round the sum, not the base.

Nothing on main tests this; the parked branch is the only guard, which is
how the regression reached the release candidate unseen.
2026-09-03 06:36:15 -07:00
iamtoruk
a1cc32663f fix(mac): the Capacity Dock popover appears inside a full-screen space
Every window belongs to a set of spaces. The rail belongs to all of them;
the detail panel had been reduced to the desktop space alone, so hovering a
pill inside a full-screen app positioned the popover, faded it in and
ordered it front exactly as it does on the desktop, in a space the user was
not looking at. Measured on a running instance: the rail reported
spaces=[3, 63, 24, 137] with 137 active, the panel reported spaces=[3].

The membership is written once in init and never again. The window server
drops it across a display sleep or a display reconfiguration, and the rail
survives only because it is never ordered out. Re-assert it in showDetail,
the one funnel every presentation passes through. It has to be written, not
read and compared: assigning collectionBehavior is what re-registers the
window, and it must happen while the window is ordered out.

Also drop a duplicate `isFloatingPanel = true` that ran after the shielding
level was set. NSPanel.isFloatingPanel writes level = .floating, so the
second assignment silently discarded the level the comment above it asks
for: the dock measured at layer 3 instead of 2147483628, low enough for any
floating window to cover it. Both panels now report the shielding level.
2026-09-03 06:07:45 -07:00
mh7whmyz6z-alt
7122c70732 fix(mac): treat omitted Grok credit percent as 0% in an active window
SuperGrok Heavy unified billing drops creditUsagePercent after a weekly
reset. That matches grok.com (proto3 default 0), not a parse failure.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 15:06:17 -07:00
Resham Joshi
500412aa88
Merge pull request #1235 from avs-io/codex/provider-reconciliation-races
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / desktop (push) Waiting to run
Join provider refreshes and prevent scoped false zeros
2026-09-02 11:51:30 -07:00
Resham Joshi
3376d764e6
Merge pull request #1234 from avs-io/codex/provider-core-contract-repair
Repair provider usage and Hermes cost contracts
2026-09-02 11:50:56 -07:00