Skip to content

feat(mobile): show Grok usage on the home and Accounts screens - #23247

Closed
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/mobile-grok-account-usage
Closed

innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/mobile-grok-account-usage

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

ELI5

The iOS home screen and Accounts screen already show how much Claude and Codex usage is left. Grok was missing there even when the Mac app's status bar showed a signed-in Grok meter. This adds that Grok meter.

What Changed

Before: The phone's Account usage card and Accounts screen list Claude and Codex only. A signed-in Grok CLI session on the paired desktop is invisible.

After: When the desktop has a Grok CLI session or a usable Grok meter, the home card shows one Grok row and the Accounts screen shows a read-only Grok section. Weekly credit plans use the 7d bar. Unified-billing plans that only have a monthly included budget use the 30d bar, with the same reset countdown the other account rows use. The label is the desktop account provenance (email and tier) when the host sends it, otherwise "Signed in". Hosts that are not signed in to Grok and have no meter stay unchanged.

Mechanism: accounts.list / accounts.subscribe already return rateLimits.getState(), which includes grok and grokAuthConfigured. The phone was keeping those fields through the snapshot's passthrough and never rendering them. Grok is decoded on its own, so a malformed Grok payload cannot blank Claude or Codex. There is no new RPC and no account switch: Grok is one CLI session on the computer running Orca.

Why

The home card is the surface people see without opening Accounts. Showing every other desktop provider here would also pull in Antigravity, whose status-bar slot is still a Gemini mirror, and Cursor, which is a separate schema gap. Those stay out of this change. #22626 proposes the wider Accounts-screen set and leaves the home card for later.

Focused fix

  • In scope: read-only Grok usage on the mobile home Account usage card and the Accounts screen.
  • Out of scope (explicit): Gemini, Kimi, MiniMax, OpenCode Go, Antigravity, and Cursor; Grok login or account switching on the phone; status-bar visibility toggles; changes to the desktop fetcher.

Preserves

  • Claude and Codex rows, account switching, and reset-credit actions are unchanged.
  • A host with no Grok CLI session and no usable Grok meter does not gain an empty Grok row.
  • Older desktops that omit grok still decode. A bad Grok object is dropped by itself.
  • The meter is the paired desktop's Grok CLI session, the same source as the Mac status bar. An SSH workspace does not grow a second Grok login.

Evidence

  • Test: cd mobile && pnpm exec vitest run src/components/grok-account-usage.test.ts src/components/grok-account-usage-surfaces.test.tsx src/components/account-usage-state.test.ts src/components/accounts-snapshot.test.ts src/accounts/mobile-accounts-route.test.ts
  • 44 tests passed, including a render of the home card (7d, percent, account label) and the Accounts section (30d, reset countdown), plus the hidden signed-out case.
  • pnpm exec oxlint on the touched files reported 0 errors. tsc -p tsconfig.test.json reported no errors in the touched files.
  • Before/after on a device: not run. The iOS simulator was not paired to a signed-in desktop in this change, so there is no screenshot.

User-regression-tradeoffs

  • Claude and Codex home rows still show 5h and 7d without a reset line. Only the Grok row is a single window.
  • While Grok is signed in but the first fetch has not landed, the row shows a loading bar instead of hiding.
  • An expired Grok session with no window yet shows "Signed in" and an em dash, plus the error on the Accounts screen.
  • The 30d label is slightly wider than 5h / 7d so it is not clipped. Other bars keep the old label width.

Linked Issue

Refs #18469
Refs #22648

This does not close those issues. #18469 also asks for the other desktop providers on the Accounts screen. #22648 also asks for those providers, plus Cursor, on the home card. #22626 is the open proposal for the wider Accounts-screen set.

Visual Proof

No simulator screenshot in this PR. The rendered home card and Accounts section are asserted in grok-account-usage-surfaces.test.tsx (account label, 7d / 30d, percent, and reset text). A signed-out host renders no Grok row.

Testing

  • cd mobile && pnpm exec vitest run src/components/grok-account-usage.test.ts src/components/grok-account-usage-surfaces.test.tsx src/components/account-usage-state.test.ts src/components/accounts-snapshot.test.ts src/accounts/mobile-accounts-route.test.ts

  • pnpm exec oxlint on the touched mobile files

  • Platforms: logic tested on macOS. No iOS simulator pass against a live desktop. No Linux, Windows, or SSH manual pass. The phone only renders the snapshot the paired desktop already publishes, and the new code has no platform branch.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Grok (xAI). The change and the test results were reviewed in this session.

Review

Self-review:

  • Cross-platform: React Native views and existing tokens only. No shortcuts or path separators.
  • SSH/remote: usage comes from the Orca desktop that owns the Grok CLI session file, including when that desktop is the paired host. No new remote command.
  • Backwards compatibility: missing or malformed Grok data does not fail decodeAccountsSnapshot.
  • Performance: one safeParse of the Grok slot per snapshot.
  • Security: read-only display of data the host already sends. No credentials and no new RPC.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No desktop, host, or protocol change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred). Mobile-scoped vitest, oxlint on the touched files, and a test-project tsc check of those files were run locally. The root desktop suite was not run because this PR does not change the desktop.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ff549c95-b126-4fa2-91f4-4dfc266629e6

📥 Commits

Reviewing files that changed from the base of the PR and between 5c9eb4d2118aad806bea0e7d9a59e7abd4394291 and 38ee2be63774d3438c89dd3f0d3d40b8e67ca20f.

📒 Files selected for processing (2)
  • mobile/src/components/grok-account-usage.test.ts
  • mobile/src/components/grok-account-usage.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The mobile app now models Grok account usage and displays it on the home account cards and host accounts screen. The model supports weekly and monthly usage windows, reset labels, loading states, and limits errors. Shared usage-state functions accept monthly windows, and UsageBar supports a configurable label width. Tests cover usage selection, rendering, and visibility.

Merge Risk: Minimal · previous review 38ee2

The misleading windowless Grok row is no longer shown on either mobile surface. No actionable merge-blocking issue remains after normal checks.

Security architecture risk: Low · up to 38ee2

Grok usage is added as a read-only display. The reviewed path does not add account switching or credential operations, but the phone relies on the paired computer for the identity and usage it shows.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A false Grok value from a paired host can affect that host’s mobile home card and Accounts display. The traced consumers do not turn it into an account mutation or credential operation.

Trust Boundaries and Controls

  • observed — The mobile decoder validates the snapshot, and the Grok selector rejects malformed or wrongly identified Grok limits. Valid host-reported provenance and errors still reach text displays; existing Claude and Codex home rows likewise display host-supplied identity text.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding Grok usage to the mobile home and Accounts screens.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, scope, linked issues, testing, compatibility, and review considerations. The UI visual-proof requirement is not fully met becaus…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Grok selectors — new mobile/src/components/grok-account-usage.ts re-parses the rateLimits.grok slot in isolation with ProviderRateLimitsSchema (dropping a malformed or foreign-provider slot without failing Claude/Codex), reads grokAuthConfigured via a cast, and picks weekly → monthly fallback.
  • Home visibility gate — hostShowsAccountUsage (Claude || Codex || Grok) replaces the inline Claude/Codex check in use-mobile-home-data.ts, so a Grok-only desktop now renders the Account usage card.
  • Home row — MobileHomeAccountUsageCards.tsx adds a single-bar Grok row (no reset line) plus its grok.limits?.error line.
  • Accounts section — new read-only GrokAccountUsageSection.tsx, mounted in accounts.tsx, with the live reset countdown.
  • UsageBar — new labelWidth prop (default 22 preserves existing callers) so the wider 30d label is not clipped; the reset-text indent now derives from it.
  • Window type — UsageWindowKey gains 'monthly'; tests extend getWindowResetLabel / getUsageBarState coverage for the monthly window.

I verified the mechanism end to end: the host's rateLimits.getState() already publishes grok and grokAuthConfigured, and the mobile snapshot's .passthrough() retains both, so this is display-only with no wire change. Window selection matches the desktop status-bar monthly-only Grok path and the fetcher (which emits weekly XOR monthly). The mobile tests (47) pass, oxlint on the touched files is clean, and tsc -p mobile/tsconfig.test.json reports no errors in the touched files.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b972c712-1f4a-486e-8243-9fd3b8daa4e1

📥 Commits

Reviewing files that changed from the base of the PR and between a85057e and 5c9eb4d2118aad806bea0e7d9a59e7abd4394291.

📒 Files selected for processing (10)
  • mobile/app/h/[hostId]/accounts.tsx
  • mobile/src/accounts/GrokAccountUsageSection.tsx
  • mobile/src/components/AccountUsage.tsx
  • mobile/src/components/account-usage-state.test.ts
  • mobile/src/components/account-usage-state.ts
  • mobile/src/components/grok-account-usage-surfaces.test.tsx
  • mobile/src/components/grok-account-usage.test.ts
  • mobile/src/components/grok-account-usage.ts
  • mobile/src/home/MobileHomeAccountUsageCards.tsx
  • mobile/src/home/use-mobile-home-data.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@innocarpe
innocarpe force-pushed the fix/mobile-grok-account-usage branch from 5c9eb4d to 38ee2be Compare September 27, 2026 01:13
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (38ee2be637)

Addressed CodeRabbit's Grok visibility finding: unauthenticated hosts now show the row only when a weekly or monthly usage window exists. The configured-auth loading state is unchanged.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Grok row now requires a real meter — getGrokAccountUsage (mobile/src/components/grok-account-usage.ts:86) replaces the hasActiveProviderUsage(limits) check with readGrokWindowKey(limits), so a host with grokAuthConfigured: false and a status: 'ok' response that carries no weekly/monthly window no longer renders a "Signed in" row with no bar. This addresses the CodeRabbit finding on the prior revision; the signed-in loading path (authConfigured true, no window yet) is unchanged.
  • Regression test added — grok-account-usage.test.ts:163 asserts getGrokAccountUsage / hostShowsAccountUsage return null / false for { status: 'ok', weekly: null, monthly: null } with auth unconfigured. The assertion fails against the pre-fix guard, so it is real coverage rather than a tautology.

I confirmed the fix is complete: the desktop Grok fetcher emits weekly XOR monthly and never session or buckets (src/main/rate-limits/grok-fetcher.ts:329-347), so readGrokWindowKey covers every usage shape the host can publish and no non-Grok path in the module regressed. No unresolved pullfrog threads remain on this PR.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@innocarpe
innocarpe force-pushed the fix/mobile-grok-account-usage branch from 38ee2be to fa14777 Compare October 22, 2026 02:50
@innocarpe
innocarpe force-pushed the fix/mobile-grok-account-usage branch from fa14777 to a4593b2 Compare October 29, 2026 11:07
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Adds Grok usage display to home and accounts screens.

The PR should not merge until the new wiring test is corrected to inspect the component it asserts against.

Findings

  1. P1 Wiring Test Reads Wrong Route ▶
  2. P2 Fallback Label Is Untranslated ▶

Summary

The PR adds read-only Grok usage to the mobile home card and Accounts screen, using the paired desktop’s existing account snapshot.

  • It selects weekly or monthly Grok meters without changing Claude or Codex account controls.
  • The new wiring test targets the wrong route file; the Grok fallback label also bypasses mobile translation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Desktop accounts snapshot] --> B[Mobile snapshot decoder]
  B --> C[Grok slot validation and meter selection]
  C --> D[Home account-usage card]
  C --> E[Accounts screen Grok section]
Loading

Reviews (1) · Last reviewed commit: "fix(mobile): hide Grok usage without a m..." · Reviewed by Greptile

Comment on lines +217 to +220
const accounts = readFileSync(
new URL('../../app/h/[hostId]/accounts.tsx', import.meta.url),
'utf8'
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Wiring test reads wrong route. When the new test runs, it reads the native accounts.tsx route and expects to find <GrokAccountUsageSection. That route renders MobileWebShellScreen; the Grok section is mounted in MobileAccountsScreen.tsx. The assertion therefore fails, breaking the test run.

Suggested change
const accounts = readFileSync(
new URL('../../app/h/[hostId]/accounts.tsx', import.meta.url),
'utf8'
)
const accounts = readFileSync(
new URL('../accounts/MobileAccountsScreen.tsx', import.meta.url),
'utf8'
)

}
return {
limits,
label: readAuthProvenance(limits) ?? 'Signed in',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Fallback label is untranslated. When the host sends no account provenance, the Grok row shows the hard-coded English text “Signed in”. Unlike the existing Accounts screen labels, it will not follow the mobile UI language, leaving the row partly untranslated.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

The paired desktop already publishes Grok rate limits on the accounts
snapshot. Show that read-only meter beside Claude and Codex, including
weekly credits and monthly unified billing.

Preserves Claude and Codex account switching. A host with neither a Grok
CLI session nor a usable meter still shows no Grok row.
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for working on this! #38187 just merged and shows usage on mobile for every provider the desktop tracks, so I'm closing this in favour of it. Your work here helped shape that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants