feat: add Grok web usage gauge and cross-tier plan merge#34
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ee3edefd1
ℹ️ 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".
| if config.providers.web_enabled { | ||
| providers.push(Box::new(FailClosedWebProvider { | ||
| service: Service::Grok, | ||
| })); |
There was a problem hiding this comment.
Keep Grok sidecar refresh from being backoff-blocked
With both cliEnabled and webEnabled (the default path for merging Grok's CLI plan with web usage), this registers a fail-closed grok.web provider that runs inside engine.refresh_all(). In the Refresh now flow I checked (src-tauri/src/lib.rs::refresh_all_with_headless_web), engine.refresh_all() runs before the Grok headless sidecar refresh; this placeholder returns LoginRequired, records a 30s backoff for grok.web, and the immediate refresh_web_provider_headless(..., Service::Grok) is skipped by try_begin_refresh, so the new Grok web gauge is not fetched on refresh-now and manual official refreshes are temporarily blocked. Register the placeholder only where it will not immediately precede the sidecar refresh, or avoid backoff for this placeholder failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 30745d6 (pushed while this round was in flight): placeholder web providers no longer create or honor backoff — is_placeholder flows through the descriptor, refresh_all skips record_provider_failure for them, and regression tests cover grok, ollama, and the real-failure-still-backs-off case.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ee3edefd1
ℹ️ 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".
| if config.providers.web_enabled { | ||
| providers.push(Box::new(FailClosedWebProvider { | ||
| service: Service::Grok, | ||
| })); |
There was a problem hiding this comment.
Do not back off Grok web before the headless refresh
When Grok web is enabled alongside the default CLI provider, registering this fail-closed grok.web provider means engine.refresh_all() refreshes it before the real headless refresh in refresh_all_with_headless_web. That synthetic provider always returns LoginRequired, which records a failure/backoff for the same grok.web key; the immediately following refresh_web_provider_headless(..., Service::Grok) then exits in try_begin_refresh while the backoff is active. In this common config, the main Refresh Now path never reads the managed Grok profile/credits endpoint and the card remains plan-only until a later due refresh/direct retry after backoff.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same finding as above — already fixed in 30745d6 (this round reviewed the pre-fix commit 7ee3edef). Re-requesting review on the current head.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
30745d6 to
bc561db
Compare
Adds the cookie-gated
grok.webprovider: PickGauge reads Grok's real weekly usage (the shared "Weekly SuperGrok Limit") fromGET grok.com/rest/grok/creditsusing the opt-in managed browser profile, and gives Grok a distinct tray/float accent. Ollama's existing web scrape is untouched; both services' web rows now inherit the plan detail from their zero-setup sibling.Refs #26 (PR 3 of the 4-PR plan; PR 4 = headless
usage --json+ skill remains).Endpoint provenance: discovered from grok.com's own JS bundles (proto descriptors for
grok_api_v2.GetGrokCreditsConfigembed thegoogle.api.httpannotation/rest/grok/credits); response shape is the proto3-JSON ofGrokCreditsConfig(creditUsagePercent,productUsage[]{product, usagePercent},currentPeriod.billingPeriodEnd). Verified live that the route exists and is cookie-session-gated (CLI bearer → Connect NOT_FOUND; same bearer works on/rest/subscriptions).What changed
grok.com/for browser passes,/rest/grok/creditsfor the cookie HTTP fast path); credits JSON parsed inside the sidecar; sanitizedproductsarray added to the response contract; absentcreditUsagePercent= 0 used; HTML body/401/403 →logged_out; missingconfig→unexpected_ui. Cookies and raw bodies never leave the sidecar.UsageProviderId::GrokWeb(grok.web), fail-closed registration + headless override (the ollama pattern), grok managed browser profile (grokPath), login flow, weekly-only window (no 5h slot anywhere).plan/billingPeriodEndfrom siblings — grok.web keeps grok.cli's plan, ollama.web keeps ollama.local's plan.[156,163,175]neutral gray, floatvar(--muted)(was Claude's ember — flagged in feat: add Grok zero-setup usage provider (grok.cli) #28).Tested
cargo test --locked --all-targets: 261 passed, 1 ignored.bun run checkclean;bun run test: 66 Vitest + 21 sidecar Node tests (new grok cases: happy path, absent-percent, missing-config, HTML body, 401/403).Not tested yet
logged_out/unexpected_ui, never wrong numbers.Risks
rest/grok/creditsis an undocumented surface; shape drift → honestunexpected_ui.