feat(wallet): surface multi-chain balances in Settings
Summary
- Surfaces the existing
wallet.balancesRPC in the UI by adding a new Settings → Account → Wallet Balances panel. - Multi-chain rows (EVM, BTC, Solana, Tron) with chain badges, truncated addresses, copy-to-clipboard, formatted balances, provider-status chips, and a Refresh button.
- No behaviour change in the core — backend was already complete; this fills the UI gap.
Problem
The wallet.balances RPC has been live in the Rust core for some time and is listed as a capability in about_app/catalog.rs, but the frontend never had a caller. The only way to read multi-chain balances today is to issue a raw JSON-RPC request — inaccessible to normal users, which breaks the obvious "I set up a wallet → what is in it?" mental model and blocks the broader crypto / portfolio workflows tracked in #1394.
Solution
app/src/services/walletApi.ts— addsBalanceInfotype +fetchWalletBalances()callingwallet.balancesvia the existingcoreRpcClient, mirroring thefetchWalletStatuspattern. New tests added in the same file.app/src/components/settings/panels/WalletBalancesPanel.tsx— new self-contained panel that renders four states (loading, error with Retry, empty with Recovery Phrase hint, loaded). Loaded state renders oneBalanceRowper balance with chain badge (color-coded per Tailwind palette), truncated address (first 6 + last 4 chars), copy-to-clipboard button, formatted amount + symbol, optional "provider unavailable" chip, and a Refresh button.app/src/pages/Settings.tsx— registers the new entry under Account section, routed at/settings/wallet-balances.- i18n — 13 new keys in
app/src/lib/i18n/en.tsplus matching English-value entries in every locale chunk (chunks/{ar,bn,de,en,es,fr,hi,id,it,ko,pt,ru,zh-CN}-4.ts) sopnpm i18n:checkparity passes and translators can fill non-English values later. - Capability catalog (
src/openhuman/about_app/catalog.rs) — single-line update to theskills.wallet_executionhow_tofield pointing users at the new panel. - Coverage matrix — new row in
docs/TEST-COVERAGE-MATRIX.mdtracking the panel.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy — 9 Vitest panel tests across loading / error+retry / empty / loaded / refresh states, plus 5 walletApi tests for the new
fetchWalletBalancesfunction (14/14 passing locally). - [x] Diff coverage ≥ 80% — changed lines are largely the new panel + new RPC client function, both fully covered by the new test files.
- [x] Coverage matrix updated — added row 13.1.4 ("Wallet Balances Panel") under the wallet feature group; covered count bumped 69→70.
- [x] All affected feature IDs from the matrix are listed in the PR description under
## Related—skills.wallet_execution(UI surfacing of an existing capability — no new feature ID needed). - [x] No new external network dependencies introduced (mock backend used per Testing Strategy) — the new tests mock
fetchWalletBalancesdirectly; no network calls. - [x] Manual smoke checklist updated if this touches release-cut surfaces (
docs/RELEASE-MANUAL-SMOKE.md) — N/A: additive UI surface, no release-cut behaviour change. - [x] Linked issue closed via
Closes #NNNin the## Relatedsection —Closes #2682below.
Impact
- Runtime / platform: pure UI addition — desktop only, no behaviour change on existing surfaces.
- Performance: negligible — one RPC call on panel mount + on user-triggered Refresh.
- Security / privacy: unchanged —
wallet.balancesonly uses the public address; the recovery phrase never leaves the local core. - Migration / compatibility: none.
Manual visual verification
Verified locally via pnpm dev:app:
- Setting up a fresh wallet via Settings → Recovery Phrase and then opening Settings → Wallet Balances renders all four chain rows (EVM, BTC, SOL, TRX) with the expected zero-balance loaded state.
- Sample output observed:
EVM 0x9B99…2660 0.000000000000000000 ETH BTC 1BnHT1…77G3 0.00000000 BTC SOL 51xrwi…aWRF 0.000000000 SOL TRX TAWYnc…q4q9 0.000000 TRX - Addresses are derived correctly per chain, decimals match the chain conventions (18/8/9/6), and chain badges colour-match the Tailwind palette tokens.
Related
- Closes: #2682
- Parent crypto roadmap: #1394 (this PR is one slice — read-only balance surface; transfers / swaps / contract calls remain open under that parent).
- Follow-up PR(s)/TODOs: none.
AI Authored PR Metadata (required for Codex/Linear PRs)
Keep this section for AI-authored PRs. For human-only PRs, mark each field
N/A.
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch: N/A
- Commit SHA: N/A
Validation Run
- [x]
pnpm --filter openhuman-app format:check— passes (Prettier auto-fixes applied during quality-gate commit). - [x]
pnpm typecheck— clean. - [x] Focused tests:
pnpm test -- WalletBalancesPanel walletApi— 14/14 passed. - [x] Rust fmt/check (if changed):
cargo check --manifest-path Cargo.tomlclean for the one-linecatalog.rstouch. - [x] Tauri fmt/check (if changed):
pnpm rust:checkclean.
Validation Blocked
command:N/Aerror:N/Aimpact:N/A
Behavior Changes
- Intended behavior change: Users can now view multi-chain wallet balances inside the app instead of having to issue raw RPC calls.
- User-visible effect: New Settings → Account → Wallet Balances panel listing per-chain balance rows.
Parity Contract
- Legacy behavior preserved: No existing surface touched. Backend RPC unchanged.
- Guard/fallback/dispatch parity checks: N/A — additive UI only.
Summary by CodeRabbit
-
New Features
- Added Wallet Balances settings panel with per-chain badges, truncated addresses + copy-to-clipboard (with “copied” feedback), provider-status badge, and manual refresh with loading/disabled state.
-
Bug Fixes / Stability
- Retry flow and error messaging for failed balance loads; refresh updates list reliably.
-
Documentation
- Added translations for the Wallet Balances UI across multiple languages and updated settings entry text.
-
Tests
- Added behavioral and API tests covering loading, error/retry, empty, populated, and refresh states.
[!NOTE]
Reviews paused
It 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
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds a Settings > Account > Wallet Balances panel that fetches multi-chain wallet balances via a new fetchWalletBalances() API, displays rows with chain badges, truncated copyable addresses, formatted balances and provider-status badges, includes request-sequencing guards, loading/error/empty states, refresh control, tests, i18n across language chunks, settings routing integration, and a separate Rust admission pipeline for generated tools with provenance/risk fields and admission logic.
Changes
Wallet Balances Feature
| Layer / File(s) | Summary |
|---|---|
API Contract & Data Shape app/src/services/walletApi.ts, app/src/services/walletApi.test.ts |
Exports BalanceInfo and fetchWalletBalances() calling openhuman.wallet_balances; tests verify RPC invocation, error propagation, and empty results. |
Panel Component Implementation app/src/components/settings/panels/WalletBalancesPanel.tsx |
Implements WalletBalancesPanel and BalanceRow: monotonic request-id guards to avoid stale updates, loading/error/empty/loaded UI branches, refresh button (disabled while loading) with spinner, truncated address + copy-to-clipboard with transient “copied” feedback, formatted balances and asset symbols, and provider-unavailable badge. |
Panel Behavioral Tests app/src/components/settings/panels/__tests__/WalletBalancesPanel.test.tsx |
Vitest suite (mocked fetchWalletBalances and navigation hook) covering loading spinner, generic error with Retry flow, empty-state with Recovery Phrase hint, loaded rows (chain badges, balances, symbols, truncated addresses), provider-unavailable chip, and refresh-triggered reloads. |
Settings Navigation & Routing app/src/pages/Settings.tsx |
Imports WalletBalancesPanel, defines WalletIcon, adds wallet-balances to accountSettingsItems with localized strings, and registers /settings/wallet-balances route rendering the panel via wrapSettingsPage. |
Navigation Hook Update app/src/components/settings/hooks/useSettingsNavigation.ts |
Adds 'wallet-balances' to SettingsRoute, maps /settings/wallet-balances to that route, and reuses recovery-phrase breadcrumbs. |
Multi-Language i18n Translations app/src/lib/i18n/en.ts, app/src/lib/i18n/chunks/*-4.ts |
Adds pages.settings.account.walletBalances and walletBalances.* keys (title/description, refresh/loading/retry, empty-state guidance, copy-address, provider-missing, raw-balance template, generic error) across the main English map and language chunk files. |
Documentation & Capability Catalog docs/TEST-COVERAGE-MATRIX.md, src/openhuman/about_app/catalog.rs |
Adds Wallet Balances Panel (13.1.4) as covered in the test matrix and updates skills.wallet_execution how_to text to mention Settings > Wallet Balances. |
Generated Tools Admission (Rust)
| Layer / File(s) | Summary |
|---|---|
Structs, Enums & Public Types src/openhuman/tools/generated.rs |
Extends GeneratedToolDefinition with optional provenance/policy fields, adds GeneratedToolRisk enum, and introduces admission-related public types (GeneratedToolAdmissionConfig, GeneratedToolAdmissionRejection, GeneratedToolAdmissionReport). |
Admission Entrypoint & Validation src/openhuman/tools/generated.rs |
Implements admit_generated_tool_definitions with normalization and validation helpers enforcing provenance/risk/provider/capability checks and returning admitted/rejected reports. |
Admission Tests & Helpers src/openhuman/tools/generated.rs (tests) |
Expands tests to cover trusted acceptance, provider normalization, invalid-provider rejection, legacy preservation when enforcement is off, duplicate/unsafe-name rejection, missing-risk rejection, and verifies external_effect() semantics. |
Sequence Diagram
sequenceDiagram
participant User
participant WalletBalancesPanel
participant fetchWalletBalances
participant CoreRPC as openhuman.wallet_balances
User->>WalletBalancesPanel: Click Refresh
WalletBalancesPanel->>WalletBalancesPanel: increment latestRequestId
WalletBalancesPanel->>fetchWalletBalances: call loadBalances()
fetchWalletBalances->>CoreRPC: call openhuman.wallet_balances
CoreRPC-->>fetchWalletBalances: return BalanceInfo[]
fetchWalletBalances-->>WalletBalancesPanel: Promise resolves
WalletBalancesPanel->>WalletBalancesPanel: setState(balances)
WalletBalancesPanel-->>User: render BalanceRow list
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
- tinyhumansai/openhuman#2519: Changes to backend
wallet_balancesoutput (provider status, optionalevm_network) that this UI andfetchWalletBalancesconsume. - tinyhumansai/openhuman#1858: Also modifies
useSettingsNavigation.ts/Settings route handling; similar integration pattern for adding settings panels.
Suggested reviewers
- graycyrus
- M3gA-Mind
- sanil-23
Poem
🐰 Hoppy code hops through the settings door,
Wallet balances shimmer, chained and pure.
Click to copy, refresh to see,
Multi-chain friends, all safe and free. ✨
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Out of Scope Changes check | ⚠️ Warning | Most changes are in-scope, but the Rust changes to src/openhuman/tools/generated.rs introducing admission pipeline for generated tools appear unrelated to wallet balances display. | Clarify the relationship between generated tool admission and wallet balances, or move those Rust changes to a separate PR focused on tool security/provenance. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 57.58% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The PR title clearly and concisely describes the main feature: adding a wallet balances panel to Settings UI for viewing multi-chain balances. |
| Linked Issues check | ✅ Passed | All primary objectives from #2682 are fully implemented: Settings entry, multi-chain rows with badges/addresses/copy, provider health visibility, refresh functionality, all UI states, privacy preservation, i18n coverage, and unit tests. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
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 @coderabbitai help to get the list of available commands and usage tips.
@graycyrus addressed both non-blocking nits in d524a5de + 1d7eb5eb:- Copy-address timer stacking: switched to a useRef-tracked timer that clears on each re-click and on unmount, so rapid clicks reset the 2s window cleanly instead of letting an older setTimeout flip copied back to false.- Dead walletBalances.addressCopied key: removed from en.ts and all 13 locale chunk-4 files. pnpm i18n:check is clean (0 missing/extra/drift). Existing Vitest suite (3551 tests) still green.
Actionable comments posted: 0
Hi @graycyrus @oxoxDev — round-4 rfix4 shepherding complete: CR comments addressed, CI green/converging, I've approved. Would appreciate a second-maintainer review when you have a moment 🙏
Hi @graycyrus — addressed your major finding directly: pushed 50dee06c which reverts the 3 bundled commits from pr/2549 (6226ed4, 21a7bf3, 46631365 — the 393 lines of admission-control code in src/openhuman/tools/generated.rs). Local cargo check clean; no other code referenced the reverted types. Once #2549 merges to main, the admission-control code will arrive here naturally via the next main merge. Re-requesting review.
@graycyrus @oxoxDev — addressed the 2 CI failures in 711e01fa: the classifies_embedding_api_invalid_token_401_as_session_expired test was failing on main itself (a regression from #2786 leaving the obsolete TAURI-RUST-T BackendUserError test contradicting the new SessionExpired classification). Fix scoped to src/core/observability.rs: guard is_embedding_backend_auth_failure so the OpenHuman-backend {"error":"Invalid token"} envelope falls through to SessionExpired; extend is_session_expired_message to match both parenthesized and bare-status wire forms; update the obsolete TAURI-RUST-T test to assert SessionExpired (now a regression guard). 121 observability tests green locally. Re-requesting review.
Resolved the merge conflict with main in 97b07007 — merged latest upstream db3fdc2e. The only conflict was in en.ts (our walletBalances.* keys vs upstream's new skills.dashboard.* keys); kept both. Verified locally: pnpm i18n:check parity clean (0 missing/extra/drifted across all locales), pnpm typecheck clean, cargo check clean. Branch is mergeable again.
really great PR. merging shortly.