Skip to content

Show Grok usage-limit reset coupons - #3188

Open
Leshabeats wants to merge 6 commits into
steipete:mainfrom
Leshabeats:grok-remaining-resets-coupon
Open

Show Grok usage-limit reset coupons#3188
Leshabeats wants to merge 6 commits into
steipete:mainfrom
Leshabeats:grok-remaining-resets-coupon

Conversation

@Leshabeats

Copy link
Copy Markdown

Summary

  • keep Grok weekly credits on the CLI-proxy path
  • fetch unused SuperGrok usage-limit reset tokens from grok.com's remaining-resets RPC
  • render them as a Limit Reset Credits detail row, and leave weekly usage intact if that extra call times out or returns nothing

Tests

  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter GrokRemainingResetsFetcherTests
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter GrokMenuCardModelTests
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter GrokCreditsProxyFetcherTests
  • swiftlint lint --strict on the Grok remaining-resets files

Why this was missing

/v1/billing?format=credits reports weekly SuperGrok usage only. grok.com's Использование panel reads unused reset coupons from a separate RPC:

POST https://grok.com/prod_mc_billing.ConsumerUiSvc/GetRemainingResets

That payload includes token_id and validity_end. CodexBar never called it, so an unused coupon such as Доступен сброс / Истекает 12 сент. stayed invisible even when weekly usage was 29%.

CodexBar does not redeem or modify reset tokens.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 11:25 AM ET / 15:25 UTC.

ClawSweeper review

What this changes

This PR fetches unused Grok reset coupons through a best-effort authenticated RPC and shows their count and expiry beside the existing weekly usage.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review. Current main does not contain this capability, and the current head resolves the prior refresh, CLI-completeness, expired-display, and fleet-persistence concerns without a new blocking defect found.

Priority: P2
Reviewed head: a5b8a152a5defae78b0cb691a8fd0ab6ff983031

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is well-covered and resolves the earlier concrete review findings, with direct real-app UI proof.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The PR discussion provides a redacted packaged-app screenshot from a real Grok account showing the reset-credit row and expiry after the change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The PR discussion provides a redacted packaged-app screenshot from a real Grok account showing the reset-credit row and expiry after the change.
Evidence reviewed 5 items Primary and optional paths stay separate: The Grok strategies publish weekly usage first and only attach reset coupons through an optional lookup; completeness-required callers await the lookup while app refreshes receive a supplemental task.
Credential and cookie routing coverage: Focused tests cover reuse of the billing-winning cookie, optional-usage suppression, and synchronous completion for both web and CLI paths.
Live-only data boundary: The reset inventory is excluded from Codable keys; decode also removes the legacy detail row, preventing a synced fleet snapshot from reviving expired or redeemed coupons.
Findings None None.
Security None None.

How this fits together

CodexBar obtains a primary Grok usage snapshot from CLI, OAuth, or browser-session routes, then renders it in menu and overview cards. The new supplemental lookup uses the winning account credential or cookie and adds only a live reset-credit inventory to that display.

flowchart LR
A[Selected Grok account] --> B[Primary weekly usage fetch]
B --> C[Primary usage snapshot]
B --> D[Optional reset-coupon lookup]
D --> E[Live sanitized coupon inventory]
C --> F[Menu and overview cards]
E --> F
E --> G[Fleet-sync filtering]
Loading

Before merge

  • Resolve merge risk (P1) - The undocumented Grok RPC may change its response or authentication contract; the implementation fails soft, but reset-credit details can disappear until the provider path is updated.
  • Complete next step (P2) - No discrete repair remains for automation; this is ready for ordinary maintainer merge review with the provider-contract risk visible.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and coverage production +976/-90, tests +1,224/-26, docs +13 across 28 files The feature introduces a new provider transport and refresh path with substantial focused parser, routing, display, and persistence coverage.

Merge-risk options

Maintainer options:

  1. Accept the bounded provider dependency (recommended)
    Merge with the documented expectation that the optional reset row may fail soft if Grok changes this authenticated RPC.

Technical review

Best possible solution:

Retain the winning-credential, live-only, fail-soft design and merge after accepting the bounded dependency on Grok’s undocumented reset endpoint.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR adds a provider-display capability; the supplied redacted packaged-app screenshot directly shows the resulting coupon row.

Is this the best way to solve the issue?

Yes. Reusing the primary snapshot’s credential or winning cookie, publishing weekly usage independently, and retaining only expiry data in live state is the narrowest maintainable approach found.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cf79d1310493.

Labels

Label justifications:

  • P2: This is a bounded enhancement to optional provider-usage details rather than a core-runtime regression.
  • merge-risk: 🚨 auth-provider: The branch adds an authenticated Grok request that must remain aligned with the credential or cookie that produced the primary usage snapshot.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The PR discussion provides a redacted packaged-app screenshot from a real Grok account showing the reset-credit row and expiry after the change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR discussion provides a redacted packaged-app screenshot from a real Grok account showing the reset-credit row and expiry after the change.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR discussion provides a redacted packaged-app screenshot from a real Grok account showing the reset-credit row and expiry after the change.

Evidence

What I checked:

Likely related people:

  • steipete: Has the most history on the Grok descriptor and authored the established weekly-credit behavior. (role: feature-history owner; confidence: high; commits: 2fa8bae27a76; files: Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift, Sources/CodexBar/UsageStore+TokenAccounts.swift)
  • o.akimov: Recent Grok work specifically covers explicit source selection and selected bearer routing, which this supplemental lookup must preserve. (role: recent authentication-routing contributor; confidence: high; commits: 6982cfa00d10; files: Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift)
  • Alec Gutman, Chip: Introduced recent Grok usage and spend publication work adjacent to the menu-data surface. (role: adjacent Grok usage contributor; confidence: medium; commits: 3bfbffdcea58; files: Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Maintain the documented same-account credential/cookie routing if the Grok provider contract evolves.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-25T09:48:07.005Z sha dd39a4a :: needs real behavior proof before merge. :: [P2] Do not gate weekly usage on the coupon lookup
  • reviewed 2026-08-25T17:33:51.210Z sha 4583904 :: needs changes before merge. :: [P2] Retain cached coupons on non-200 responses | [P2] Remove cached detail rows after confirmed empty results | [P2] Share the in-flight lookup with replacement refreshes | [P2] Schedule supplemental updates for all token accounts
  • reviewed 2026-08-26T09:03:14.372Z sha 2f4ddc4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T10:40:29.904Z sha c094bb7 :: needs changes before merge. :: [P2] Honor CLI optional-usage completeness | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-26T12:50:39.041Z sha 93d631e :: needs maintainer review before merge. :: none

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd39a4ac1d

ℹ️ 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".

Comment thread Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift Outdated
Comment thread Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift Outdated
Comment thread Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift Outdated
Comment thread Sources/CodexBarCore/Providers/Grok/GrokRemainingResetsFetcher.swift Outdated
@Leshabeats
Leshabeats force-pushed the grok-remaining-resets-coupon branch from dd39a4a to 4583904 Compare August 25, 2026 16:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4583904361

ℹ️ 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".

Comment thread Sources/CodexBar/UsageStore+SupplementalUsage.swift Outdated
Comment thread Sources/CodexBar/UsageStore+TokenAccounts.swift
Comment thread Sources/CodexBarCore/Providers/Grok/GrokRemainingResetsFetcher.swift Outdated
@Leshabeats

Copy link
Copy Markdown
Author

Addressed the review feedback in 45839043:

  • rebased onto current main; the PR now merges cleanly
  • decoupled GetRemainingResets from primary weekly usage publication; the coupon arrives as a stale-safe supplemental update
  • reused the exact credential/cookie that produced the usage snapshot, avoiding cross-account enrichment
  • gated both fetch and display on optional usage
  • rendered Grok through the same localized reset-credit block used by Codex

Live proof from the packaged debug app against a real Grok account (account data and tokens redacted):

Grok limit reset credit shown in CodexBar

The weekly card remains available immediately; the reset-credit block then shows 1 доступен with its expiry.

Validation: 47 affected tests across 7 suites pass, make check passes, and ./Scripts/package_app.sh debug builds successfully.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 25, 2026
Weekly CLI-proxy credits omit SuperGrok reset tokens, so CodexBar never
rendered an unused coupon even when grok.com listed one. Fetch remaining
resets as a best-effort overlay and keep weekly usage if that call fails.
@Leshabeats
Leshabeats force-pushed the grok-remaining-resets-coupon branch from 4583904 to 2f4ddc4 Compare August 26, 2026 08:59
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f4ddc468a

ℹ️ 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".

Comment thread Sources/CodexBar/MenuCardView+CodexResetCredits.swift

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c094bb7b93

ℹ️ 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".

Comment thread Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift Outdated
Comment thread Sources/CodexBarCore/Providers/Grok/GrokRemainingResetsFetcher.swift Outdated
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93d631e64b

ℹ️ 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".

Comment thread Sources/CodexBar/MenuCardView+CodexResetCredits.swift

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3188cc675

ℹ️ 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".

Comment thread Sources/CodexBar/MenuCardView+CodexResetCredits.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant