Permanent Claude 0/0 fix: Firefox cookies + honest fallback + /health#33
Merged
Conversation
The recurring 0/0 came from a chain of single points of failure: the AppleScript-Chrome scrape depended on Chrome's "Allow JavaScript from Apple Events" preference (which Chrome can silently disable on update), and when the scrape inevitably broke the daemon dropped to a token-count fallback that reported 0% any time the user exceeded the hardcoded 200k/1M budget. The user couldn't tell daemon-down from limit-hit. This commit removes both failure modes: - New scripts/claude-plan-usage-firefox.py reads sessionKey from Firefox's unencrypted cookies.sqlite and calls claude.ai/api/.../usage directly. No AppleScript, no DOM scrape, immune to page-layout changes and the Chrome preference. Writes a health side-file so /health can surface the last scrape outcome. - install.sh and the running LaunchAgent now point at the Firefox script as primary. The old Chrome AppleScript script stays in the repo as a manual fallback. - Daemon's Claude fallback is now honest: when every fresh source fails, it returns the last cached plan-usage percentages with ok=False and status "stale Nh" instead of the misleading token-budget 0/0. The token-count path is no longer reachable for the Claude provider. - New /health endpoint exposes per-source freshness, last scrape result, and the snapshot the daemon is currently serving — one curl tells you what's wrong. - CLAUDE.md is the new project memory / runbook: documents every failure mode we've already debugged with the exact /health output and commands to fix each. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Three rounds of "0/0 on the iPhone" all traced to the same architecture:
the AppleScript-Chrome scrape was a single point of failure (Chrome can
silently disable "Allow JavaScript from Apple Events" on update), and
when it broke the daemon fell through to a token-count fallback that
reported 0% any time you exceeded the hardcoded 200k/1M budget. The user
couldn't tell "daemon down" from "limit hit."
This PR is the permanent fix.
What changed
scripts/claude-plan-usage-firefox.py— readssessionKeyfromFirefox's unencrypted
cookies.sqliteand callshttps://claude.ai/api/organizations/{org}/usagedirectly. NoAppleScript, no DOM scrape; immune to page-layout changes and the
Chrome preference. Writes a health side-file so
/healthcan surfacethe last scrape outcome. Setup is one-time:
./scripts/claude-plan-usage-firefox.py login.install.shswitched to the Firefox script as primary.The Chrome AppleScript script stays for manual fallback only.
the last cached
claude-plan-usage.jsonpercentages withok=Falseand status
"stale Nh"instead of the misleading token-budget 0/0.The token-count path is no longer reachable for the Claude provider.
/healthendpoint exposes per-source freshness, last scrape result,and the snapshot the daemon is currently serving.
CLAUDE.mdis the new project runbook: documents every failuremode I've debugged in this thread (Firefox session expired, daemon
running stale code after pull, LaunchAgent dead, claude.ai page change,
Chrome preference disabled, mDNS name collision) with the exact
/healthsignature and the commands to fix each.Verified live
Test plan
ruff check daemon/ scripts/cleanpytest -q(11 passed)/usageserves real percentages from Firefox-cookie scrape/healthreportssources.plan_usage.fresh: trueand current snapshotok: trueok: falseandstatus: "stale Xh"instead of 0/0🤖 Generated with Claude Code