Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe mobile app now supports visibility controls for eight account-usage providers. Visibility preferences are loaded, normalized, persisted with serialized updates, and exposed through a new settings route and focus-aware hook. Home and account usage screens render selected managed and display-only providers using shared usage-window components. Provider state selectors now support additional snapshot fields, dynamic windows, reset labels, and expanded renderability rules, with tests covering persistence, settings interactions, selectors, and rendering. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7b9e8cbd-6212-4fc7-8d1a-9d3d02fe0927
📥 Commits
Reviewing files that changed from the base of the PR and between 0532765 and 383d7b0d28df857faa67b0877adbb72696184161.
📒 Files selected for processing (16)
mobile/app/_layout.tsxmobile/app/account-usage-settings.tsxmobile/app/h/[hostId]/accounts.tsxmobile/app/index.tsxmobile/app/settings.tsxmobile/src/account-usage-settings-route.test.tsmobile/src/accounts-route-display-provider.test.tsmobile/src/components/AccountUsage.tsxmobile/src/components/HomeAccountUsageCard.tsxmobile/src/components/account-usage-state.test.tsmobile/src/components/account-usage-state.tsmobile/src/components/home-account-usage-card.test.tsmobile/src/components/use-visible-usage-providers.test.tsmobile/src/components/use-visible-usage-providers.tsmobile/src/storage/preferences.test.tsmobile/src/storage/preferences.ts
d9d43e5 to
8afd15c
Compare
|
Rebased onto current |
|
Rebased onto current Kept main's Branch is restacked and ready for re-review. |
8afd15c to
f5604b0
Compare
桌面已支援 Claude/Codex/Gemini/OpenCode Go/Kimi/MiniMax/Grok 的用量顯示, 行動端卻只顯示 Claude+Codex。此變更讓行動端顯示全部 provider,並於 Settings → Account usage 提供每個 provider 的開關(預設只開 Claude+Codex, 其餘 opt-in,避免手機一次塞滿)。 - 純 client 變更:host 已在 accounts.list / accounts.subscribe 的 snapshot 送出完整 RateLimitState,零後端 / 協定改動。 - 拆 ManagedAccountProviderKey(可切換)vs UsageProviderKey(唯讀顯示); display-only provider 走不可點路徑,不會觸發帳號切換。 - 以 canonical descriptor 對應 wire id 與 snapshot 欄位(解 opencode-go / opencodeGo 不一致);新欄位為 optional 並以 ?? null 正規化舊 v1 快取。 - getProviderUsageWindows 依實際視窗渲染:Gemini 具名 buckets、OpenCode Go monthly、其餘 session/weekly,不再硬寫 5h/7d。 - 可見性偏好存於本地 AsyncStorage,沿用既有 focus-reload 慣例。 - home 卡片抽成 HomeAccountUsageCard 以符合 max-lines。
… load
The Account-usage settings screen started on the default set {claude,codex}
while the stored visibility set loaded asynchronously. A toggle fired before
that load resolved persisted the whole set against the stale default, silently
dropping any provider that lived only in the stored set (e.g. an opted-in
Grok).
- Gate the switches until the stored set loads, so no toggle can persist
against the default base.
- Move persistence to a serialized read-modify-write in preferences
(`setUsageProviderVisible`): each toggle re-reads the latest stored set and
changes only its own provider, so concurrent toggles can't clobber each
other and the write survives an unmount.
- Load once on mount via a settled read (the screen is the sole writer), so a
focus-reload can't overwrite the optimistic UI with a pre-write snapshot.
- Distinguish an I/O read failure (abort the write) from corrupt content
(missing / malformed JSON / non-array → re-base on the default and self-heal).
Tests cover: stored-only provider survives a pre-load toggle, concurrent
toggles serialize, I/O read failure aborts the write, malformed JSON self-heals.
…11y, guard NaN Review follow-ups on the multi-provider usage feature: - The Home usage card now keeps a display-only provider visible while it is fetching or in error (spinner / last bars) instead of dropping it, matching the accounts screen and making the previously-unreachable fetching branch reachable. - Each visibility Switch gets an accessibilityLabel so a screen reader names the provider being toggled. - UsageBar treats a non-finite percent (NaN/Infinity) as no data so it never renders `width: "NaN%"`.
f5604b0 to
0ad8149
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/src/components/accounts-snapshot.ts (1)
88-98: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject WSL runtime metadata without a distro.
Both refinements accept
runtime: 'wsl'with nowslDistro. That permits an ambiguous WSL target through decoding, despite the accounts route using it for targeted Codex account selection.
mobile/src/components/accounts-snapshot.ts#L88-L98: require a non-empty, untrimmedwslDistrowheneverruntimeiswsl.mobile/src/components/accounts-snapshot.ts#L157-L167: enforce the same invariant for WSL-managed Codex accounts.mobile/src/components/accounts-snapshot.test.ts#L144-L149: add rejection cases for WSL runtime values with null or omitted distros.Proposed validation change
- if ( - target.runtime === 'wsl' && - target.wslDistro !== null && - target.wslDistro.trim() !== target.wslDistro - ) { + if ( + target.runtime === 'wsl' && + (target.wslDistro === null || target.wslDistro.trim() !== target.wslDistro) + ) {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b959ae4f-185e-46a0-af82-496addfee187
📒 Files selected for processing (18)
mobile/app/_layout.tsxmobile/app/account-usage-settings.tsxmobile/app/h/[hostId]/accounts.tsxmobile/app/index.tsxmobile/app/settings.tsxmobile/src/account-usage-settings-route.test.tsmobile/src/accounts-route-display-provider.test.tsmobile/src/components/AccountUsage.tsxmobile/src/components/HomeAccountUsageCard.tsxmobile/src/components/account-usage-state.test.tsmobile/src/components/account-usage-state.tsmobile/src/components/accounts-snapshot.test.tsmobile/src/components/accounts-snapshot.tsmobile/src/components/home-account-usage-card.test.tsmobile/src/components/use-visible-usage-providers.test.tsmobile/src/components/use-visible-usage-providers.tsmobile/src/storage/preferences.test.tsmobile/src/storage/preferences.ts
🚧 Files skipped from review as they are similar to previous changes (12)
- mobile/src/components/HomeAccountUsageCard.tsx
- mobile/src/components/home-account-usage-card.test.ts
- mobile/src/account-usage-settings-route.test.ts
- mobile/src/accounts-route-display-provider.test.ts
- mobile/app/settings.tsx
- mobile/src/storage/preferences.test.ts
- mobile/app/account-usage-settings.tsx
- mobile/app/h/[hostId]/accounts.tsx
- mobile/src/components/AccountUsage.tsx
- mobile/app/index.tsx
- mobile/src/storage/preferences.ts
- mobile/src/components/account-usage-state.test.ts
|
Closing as part of fork PR backlog cleanup. This branch is long-conflicted (DIRTY) against current |
Port stablyai#9274 onto fork-main. Claude and Codex stay default-on. Grok and the other extra providers are Settings → Account usage opt-in. No versionCode bump.
Summary
Continues and supersedes #8571 by @audichuang.
mainconflicts on top.Screenshots
Mobile viewport (390 × 844), showing the default Claude + Codex selection and all eight provider controls:
Testing
corepack [email protected] --dir mobile lintcorepack [email protected] --dir mobile typecheckcorepack [email protected] --dir mobile test— 290 files passed; 2080 tests passed, 2 skippedCI=true corepack [email protected] --dir mobile exec expo export --platform webpnpm build— not run; this is mobile-only, and the mobile production export above is the relevant build gateAI Review Report
Claude Opus (
claude-opus-4-8) reviewed the fullorigin/main..HEADdiff after the latestmainmerge and returned Ready to merge: Yes with no Critical or Important findings.Earlier review rounds caught or prompted verification of focus-refresh coverage, dynamic bucket + weekly/monthly coexistence, the preference write/return race, Accounts display-only render coverage, and non-finite usage handling. Those items were fixed or adjudicated against source and covered by tests before the final approval.
Cross-platform review found no new shortcut, label, filesystem-path, shell, or Electron platform behavior. The UI uses React Native primitives and existing theme tokens. Remote/SSH hosts use the existing host-scoped
accounts.list/accounts.subscribeRPC; currentmainwas verified to send the full eight-providerRateLimitState.Security Audit
Notes
0745110e09by @audichuang03924e168eby @audichuang263c4c2301by @audichuangELI5
Mobile can show the same set of usage providers as desktop, with settings toggles for which ones appear. You control visibility on Home and each host's Accounts screen.