Skip to content

Port Atlas Cloud balance provider from v0.66.0 - #618

Draft
Finesssee wants to merge 1 commit into
codex/port-0.65-account-source-packfrom
codex/port-0.66.0-atlas-cloud
Draft

Finesssee wants to merge 1 commit into
codex/port-0.65-account-source-packfrom
codex/port-0.66.0-atlas-cloud

Conversation

@Finesssee

@Finesssee Finesssee commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the Atlas Cloud balance provider from upstream v0.66.0 using Win-CodexBar's native Rust/Tauri patterns. It reads account-wide available USD through ATLASCLOUD_API_KEY or the existing keyring path, validates the typed API response, and registers the provider in settings and the frontend catalog. It reports the returned balance without inventing quota, spend, or history semantics.

This draft is stacked on #620 (codex/port-0.65-account-source-pack). The Atlas patch remains a single commit on that validated provider/account stack.

Validation

  • The Atlas patch's focused Rust tests passed before restacking (6 passed); the original review also passed Rust Clippy and frontend tests/build.
  • After restacking: cargo fmt --all -- --check and git diff --check passed.
  • CircleCI Windows pr-check passed on head f9b60dfa.
  • Thermo-nuclear re-review of f9b60dfa against e0a4bdc2 found no actionable maintainability issues.

Remaining evidence

  • Fresh Windows-native CUA proof for the provider UI surfaces is still pending. Frontend tests/build do not replace that proof.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee force-pushed the codex/port-0.66.0-atlas-cloud branch from 060408e to f9b60df Compare September 25, 2026 05:40
@Finesssee
Finesssee changed the base branch from main to codex/port-0.65-account-source-pack September 25, 2026 05:42
@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear code-quality review

Verdict: FINDINGS. Reviewed head f9b60dfaa against its base codex/port-0.65-account-source-pack.

P1: A USD balance is modeled as an unformatted display string

parse_balance checks that available.currency == "usd" and that the value is a decimal, then throws both facts away. It returns the raw string, and the provider emits it as ProviderDisplayDetail::new("atlascloud-available", "Available", balance) (atlascloud/mod.rs:90). The user sees 12.3456 with no currency symbol. Because the value is untyped, it also can't reach Usage & Spend, the balance formatting, or the preferred-currency conversion in #609.

The codebase already has a typed carrier for this: CostSnapshot::new(0.0, "USD", "Atlas Cloud balance").with_balance(amount), used by neuralwatt/mod.rs:253, helmcode.rs, huggingface and Claude web. Parse to f64 and emit a CostSnapshot with with_balance. format_balance then handles the display. That also removes the need to return the string verbatim, which makes is_decimal (:182) plus the parse::<f64>() / is_finite() double-check reducible to a single parse with a finiteness check.

P2: Two dashboard URLs for the same provider, and they disagree

  • ProviderMetadata.dashboard_url: https://atlascloud.ai/dashboard (atlascloud/mod.rs:47)
  • api_keys.rs:407 dashboard_url: https://www.atlascloud.ai/console

#610 (6eec2e2f) adds a resolver that prefers metadata and falls back to the API-key catalog, so this mismatch is already reachable. Choose the correct URL and define it once. The metadata is the canonical home; the API-key catalog entry should reuse it or leave it out.

P3 (pre-existing): HAS_DASHBOARD duplicates backend metadata

TrayPanel.tsx:30 is a hand-maintained set that mirrors metadata.dashboard_url, and every new provider has to edit it. The provider catalog could carry hasDashboard, which would delete the set. Not a blocker for this PR.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo review correction: negative balances

This corrects the P1 in my earlier thermo review on this PR, which suggested using CostSnapshot::with_balance for the Atlas Cloud balance.

The suggestion as written would lose negative balances. with_balance stores the value through finite_amount, which clamps to >= 0 (rust/src/core/usage_snapshot.rs, around line 600), so a balance of -3.25 would display as $0.00. Upstream's APIBalancePluginTests at v0.66.0 require "0.00" → $0.00 and "-1.250000" → -$1.25.

Suggested shape instead:

  • Parse available.value to f64 once, keeping the existing strict decimal validation.
  • Keep the typed balance via CostSnapshot::with_balance for the non-negative case, so it still reaches balance formatting and Usage & Spend.
  • Also emit the formatted, signed amount ($95.50, -$1.25) as the display row or informational primary, so a deficit stays visible. xai/mod.rs has a local precedent.
  • Add tests for -3.25, "-1.250000", "0.00", "", " ", NaN, 1e999, 0x10, and a non-numeric body. The error must not echo the body.

The other findings still apply. For the dashboard URL, upstream v0.66.0 uses https://www.atlascloud.ai/console, so that should be the single canonical value. Upstream also sets loginMethod = "API".

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