Repository navigation
Commit 09d2d01
Claude: opt-in statusLine usage feed (#2769)
* Add the opt-in Claude statusLine usage feed
Implements the owner ruling on #2733: Claude Code publishes rate_limits to
whatever statusLine command the user configured, and reading what it publishes
does not cross the credential-ownership boundary the Keychain rules protect.
Off by default. When enabled, a .statusline step joins the app Auto order
behind .oauth and ahead of .cli, so it fills the gap while the polled sources
cool down and never pre-empts a successful OAuth read. When disabled the plan
is byte-identical to today: the step is inserted, not present-but-unavailable,
because planner order is asserted directly by tests and shown in debug output.
The source is never user-selectable. Pinning a feed that goes silent whenever
the user is not running Claude Code would strand the card, so it is excluded
from the picker and persists as Auto if it ever reaches settings.
Fail soft throughout: bad JSON, an unknown envelope version, wrong types, an
out-of-range percentage or a drifted schema all read as absence, which leaves
the polled sources in place rather than surfacing an error. The status line is
the user's own configuration and Claude Code owns the payload schema.
Observations are matched to the reporting profile by CLAUDE_CONFIG_DIR and
bounded to 15 minutes, so one account's numbers cannot render under another's
card and a stale live value cannot outrank a fresh poll. The snapshot asserts
no identity or plan, and the card labels the numbers as coming from the user's
own statusLine config.
* Document the statusLine feed and its drop-file contract
Describes the envelope, a minimal shim, and the profile/freshness rules, so the
feed is usable by hand while the managed-install question is open.
* Make the statusLine feed toggle actually reachable
The opt-in flag was read by the planner but nothing ever populated it: there
was no SettingsStore property, no defaults key, and no UI control, so it was
false in every build and the feed could not be switched on at all.
Wires it end to end — stored default (off), settings snapshot, menu
observation, and a Claude provider toggle — and adds a test that asserts the
user-facing switch reaches the snapshot field the planner reads.
The existing planner tests could not catch this: they construct
ClaudeSourcePlanningInput directly, so they pass whether or not anything
carries the user's choice into it. Removing the snapshot line again fails the
new test with the exact symptom that shipped.
* Require a capture time on statusLine observations
The parser defaulted a missing capturedAt to the parse time, so a drop file
that had sat on disk for hours read as current and the staleness bound stopped
protecting anything — a dead session could outrank a live poll indefinitely.
An observation that cannot be aged is now absence. The previous test asserted
the fallback as intended behaviour, which is why the suite stayed green; it now
asserts the drop instead.
* Cap how far ahead a statusLine capture time may sit
Future timestamps were accepted without bound to tolerate clock skew, so an
observation dated arbitrarily far ahead stayed fresh forever — the same defect
as a missing capture time, in the opposite direction. Skew is now tolerated up
to five minutes and rejected beyond it.
The previous test asserted the unbounded behaviour as intended, so the suite
stayed green; it now covers both the tolerated and the rejected case.
* Compose the statusLine feed over the last poll instead of replacing it
Addresses both P1 findings on the draft, now that #2675 has landed.
The feed carries only the 5h/7d windows. Publishing its result whole blanked
identity, plan, model-scoped weekly, Daily Routines, extra usage and cost —
the opposite of the "composes with, never replaces" constraint in the owner
ruling. Its windows are now merged over the last polled Claude snapshot, and a
window the observation omits means "no update" rather than "cleared".
Composition also carries the account guard the feed cannot supply itself.
Matching CLAUDE_CONFIG_DIR cannot distinguish an account switch within one
profile, so an observation is discarded outright when the active account has
changed since the snapshot it would compose over. Publishing it there would
render one account's windows beneath another account's identity.
Follows the existing shape of this apply path, which already reconciles
results against previous state for Codex, CommandCode, DeepSeek and reset
backfill. The helper lives in its own file and the call site replaces an
existing binding, so the refresh function stays within its length budget.
The card note keeps precedence over the dataConfidence note added by #2675: a
composed snapshot inherits its confidence from the previous poll, so a prior
CLI scrape would otherwise label live statusLine windows as CLI-sourced.
* Address the three Codex findings on the statusLine feed
Persist the opt-in toggle. The setter only updated the in-memory defaults
state, so the feed silently switched itself off on the next launch. It now
writes the key and notifies the background-work path, matching the adjacent
provider toggles.
Stop promoting a weekly-only observation into the session lane. This snapshot
is composed over a previous one where primary is the session row, so a
promoted 7-day figure rendered as the 5-hour limit while the real weekly row
survived beside it. A weekly-only payload is now absence rather than a
lane-shifted guess.
Verify ownership of the rows being composed over. The active-account
observation only proves the account held still during a fetch; if the user
switches accounts and the next refresh is served by the statusLine file,
nothing in that fetch re-read the account, so stability alone would let the
new account's windows sit beneath the old account's identity. The account
behind each polled snapshot is now recorded and must still be active for the
feed to compose over it, and a snapshot the feed itself produced never becomes
that evidence.
* Keep the statusLine opt-in through launch
The launch reset that clears Claude web extras outside CLI mode was also clearing
the statusLine feed. The planner emits the feed's step only under `.auto`, which is
exactly the branch that reset covers, so an enabled user lost the opt-in on every
launch and the feature was unreachable after a restart.
The reset is CLI-scoped by design; the statusLine line never belonged in it.
No test caught this because the reset lives in the non-test branch of an
`isRunningTests` gate, so the suite never executed it. Adding
`writesLaunchResetsToRawState` — mirroring the existing
`performInitialProviderDetection` seam — lets a test take the production path.
Verified by reintroducing the defect and watching the new test fail on both
assertions before it passed.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Restore the provider architecture gatekeeper on this branch
`cross provider case clusters are derived or specifically justified` passes on
main and failed on this branch. The allowlist pins each guarded construct to an
exact line with a text anchor, and earlier commits here inserted lines into
UsageStore+Refresh.swift, UsageStore.swift and MenuCardView+ModelHelpers.swift,
so 44 entries drifted off their anchors and every orphaned entry then cascaded
into an unjustified-construct failure.
- Recompute the 44 drifted line numbers against their anchors.
- Justify the two Claude constructs in the composition file, which were added
with no marker at all. The first reads better hoisted into a named local than
as a comment buried in an argument list.
- Update the MenuCardView cluster fingerprint: the statusLine note sits between
the .kiro and .kilo checks, so the gatekeeper now sees one three-provider
cluster where the entry expected two. The maintainer's reason text still
describes it accurately and is left alone.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Keep the Claude chain moving when a feed observation cannot be attributed
Composition returned nil when a statusLine observation could not be attributed to
the stored rows. By then the fetch pipeline had already accepted the statusLine
result, so nothing fell through to the CLI probe: the refresh published nothing
and the card kept whatever it was showing.
Three things combined to make that permanent rather than transient:
- Feed-stored snapshots recorded no owner at all, so the first feed-only publish
created rows that no later feed refresh could ever attribute. The account UUID
is read from the environment, not from the observation, so recording it for
feed snapshots is evidence about when the rows were stored — exactly what the
next composition needs to ask about.
- The record lived only in memory while the snapshots it describes are persisted,
so every relaunch began with an unknown owner against restored rows.
- Rejection was a decision about whether to publish rather than about which rows
to trust.
Ownership is now three-state. "Cannot tell" is not "belongs to someone else":
only the latter justifies discarding rows the user can currently see, so an
unreadable account republishes the previous snapshot rather than blanking
identity, plan and extra rows on a guess.
This does not gate the step at plan time as the review suggested, which would
mean plumbing composability from UsageStore through the settings snapshot into
the Core planner. The stall it protects against no longer exists.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Make statusLine ownership a condition of the source, not a decision after it
An unowned observation was being resolved after the fetch had already committed
to it, where every remaining option was wrong: publish rows that cannot be
attributed, publish nothing and stall the chain, or blank verified rows on a
guess. Ownership is now part of whether the step is offered at all. When the
stored rows are not provably owned by the active account the source is not
planned, OAuth -> CLI -> web runs as it did before the feed existed, and a poll
that carries its own identity re-establishes ownership on its own.
Two findings this closes:
- A feed observation no longer records who owns the rows it produced. The account
UUID is read from the environment, so it is evidence about when the rows were
stored, not about whose usage they count. The drop file is scoped to the
profile rather than the account and its freshness window is minutes wide, so a
file written by the previous account's session was being stamped as the new
account's and composed beneath its identity on the next refresh.
- Composition reports whether the published rows came from the fetched result,
and the source label only moves when they did. A discarded observation
republishes the previous rows, and claiming its label made the card attribute
an old OAuth or CLI reading to the user's status line.
Worth recording for whoever owns this next: the payload carries no account
identity of any kind, and its drop file is shared by every account on a profile.
The feed cannot attribute itself. It can only ever supplement rows whose owner is
already established, which is what the planning gate now enforces structurally.
Co-Authored-By: Claude Opus 5 <[email protected]>
* feat: add Keychain-free Claude statusLine feed
Co-authored-by: Luis Gonzalez <[email protected]>
* test: stabilize subprocess timing under load
* fix: import CoreFoundation for Linux statusLine build
* test: register statusLine localization fallbacks
* style: wrap statusLine localization fallback
---------
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>1 parent c8822a8 commit 09d2d01
58 files changed
Lines changed: 1980 additions & 34 deletions
File tree
- Sources
- CodexBarCLI
- CodexBarCore/Providers/Claude
- CodexBar
- Providers/Claude
- Resources
- ar.lproj
- ca.lproj
- de.lproj
- en.lproj
- es.lproj
- fa.lproj
- fr.lproj
- gl.lproj
- id.lproj
- it.lproj
- ja.lproj
- ko.lproj
- nl.lproj
- pl.lproj
- pt-BR.lproj
- ru.lproj
- sv.lproj
- th.lproj
- tr.lproj
- uk.lproj
- vi.lproj
- zh-Hans.lproj
- zh-Hant.lproj
- Tests/CodexBarTests
- docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
255 | 268 | | |
256 | 269 | | |
257 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| |||
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
180 | 298 | | |
181 | 299 | | |
182 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| |||
174 | 186 | | |
175 | 187 | | |
176 | 188 | | |
177 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
178 | 192 | | |
179 | 193 | | |
180 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1464 | 1464 | | |
1465 | 1465 | | |
1466 | 1466 | | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1463 | 1463 | | |
1464 | 1464 | | |
1465 | 1465 | | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1461 | 1461 | | |
1462 | 1462 | | |
1463 | 1463 | | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
0 commit comments