Repository navigation
Credit-tracking follow-ups: phone Settings, expired session key, stale strip, live credit shapes - #9
Conversation
…ey, stale strip) - Settings: the page container was an auto-margin flex item without w-full, so it sized to its content's min-width (408px at a 375px viewport). Add w-full like the other pages; let the font-size row wrap and the preview path break. - Claude: when the credit endpoints reject the saved claude.ai session key (401/403 with nothing getting through), flag sessionKeyExpired on the usage data and skip those endpoints for 15 minutes, keyed by the session key so a newly saved key retries at once. The Claude card and Settings connection status show a "session key expired, prepaid balance unavailable" hint. - Monitor strip: drop a provider's row once it reports MISSING_CREDENTIALS instead of showing the stale SWR data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checked against live responses with a saved session key (shapes only): - Units: prepaid `amount` and spend-limit `monthly_credit_limit` equal the `amount_minor` of their balance/cap objects with exponent 2, so cents is right. Honor `extra_usage.decimal_places` and the balance/cap exponent when present instead of hard-coding /100. - overage_spend_limit reports out_of_credits=true while extra usage is switched off (disabled_reason self_selected_spend_limit_reached, nothing used), which showed a false "Out of credits" pill. Only flag it while extra usage is enabled, preferring extra_usage.spend_limit_reached. - An empty ($0) prepaid balance no longer shadows extra-usage headroom in the Monitor strip summary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24878060df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const sessionKeyExpired = | ||
| results.some((r) => r.authRejected) && results.every((r) => r.data == null); |
There was a problem hiding this comment.
Avoid treating mixed endpoint failures as expired credentials
When a valid session key gets a permission-related 403 from one credit endpoint while the other endpoint is unavailable with a 404, timeout, or malformed response, both data values are null and this marks the key expired. That is precisely the kind of endpoint-specific 403 the preceding comment recognizes, but the lack of a successful sibling response turns it into a false warning and suppresses both credit requests for 15 minutes. Require stronger authentication evidence, such as both endpoints rejecting authentication or validation through a session-wide endpoint, before setting sessionKeyExpired.
Useful? React with 👍 / 👎.
Stacked on #6. Review and merge that first; this PR then retargets to
main.Four items that were parked during the add-on credit work.
1. Settings overflowed at 375px
The page was 408px wide on a 375px viewport. The page container (
mx-auto max-w-3xl) is an auto-margin item in the layout's flex column. Withoutw-fullit took its content's min-width: first the Font Size row, then the Hub URL row. It now hasw-full, the same as the other pages. The font-size row also wraps now, and the preview path breaks anywhere. Checked in the browser: scrollWidth 375/375.2. Expired claude.ai session key while OAuth still works
ClaudeUsageData.sessionKeyExpiredis set when a credit endpoint returns 401/403 and none of them succeeds. A lone 403 next to a 200 is more likely an endpoint this org can't use.ProviderHealthEntry.warning, amber dot) show: "claude.ai session key expired: prepaid balance unavailable. Update it in Settings."3. Monitor strip showed stale numbers after credentials were deleted
dataUnlessUnconfigured()(src/lib/usage/stale-data.ts) drops a provider's row onMISSING_CREDENTIALS, the same way the dashboard cards switch to their setup placeholder. Other errors still keep the last data.4. Live claude.ai credit shapes
I probed
/usage,/prepaid/creditsand/overage_spend_limitwith a saved session key. Only shapes, enums and equality checks were printed, never values or the key.amountequalsbalance.credits.amount_minor, and spend-limitmonthly_credit_limitequalscap.credits.amount_minor; both haveexponent: 2. Currency is an ISO code (USD). The parser now usesextra_usage.decimal_placesor the balance/cap exponent when present, and falls back to /100.overage_spend_limit.out_of_creditswastruewhile extra usage was switched off (disabled_reason: self_selected_spend_limit_reached, nothing used this period). The card would have shown a red pill next to "Extra usage is off". It's now only flagged while extra usage is enabled, andextra_usage.spend_limit_reached(a new field) takes precedence.Verification
npm test: 317 passed (new client, health route, parser, credit-summary and stale-data tests)npm run test:edge: 84 passednpx tsc --noEmit,npm run lint,next build: cleanThe session-key hint (item 2) is covered by unit tests but wasn't seen in a browser. The saved key is still valid, so the expired state couldn't be reproduced live.
🤖 Generated with Claude Code