Skip to content

feat(mobile): show DeepSeek API balance - #23294

Open
innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/mobile-deepseek-account-usage
Open

innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/mobile-deepseek-account-usage

Conversation

@innocarpe

@innocarpe innocarpe commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Mobile Home and Accounts show the DeepSeek balance supplied by the connected host. Balance and status updates use polite live regions. Malformed balance data now shows “Balance unavailable” instead of remaining on “Checking balance…”.

What Changed

  • Display DeepSeek host-snapshot usage on the Home usage card and Accounts screen.
  • Mark the primary balance/status and conditional error/status text as polite live regions on both screens.
  • Reuse the snapshot schema’s unknown-field types for optional DeepSeek fields, removing the old type assertion.
  • Distinguish malformed provider data from a missing initial balance request; keep malformed DeepSeek data isolated from other provider snapshots.
  • Render the real Home and Accounts components in tests for loading, unavailable, available, depleted, and refresh-error states.
  • Keep the view read-only: no mobile DeepSeek API request or credential storage.

Why

The host provider work is separate in #12873. This PR presents that data on mobile and exposes changes to accessibility services without changing layout or data ownership.

Linked Issue

Refs #12869; host provider dependency #12873.

Visual Proof

N/A for this follow-up — status labels and accessibility metadata, covered by component render tests. Device screen-reader behavior was not manually tested.

Testing

  • DeepSeek selector, Home/Accounts render, usage-state, and snapshot tests: 40 passed.
  • Mobile app TypeScript check, test-typecheck ratchet, changed-code quality gate, and whitespace check.
  • Full test TypeScript check remains red on existing test diagnostics; no changed component is referenced. Device VoiceOver/TalkBack validation and full mobile build were not run.

AI Disclosure

Implementation and verification assisted by OpenAI Codex.

Agent skill upstream boundary

  • Not applicable — mobile components and presentation logic only.

Checklist

  • Focused read-only mobile presentation change.
  • Host credentials and API ownership retained; folder/remote host snapshots supported.
  • Device accessibility verification.

@coderabbitai

coderabbitai Bot commented Sep 27, 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.

Walkthrough

The mobile app now derives DeepSeek account usage from account snapshots. Home displays a DeepSeek API row when usage data is present, and the connected-host filter includes hosts with DeepSeek usage. Accounts displays a read-only DeepSeek usage section. Tests cover usage statuses, malformed data, and both display integrations.

Merge Risk: Minimal · previous review 00f0d

DeepSeek balance and status now appear on Home and Accounts. Malformed data shows an unavailable state, and status changes are announced through polite live regions. No merge-blocking risk remains.

Security architecture risk: Low · up to 00f0d

The new balance display appears confined to connected hosts and read-only mobile views. No security issue was verified, but coverage of the full changed-file surface and the separate host provider remains incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The established exposure is the balance and status shown for a connected host in mobile Home and Accounts, not a new credential or provider-request path.

Trust Boundaries and Controls

  • observed — The optional host-supplied DeepSeek slot is independently parsed against a schema requiring the DeepSeek provider identity; a failed parse does not supply trusted limits.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)

Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: displaying the DeepSeek API balance in the mobile app.
Description check ✅ Passed The description is complete and relevant. It explains the user-visible change, implementation scope, rationale, linked issues, testing results, limitations, and AI disclosure. It omits the template's …
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2c50ae4c-2023-40a2-aee1-50b60a94210d

📥 Commits

Reviewing files that changed from the base of the PR and between 15eefdf065a71b4ef93e1455823f51f4a97dc30e and 00f0dd17162caea8187f84b1b48de87fa43e90cc.

📒 Files selected for processing (2)

  • mobile/src/components/deepseek-account-usage.test.ts
  • mobile/src/components/deepseek-account-usage.ts

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

@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: e899305d-f7b3-44e5-943f-23ccc63f5fe9

📥 Commits

Reviewing files that changed from the base of the PR and between 46907de and a21b57d5325eeed5cd957360b379c6302b88c158.

📒 Files selected for processing (6)
  • mobile/app/h/[hostId]/accounts.tsx
  • mobile/src/accounts/DeepSeekAccountUsageSection.tsx
  • mobile/src/components/deepseek-account-usage.test.ts
  • mobile/src/components/deepseek-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.

@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

  • DeepSeek usage selector — getDeepSeekAccountUsage/hasDeepSeekAccountUsage validate the optional rateLimits.deepseek slot in isolation, so a malformed payload cannot take down Claude/Codex decoding, and map the host's monthly balance window to loading / available / depleted / refresh-error / unavailable.
  • Accounts screen — new read-only DeepSeekAccountUsageSection mounted after the Codex section.
  • Home usage card — a DeepSeek row in MobileHomeAccountUsageCards, plus a hasDeepSeekAccountUsage clause so DeepSeek-only hosts still appear on Home.
  • Tests — logic coverage for each status, a malformed-slot isolation case, and a source-string seam test over the three wiring sites.

I traced the consumed contract against the still-open host PR #12873: ProviderRateLimits.provider gains 'deepseek', RateLimitState gains deepseek + deepseekAuthConfigured, the fetcher maps the USD balance into monthly.resetDescription with usedPercent 0/100, and applyStalePolicy preserves the prior window with status: 'error' on a failed refresh — which is exactly what the mobile refresh-error branch expects. The extended schema also keeps working after #12873 adds 'deepseek' to the base enum.

ℹ️ This view is inert until #12873 lands

Every field this PR reads — rateLimits.deepseek and rateLimits.deepseekAuthConfigured — comes from the still-open host PR #12873, so on its own the mobile view always returns null and stays hidden. That is safe but dark; the only thing worth settling before merge is that #12873's shape is frozen, since it is still under review and could rename the balance carrier or change the usedPercent convention this code hard-codes.

Technical details
# DeepSeek mobile view depends on an unmerged host contract

## Affected sites
- `mobile/src/components/deepseek-account-usage.ts:26` — reads `rateLimits.deepseekAuthConfigured`
- `mobile/src/components/deepseek-account-usage.ts:34` — reads `rateLimits.deepseek`
- `mobile/src/components/deepseek-account-usage.ts:52` — treats `monthly.resetDescription` as the balance label
- `mobile/src/components/deepseek-account-usage.ts:58` — treats `monthly.usedPercent >= 100` as depleted

## Required outcome
- Confirm the host PR #12873 field names and the `resetDescription`/`usedPercent` conventions are frozen, or land the two PRs together.

## Suggested approach (optional)
- No code change required here; this is a merge-ordering / contract-stability question.

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

@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from a21b57d to 15eefdf Compare September 29, 2026 08:05
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking accessibility announcement concern.

Findings

  1. P2 Status update may go unheard ▶

Summary

The PR displays host-supplied DeepSeek balance and status on Mobile Home and Accounts, distinguishes malformed balance data from a pending request, and adds rendered state tests. The conditional status announcement may not be heard when an unchanged balance develops an error.

Reviews (3) · Last reviewed commit: "fix(mobile): show unavailable balances a..." · Reviewed by Greptile

@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: 85a02293-2070-41c2-9c84-cff1e63c2ca4

📥 Commits

Reviewing files that changed from the base of the PR and between a21b57d5325eeed5cd957360b379c6302b88c158 and 15eefdf065a71b4ef93e1455823f51f4a97dc30e.

📒 Files selected for processing (3)
  • mobile/src/accounts/DeepSeekAccountUsageSection.tsx
  • mobile/src/components/deepseek-account-usage.ts
  • mobile/src/home/MobileHomeAccountUsageCards.tsx

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

@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

This pass re-reviewed only the delta since the prior Pullfrog review (15eefdf065 against a21b57d532; the ea4fe30988 feat commit is a rebase of already-reviewed content onto bd133058).

  • Polite live regions on both DeepSeek surfaces — accessibilityLiveRegion="polite" added to the balance/status text and the conditional error/status text in both MobileHomeAccountUsageCards and DeepSeekAccountUsageSection, matching the existing mobile status pattern.
  • Dropped the readField helper — the optional DeepSeek slot is now read by directly indexing the passthrough rateLimits object, removing the last assertion from the selector.

The selector tests (7 passed) and the mobile app typecheck are green against this revision.

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

@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from 15eefdf to 00f0dd1 Compare September 29, 2026 08:57

@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

This pass re-reviewed the delta since the prior Pullfrog review (15eefdf065 → 00f0dd1716).

  • Malformed DeepSeek payloads now report unavailable — readDeepSeekLimits returns a distinct invalid flag, and getDeepSeekAccountUsage maps a failed schema parse to unavailable ("Balance unavailable") instead of the indefinite "Checking balance…" state; a genuinely absent slot still loads.
  • Render-level coverage for both surfaces — the source-string assertion over MobileHomeAccountUsageCards is replaced with react-test-renderer mounts of the real Home card and Accounts section across pending / malformed / available / depleted / refresh-error snapshots, asserting the visible balance/status and accessibilityLiveRegion="polite" on changing labels. The remaining source assertions cover only Accounts route mounting and DeepSeek-only host inclusion.

Verified locally: 12 focused tests pass, and no changed file appears in the mobile typecheck:tests diagnostics (the remaining errors are pre-existing and unrelated).

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

@innocarpe

Copy link
Copy Markdown
Contributor Author

Updated this follow-up at 00f0dd1716: known review findings are addressed, with 40 selector/component/snapshot tests, the mobile app TypeScript check, the test-typecheck ratchet, and changed-code quality checks passing. Malformed data now renders as unavailable, and the real Home and Accounts components cover the balance/status states and polite live regions.

Greptile and Pullfrog have completed successfully. PR Checks, Mobile Checks, and PR test LoC currently require maintainer approval; please approve those workflow runs when reviewing this update. Device VoiceOver/TalkBack testing and the full mobile build remain unperformed.

nwparker added a commit that referenced this pull request Oct 2, 2026
Store write-only API-key entries in protected execution-host storage and poll the documented balance endpoint through the existing account usage service.
Display each currency's exact monetary strings in Accounts and the status bar, with explicit unsupported hosts and stale errors.

Builds on the DeepSeek balance and mobile account work in #12873 and #23294.

Co-authored-by: Wooseong Kim <innocarpe@gmail.com>
@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from 00f0dd1 to 2798978 Compare October 22, 2026 02:31
@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from 2798978 to 4035ee9 Compare October 29, 2026 11:04
Comment on lines +115 to +123
{deepSeekUsage.balanceLabel && deepSeekUsage.status !== 'available' ? (
<Text
accessibilityLiveRegion="polite"
style={styles.providerStatus}
numberOfLines={1}
>
{deepSeekUsage.statusLabel}
</Text>
) : null}

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 Status update may go unheard When a balance stays the same but its status changes to depleted or refresh-error, the existing live-region text does not change. The separate status text is mounted only when the failure appears. If a screen reader announces changes only to existing live regions, it may not speak the failure on Home or Accounts. Keeping a status announcement region present across states would make the update reliable.

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!

@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from 4035ee9 to 43f30c8 Compare November 2, 2026 10:52
@innocarpe
innocarpe force-pushed the fix/mobile-deepseek-account-usage branch from 43f30c8 to cde988d Compare November 8, 2026 12:17
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (cde988da63)

Rebased onto current upstream/main. The DeepSeek balance section still renders on Accounts, using main's one-argument provider sections and the other-providers block.

This branch has not been deployed

No deployments
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.

1 participant