fix(bar): stop false re-auth on non-default native subscription profiles

Fixes the two collector-side root causes of #1601:

1. Claude per-profile credential reads were file-only, but on macOS Claude
   Code stores the OAuth token for an isolated CLAUDE_CONFIG_DIR in a
   per-directory Keychain item ("Claude Code-credentials-<sha256(dir)[0..8]>").
   The .credentials.json file never exists, so every isolated profile was
   parked with needsReauth:true forever. The reader now falls back to that
   Keychain item (file-first, same security-CLI read the shipped global
   fallback already performs; TTL-gated so it is not on every /summary).

2. Non-default profiles were cache-only forever, so they could never leave
   the parked state even with valid credentials. getNativeAccountRows now
   gives each surface ONE rotating live slot: the stalest eligible
   non-default profile is refreshed per pass, skipping profiles inside
   breaker/reauth cooldowns. Every account converges to real quota within a
   few polls while the per-pass upstream budget stays constant (<= 2 calls
   per surface regardless of profile count). Codex named profiles with valid
   auth but sparse payloads now yield an active quota-less row instead of a
   false needsReauth row.

Non-default rows keep paused:true (dimmed) even when freshly refreshed so
only the default renders active and rows do not flicker between polls.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
poomscandClaude Fable 5 committed 2026-08-08 14:18:00 +07:00
1 parent 7fb56d62e1
commit a5a5b742e4
6 files changed
+401 -67

No files matched your search

+3 -3
View File
@@ -1,9 +1,9 @@
{
"scope": "src/**/*.{ts,tsx,js,jsx,mjs,cjs}",
"syncFs": {
"totalOccurrences": 2427,
"totalOccurrences": 2426,
"filesAffected": 258,
"hotpathOccurrences": 1142,
"hotpathOccurrences": 1141,
"hotpathFilesAffected": 152,
"topHotpathFiles": [
{
@@ -725,7 +725,7 @@
"topOver400": [
{
"file": "src/web-server/usage/native-quota-collector.ts",
"loc": 1662
"loc": 1730
},
{
"file": "src/web-server/routes/cliproxy-auth-routes.ts",
+3 -3
View File
@@ -6,9 +6,9 @@ Scope: `src/**/*.{ts,tsx,js,jsx,mjs,cjs}`
| Metric | Value |
|---|---:|
| Sync fs occurrences (all) | 2427 |
| Sync fs occurrences (all) | 2426 |
| Sync fs files affected (all) | 258 |
| Sync fs occurrences (runtime hotpaths) | 1142 |
| Sync fs occurrences (runtime hotpaths) | 1141 |
| Sync fs files affected (runtime hotpaths) | 152 |
| Legacy shim markers | 458 |
| Legacy shim files affected | 173 |
@@ -89,7 +89,7 @@ Scope: `src/**/*.{ts,tsx,js,jsx,mjs,cjs}`
| File | LOC |
|---|---:|
| `src/web-server/usage/native-quota-collector.ts` | 1662 |
| `src/web-server/usage/native-quota-collector.ts` | 1730 |
| `src/web-server/routes/cliproxy-auth-routes.ts` | 1531 |
| `src/cliproxy/auth/oauth-handler.ts` | 1510 |
| `src/cursor/cursor-executor.ts` | 1234 |