The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix: ui consistency, accessibility, i18n, and formatting improvements
iamrhn029bd77a5892
diff --git a/app/src/components/settings/panels/RecoveryPhraseGenerateMode.tsx b/app/src/components/settings/panels/RecoveryPhraseGenerateMode.tsxindex 03ba6295d1..cfb2afd700 100644--- a/app/src/components/settings/panels/RecoveryPhraseGenerateMode.tsx+++ b/app/src/components/settings/panels/RecoveryPhraseGenerateMode.tsx@@ -13,6 +13,7 @@ export interface RecoveryPhraseGenerateModeProps {onCopy: () => void;confirmed: boolean;onConfirmedChange: (next: boolean) => void;+ onSwitchToImport: () => void;}// Generate-mode body: the newly generated word grid (blurred until revealed),@@ -25,6 +26,7 @@ const RecoveryPhraseGenerateMode = ({onCopy,confirmed,onConfirmedChange,+ onSwitchToImport,}: RecoveryPhraseGenerateModeProps) => {const { t } = useT();@@ -108,6 +110,10 @@ const RecoveryPhraseGenerateMode = ({{t('mnemonic.consentSaved')}</span></label>++ <Button type="button" variant="tertiary" onClick={onSwitchToImport} className="w-full mb-3">+ {t('mnemonic.alreadyHavePhrase')}+ </Button></>);};diff --git a/app/src/components/settings/panels/RecoveryPhrasePanel.tsx b/app/src/components/settings/panels/RecoveryPhrasePanel.tsxindex 5273403126..2e76958bfd 100644--- a/app/src/components/settings/panels/RecoveryPhrasePanel.tsx+++ b/app/src/components/settings/panels/RecoveryPhrasePanel.tsx@@ -368,6 +368,10 @@ const RecoveryPhrasePanel = () => {onCopy={() => void handleCopy()}confirmed={confirmed}onConfirmedChange={setConfirmed}+ onSwitchToImport={() => {+ setError(null);+ setMode('import');+ }}/>) : (<RecoveryPhraseImportMode@@ -387,6 +391,23 @@ const RecoveryPhrasePanel = () => {</Alert>)}+ {mode === 'import' && (+ <Button+ type="button"+ variant="tertiary"+ onClick={() => {+ const phrase = generateMnemonicPhrase();+ setMnemonic(phrase);+ setConfirmed(false);+ setRevealed(false);+ setError(null);+ setMode('generate');+ }}+ className="w-full mb-3">+ {t('mnemonic.createANewWallet')}+ </Button>+ )}+<Buttontype="button"variant="primary"@@ -405,38 +426,6 @@ const RecoveryPhrasePanel = () => {t('mnemonic.saveRecoveryPhrase'))}</Button>-- {mode === 'generate' && (- <p className="text-center mt-3 text-sm">- <button- type="button"- onClick={() => {- setError(null);- setMode('import');- }}- className="text-primary-500 hover:text-primary-400 font-medium transition-colors">- {t('mnemonic.importAnExistingWallet')}- </button>- </p>- )}-- {mode === 'import' && (- <p className="text-center mt-3 text-sm">- <button- type="button"- onClick={() => {- const phrase = generateMnemonicPhrase();- setMnemonic(phrase);- setConfirmed(false);- setRevealed(false);- setError(null);- setMode('generate');- }}- className="text-primary-500 hover:text-primary-400 font-medium transition-colors">- {t('mnemonic.createANewWallet')}- </button>- </p>- )}</>)}</>diff --git a/app/src/components/settings/panels/RecoveryPhraseReplaceConfirm.tsx b/app/src/components/settings/panels/RecoveryPhraseReplaceConfirm.tsxindex 1a852b6d0a..0265fb3309 100644--- a/app/src/components/settings/panels/RecoveryPhraseReplaceConfirm.tsx+++ b/app/src/components/settings/panels/RecoveryPhraseReplaceConfirm.tsx@@ -1,7 +1,7 @@import { useT } from '../../../lib/i18n/I18nContext';import { Alert } from '../../ui/Alert';import Button from '../../ui/Button';-import { WarningIcon } from '../../ui/icons';+import { WarningIcon } from '../../ui';export interface RecoveryPhraseReplaceConfirmProps {onConfirm: () => void;diff --git a/app/src/components/settings/panels/RecoveryPhraseViewMode.tsx b/app/src/components/settings/panels/RecoveryPhraseViewMode.tsxindex 68c27db894..75374b5816 100644--- a/app/src/components/settings/panels/RecoveryPhraseViewMode.tsx+++ b/app/src/components/settings/panels/RecoveryPhraseViewMode.tsx@@ -79,10 +79,14 @@ const RecoveryPhraseViewMode = ({}}, [isModalOpen, mnemonic, resetInactivityTimer]);- const handleCopy = (chain: string, address: string) => {- navigator.clipboard.writeText(address).catch(() => {});- setCopiedChain(chain);- setTimeout(() => setCopiedChain(null), 2000);+ const handleCopy = async (chain: string, address: string) => {+ try {+ await navigator.clipboard.writeText(address);+ setCopiedChain(chain);+ setTimeout(() => setCopiedChain(null), 2000);+ } catch {+ // ignore+ }};// Fetch seed phrase on reveal@@ -238,7 +242,7 @@ const RecoveryPhraseViewMode = ({size="md"className="w-full bg-surface dark:bg-white/5 border border-line hover:bg-surface-hover dark:hover:bg-white/10 group transition-all duration-200"><span className="text-content-secondary group-hover:text-content font-semibold transition-colors flex items-center justify-center gap-2">- Replace Wallet+ {t('mnemonic.replaceWallet')}<LuChevronDown className="w-4 h-4" /></span></Button>diff --git a/app/src/components/settings/panels/WalletBalancesPanel.tsx b/app/src/components/settings/panels/WalletBalancesPanel.tsxindex d885a0dfb4..d5dd264e4d 100644--- a/app/src/components/settings/panels/WalletBalancesPanel.tsx+++ b/app/src/components/settings/panels/WalletBalancesPanel.tsx@@ -67,18 +67,18 @@ export const NETWORK_MODAL_ICONS: Record<string, string> = {tron: networkTronIcon,};-export const ChainIcon = ({+export function ChainIcon({chain,evmNetwork,}: {chain: WalletChain;evmNetwork?: EvmNetwork;-}) => {+}) {const key = evmNetwork || chain;const src = CHAIN_ICONS[key];if (!src) return null;return <img src={src} alt="" aria-hidden className="w-10 h-10 shrink-0 object-contain" />;-};+}export const TOKEN_ICONS: Record<string, string> = {ETH: tokenEthIcon,@@ -474,12 +474,13 @@ const WalletBalancesPanel = () => {const selectedNetworkLabel =NETWORK_FILTERS.find(f => f.id === selectedNetwork)?.label ?? 'All networks';- const filterRows = <T extends { chain: WalletChain; evmNetwork?: EvmNetwork }>(rows: T[]) => {+ const filterRows = <T extends { chain: WalletChain; evmNetwork?: EvmNetwork; assetSymbol: string }>(rows: T[]) => {return rows.filter(row => {- const rowId = row.chain === 'evm' ? row.evmNetwork : row.chain;- if (rowId && hiddenTokenKeys.includes(rowId)) return false;+ const networkId = row.chain === 'evm' ? row.evmNetwork : row.chain;+ const bKey = balanceKey(row);+ if (hiddenTokenKeys.includes(bKey)) return false;if (selectedNetwork === 'all') return true;- return rowId === selectedNetwork;+ return networkId === selectedNetwork;});};@@ -630,6 +631,16 @@ const WalletBalancesPanel = () => {}if (balances && balances.length > 0) {+ const visibleRows = filterRows(balances);++ if (visibleRows.length === 0) {+ return (+ <div className="px-4 py-8 text-center">+ <SettingsEmptyState label="No balances match your filters" />+ </div>+ );+ }+return (<Table containerClassName="w-full bg-transparent border border-line rounded-[24px] overflow-hidden"><TableHeader>@@ -648,7 +659,7 @@ const WalletBalancesPanel = () => {</TableRow></TableHeader><TableBody>- {filterRows(balances).map(balance => (+ {visibleRows.map(balance => (<BalanceRowkey={balanceKey(balance)}balance={balance}diff --git a/app/src/components/settings/panels/wallet/ManageTokensModal.tsx b/app/src/components/settings/panels/wallet/ManageTokensModal.tsxindex 6c505e3771..7aa0a2dd70 100644--- a/app/src/components/settings/panels/wallet/ManageTokensModal.tsx+++ b/app/src/components/settings/panels/wallet/ManageTokensModal.tsx@@ -1,7 +1,7 @@import { Dialog as DialogPrimitive } from 'radix-ui';import { useDispatch, useSelector } from 'react-redux';-import { balanceAssetName, formatDisplayBalance } from '../../../../features/wallet/walletDisplay';+import { balanceAssetName, balanceKey, formatDisplayBalance } from '../../../../features/wallet/walletDisplay';import { type EvmNetwork, type WalletChain } from '../../../../services/walletApi';import { type RootState } from '../../../../store';import { toggleTokenHidden } from '../../../../store/walletPreferencesSlice';@@ -25,10 +25,6 @@ export default function ManageTokensModal({ open, onClose, tokens }: ManageToken(state: RootState) => state.walletPreferences?.hiddenTokenKeys || []);- const getTokenKey = (chain: WalletChain, evmNetwork?: EvmNetwork) => {- return chain === 'evm' ? evmNetwork! : chain;- };-return (<DialogPrimitive.Rootopen={open}@@ -62,7 +58,7 @@ export default function ManageTokensModal({ open, onClose, tokens }: ManageToken<div className="flex flex-col py-2 max-h-[60vh] overflow-y-auto">{tokens.map(token => {- const key = getTokenKey(token.chain, token.evmNetwork);+ const key = balanceKey(token);const isHidden = hiddenTokenKeys.includes(key);const isVisible = !isHidden;const assetName = balanceAssetName(token.assetSymbol);diff --git a/app/src/components/settings/panels/wallet/RevealRecoveryModal.tsx b/app/src/components/settings/panels/wallet/RevealRecoveryModal.tsxindex 31699ca49c..58626f6170 100644--- a/app/src/components/settings/panels/wallet/RevealRecoveryModal.tsx+++ b/app/src/components/settings/panels/wallet/RevealRecoveryModal.tsx@@ -16,19 +16,28 @@ export default function RevealRecoveryModal({ open, onClose, mnemonic }: RevealR// Clear sensitive data on unmount/closeuseEffect(() => {+ let timer: ReturnType<typeof setTimeout>;if (!open) {- setTimeout(() => {+ timer = setTimeout(() => {setRevealed(false);}, 300); // delay cleanup slightly for exit animation}+ return () => clearTimeout(timer);}, [open]);+ useEffect(() => {+ let timer: ReturnType<typeof setTimeout>;+ if (copied) {+ timer = setTimeout(() => setCopied(false), 3000);+ }+ return () => clearTimeout(timer);+ }, [copied]);+const handleCopy = useCallback(async () => {if (!mnemonic) return;try {await navigator.clipboard.writeText(mnemonic);setCopied(true);- setTimeout(() => setCopied(false), 3000);} catch {const textarea = document.createElement('textarea');textarea.value = mnemonic;@@ -38,10 +47,7 @@ export default function RevealRecoveryModal({ open, onClose, mnemonic }: RevealRtextarea.select();const ok = document.execCommand('copy');document.body.removeChild(textarea);- if (ok) {- setCopied(true);- setTimeout(() => setCopied(false), 3000);- }+ if (ok) setCopied(true);}}, [mnemonic]);@@ -87,7 +93,8 @@ export default function RevealRecoveryModal({ open, onClose, mnemonic }: RevealR<div className="relative bg-surface-muted rounded-2xl p-2 border border-line overflow-hidden"><divclassName={`grid grid-cols-3 gap-2 transition-all duration-300 ${!revealed ? 'blur-[8px] pointer-events-none select-none opacity-40 scale-[0.98]' : ''}`}- onClick={() => revealed && setRevealed(false)}>+ onClick={() => revealed && setRevealed(false)}+ aria-hidden={!revealed}>{words.map((word, index) => (<divkey={index}diff --git a/app/src/components/settings/panels/wallet/SendCryptoModal.tsx b/app/src/components/settings/panels/wallet/SendCryptoModal.tsxindex ae6ca4e9f6..f212dbb094 100644--- a/app/src/components/settings/panels/wallet/SendCryptoModal.tsx+++ b/app/src/components/settings/panels/wallet/SendCryptoModal.tsx@@ -16,7 +16,7 @@ import {} from '../../../../services/walletApi';import { Alert, AlertDescription } from '../../../ui/Alert';import Button from '../../../ui/Button';-import { CheckIcon, Spinner } from '../../../ui/icons';+import { CheckIcon, Spinner } from '../../../ui';import { InputGroupAddon, InputGroupInput, InputGroupRoot } from '../../../ui/InputGroup';import Label from '../../../ui/Label';import TextField from '../../../ui/TextField';@@ -134,7 +134,7 @@ const SendCryptoModal = ({ balance, onClose, onSuccess }: SendCryptoModalProps)<div className="flex items-center justify-between border-b border-line-subtle px-4 py-4"><div className="w-8" /><DialogPrimitive.Title className="text-sm font-semibold text-content m-0 p-0">- Send+ {t('walletSend.title')}</DialogPrimitive.Title><buttononClick={onClose}@@ -174,7 +174,7 @@ const SendCryptoModal = ({ balance, onClose, onSuccess }: SendCryptoModalProps)<LabelhtmlFor="send-recipient-input"className="text-content-muted font-normal ml-1">- To+ {t('walletSend.to')}</Label><TextFieldid="send-recipient-input"@@ -192,17 +192,19 @@ const SendCryptoModal = ({ balance, onClose, onSuccess }: SendCryptoModalProps)<div className="flex flex-col gap-1.5"><div className="flex items-center justify-between ml-1 mb-0.5"><Label htmlFor="send-amount-input" className="text-content-muted font-normal">- Amount+ {t('walletSend.amount')}</Label><div className="flex items-center gap-2 text-xs"><span className="text-content-muted">- {formatDisplayBalance(balance.formatted)} {balance.assetSymbol} available+ {t('walletSend.availableBalance')+ .replace('{{amount}}', formatDisplayBalance(balance.formatted))+ .replace('{{symbol}}', balance.assetSymbol)}</span><buttontype="button"onClick={() => setAmount(balance.formatted)}className="text-primary-500 font-medium hover:text-primary-600 transition-colors">- Max+ {t('walletSend.max')}</button></div></div>diff --git a/app/src/features/wallet/walletDisplay.ts b/app/src/features/wallet/walletDisplay.tsindex 48aa97dc21..c825a85938 100644--- a/app/src/features/wallet/walletDisplay.ts+++ b/app/src/features/wallet/walletDisplay.ts@@ -87,44 +87,118 @@ export function balanceAssetName(assetSymbol: string): string {* catch them and surface a translated, user-facing message via `useT()` —* never render `error.message` from here directly.*/-export function toSmallestUnit(human: string, decimals: number): string {- const trimmed = human.trim();- if (trimmed === '' || trimmed === '.' || !/^\d*\.?\d*$/.test(trimmed)) {+export function toSmallestUnit(human: string | number, decimals: number): string {+ let humanStr = String(human).trim();+ if (humanStr === '' || humanStr === '.') throw new Error('invalid_amount');++ // Convert scientific notation to plain decimal string to avoid BigInt parsing errors+ if (humanStr.includes('e') || humanStr.includes('E')) {+ const num = Number(humanStr);+ if (isNaN(num)) throw new Error('invalid_amount');+ // Using BigInt on the number gets the exact integer if it's large without fraction+ // But human inputs are usually not scientific notation unless auto-filled.+ // A robust way for scientific notation in JS:+ const [lead, exp] = humanStr.toLowerCase().split('e');+ const expNum = parseInt(exp, 10);+ // basic expansion (this is a simplified fallback)+ if (expNum > 0) {+ const [w, f = ''] = lead.split('.');+ const missingZeros = expNum - f.length;+ if (missingZeros >= 0) {+ humanStr = w + f + '0'.repeat(missingZeros);+ } else {+ humanStr = w + f.slice(0, expNum) + '.' + f.slice(expNum);+ }+ }+ }++ if (!/^\d*\.?\d*$/.test(humanStr)) {throw new Error('invalid_amount');}- const [whole, frac = ''] = trimmed.split('.');++ const [whole, frac = ''] = humanStr.split('.');if (frac.length > decimals) {throw new Error('too_many_decimals');}- const combined = `${whole || '0'}${frac.padEnd(decimals, '0')}`;- const normalized = combined.replace(/^0+(?=\d)/, '');- return normalized === '' ? '0' : normalized;++ try {+ const wholeBig = BigInt(whole || '0');+ const multiplier = 10n ** BigInt(decimals);+ let fracBig = 0n;+ if (frac.length > 0) {+ const paddedFrac = frac.padEnd(decimals, '0');+ fracBig = BigInt(paddedFrac);+ }+ const combined = wholeBig * multiplier + fracBig;+ return combined.toString();+ } catch {+ throw new Error('invalid_amount');+ }}/*** Format a smallest-unit decimal string back to a human amount, trimming* trailing fractional zeros. Inverse of {@link toSmallestUnit}.*/-export function fromSmallestUnit(raw: string, decimals: number): string {- if (!/^\d+$/.test(raw)) return raw;- if (decimals === 0) return raw;- const padded = raw.padStart(decimals + 1, '0');- const whole = padded.slice(0, padded.length - decimals);- const frac = padded.slice(padded.length - decimals).replace(/0+$/, '');- return frac.length > 0 ? `${whole}.${frac}` : whole;+export function fromSmallestUnit(raw: string | number | bigint, decimals: number): string {+ let value: bigint;+ try {+ if (typeof raw === 'number' || (typeof raw === 'string' && raw.toString().toLowerCase().includes('e'))) {+ value = BigInt(Math.floor(Number(raw)));+ } else {+ value = BigInt(raw);+ }+ } catch {+ return String(raw);+ }++ if (decimals === 0) return value.toString();++ const divisor = 10n ** BigInt(decimals);+ const whole = value / divisor;+ const frac = value % divisor;++ if (frac === 0n) return whole.toString();++ const fracStr = frac.toString().padStart(decimals, '0').replace(/0+$/, '');+ return `${whole.toString()}.${fracStr}`;}/*** Formats balance to 8 decimal places e.g. 1.00000000.* Balances below 0.00000001 display as <0.00000001.*/-export function formatDisplayBalance(formatted: string): string {- const num = parseFloat(formatted);- if (isNaN(num) || num === 0) return '0';+export function formatDisplayBalance(formatted: string | number): string {+ const str = String(formatted).trim();+ if (!str || str === 'NaN' || str === '0') return '0';++ // Handle scientific notation for small numbers (e.g. from Number.toString) if any+ let normalized = str;+ if (normalized.toLowerCase().includes('e')) {+ try {+ normalized = Number(normalized).toFixed(20).replace(/0+$/, '').replace(/\.$/, '');+ } catch {+ return str;+ }+ }++ // Handle very small numbers without scientific notation+ if (normalized.startsWith('0.') && normalized !== '0.0') {+ const fracPart = normalized.split('.')[1] || '';+ if (fracPart.length >= 8 && /^0{7,}/.test(fracPart)) {+ // if it's less than 0.00000001+ const num = Number(normalized);+ if (num > 0 && num < 0.00000001) {+ return '<0.00000001';+ }+ }+ }++ const [whole = '0', frac = ''] = normalized.split('.');- if (num < 0.00000001) {- return '<0.00000001';+ if (!frac) {+ return `${whole}.00000000`;}- return num.toFixed(8);+ return `${whole}.${frac.slice(0, 8).padEnd(8, '0')}`;}diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.tsindex a52c42cefa..850bb303bd 100644--- a/app/src/lib/i18n/en.ts+++ b/app/src/lib/i18n/en.ts@@ -6512,7 +6512,13 @@ const en: TranslationMap = {'walletReceive.onlyChainWarning':'Only send {network} assets to this address. Sending assets from another network may result in permanent loss.',// Send modal+ 'walletSend.title': 'Send',+ 'walletSend.to': 'To',+ 'walletSend.addressPlaceholder': 'Enter or paste an address',+ 'walletSend.max': 'Max','walletSend.available': 'Available',+ 'walletSend.availableBalance': '{{amount}} {{symbol}} available',+ 'walletSend.amountWithSymbol': '{{amount}} {{symbol}}','walletSend.recipient': 'Recipient address','walletSend.recipientPlaceholder': 'Paste the destination address','walletSend.recipientRequired': 'Enter a recipient address',