Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c932edbee2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let primaryPercent = recurringTotal > 0 | ||
| ? min(100, max(0, recurringUsed / recurringTotal * 100)) | ||
| : 0.0 |
There was a problem hiding this comment.
Mark zero recurring credits as fully used
When recurringTotal is 0, this branch sets primaryPercent to 0.0, which renders the recurring bar as full even though there are no recurring credits available. This affects free/expired accounts (or any response without recurring grants) and contradicts the empty-pool handling used for promo/purchased bars, so the UI reports the recurring pool in the opposite state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — this was fixed in a subsequent commit. The original code did set primaryPercent to 0.0 for zero recurring credits. It now correctly uses 100.0, matching the empty-pool treatment for promo/purchased bars. Test toUsageSnapshotZeroRecurringBarIsFullyDepleted covers this.
| let raw = environment["PERPLEXITY_SESSION_TOKEN"] | ||
| ?? environment["perplexity_session_token"] | ||
| ?? environment["PERPLEXITY_COOKIE"] | ||
| return self.cleaned(raw) |
There was a problem hiding this comment.
Parse PERPLEXITY_COOKIE as cookie header
This reader accepts PERPLEXITY_COOKIE but returns it verbatim as a session token; if users provide a full cookie header (which the variable name strongly implies), the fetcher later wraps it again as __Secure-next-auth.session-token=<value>, producing a malformed Cookie header and authentication failures. PERPLEXITY_COOKIE should be normalized through the same token-extraction path used for manual cookie input.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — this was fixed in a subsequent commit. The original code did return PERPLEXITY_COOKIE verbatim via nil-coalescing. It now handles it separately, piping through PerplexityCookieHeader.override(from:)?.token to extract just the bare session token before returning it.
fabc673 to
56d03e5
Compare
|
When are you going to merge this one @BeelixGit Keen to use it. |
Tracks usage-based API credits from Perplexity Pro/Max plans via the /rest/billing/credits endpoint using a browser session cookie. - Three-tier display: recurring credits (monthly), bonus credits (promotional grants), and purchased on-demand credits - Infers plan name (Free/Pro/Max) from recurring credit pool size - Cookie auth: auto browser import from Chrome/Chromium, manual paste, or PERPLEXITY_SESSION_TOKEN / PERPLEXITY_COOKIE env var fallback - Waterfall attribution: recurring → purchased → promotional - Empty credit pools render as depleted bars, not full ones - Login flow opens perplexity.ai/signin with the standard key icon - 10 unit tests covering parsing, waterfall logic, plan inference, empty-pool rendering, and UsageSnapshot conversion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…warning - Cache Perplexity session cookies via CookieHeaderCache (matching Claude/Cursor pattern): try cache before browser import, cache on success, clear + retry on 401/403, preserve cache on transient errors - Fix PerplexityCreditGrant.expiresAtTs to be optional — the API returns null for purchased grants, causing parse failures - Remove deprecated kSecUseAuthenticationUIFail (macOS 14+ only needs LAContext.interactionNotAllowed) - Add debug logging for parse failures (raw response preview) - Add 6 tests for cookie cache behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Perplexity now sends purchased credits as a credit_grant with type="purchased" instead of (or in addition to) the top-level current_period_purchased_cents field. Take the larger of the two sources to avoid double-counting while catching either path. Without this fix, 40k purchased credits were invisible to the waterfall calculation, causing bonus credits to show 100% used when they still had ~42% remaining.
f131b52 to
0e218b9
Compare
|
Just rebased onto latest |
|
Hey @warrendt — thanks for the interest! I'm the PR author but I don't have merge access — that's up to the repo maintainers. I'm pretty new to open source and still figuring out how all of this works honestly (been leaning on Claude Code for most of it). Just rebased the branch so it's conflict-free and ready to go on their end. Hopefully it gets picked up soon! |
|
I have had Claude Code do near everything on this insofar as even checking and replying to the comments here so If I am doing anything the wrong way or should do differently please just let me know |
Sweet, I guess we just wait for @steipete to do the merge then since it passed all the checks. I have built and run your version and it works great. |
|
Opened a superseding PR here: #606 Thanks again @BeelixGit for the original Perplexity provider work and all the follow-up fixes. |
Worked with Claude Code to add Perplexity Max usage tracking to CodexBar. Seems to work for me but I am sure there are things I missed.
What this adds
/rest/billing/creditsusing a browser session cookie (auto-imported from Chrome/Chromium on macOS, or set manually via cookie header /PERPLEXITY_SESSION_TOKENenv var)UsageSnapshotconversionTest plan
bash Scripts/compile_and_run.shswift test --filter PerplexityUsageFetcherTests🤖 Generated with Claude Code