Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ui): correct wallet balance display and sync audit panel

Steven Enamakel9b8b9680ce91
diff --git a/app/src/components/intelligence/SyncAuditPanel.tsx b/app/src/components/intelligence/SyncAuditPanel.tsx
index b0a900953c..e92c282cdd 100644
--- a/app/src/components/intelligence/SyncAuditPanel.tsx
+++ b/app/src/components/intelligence/SyncAuditPanel.tsx
@@ -198,7 +198,11 @@ export function SyncAuditPanel() {
}, [anySyncing, reload]);
const statusOf = (e: SyncAuditEntry): SyncStatus =>
- e.success ? 'success' : (e.tree_ingest_failures ?? 0) > 0 || e.tree_error ? 'partial' : 'failed';
+ e.success
+ ? 'success'
+ : (e.tree_ingest_failures ?? 0) > 0 || e.tree_error
+ ? 'partial'
+ : 'failed';
const sourceName = (e: SyncAuditEntry) => labels[e.source_id] ?? scopeLabel(e.scope);
const needle = query.trim().toLowerCase();
diff --git a/app/src/components/settings/panels/WalletBalancesPanel.tsx b/app/src/components/settings/panels/WalletBalancesPanel.tsx
index 5299dcc48e..e0632d3e71 100644
--- a/app/src/components/settings/panels/WalletBalancesPanel.tsx
+++ b/app/src/components/settings/panels/WalletBalancesPanel.tsx
@@ -1,3 +1,4 @@
+import { ArrowDown, ArrowUp, Check, Copy, Globe, RefreshCw, Settings2 } from 'lucide-react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useSelector } from 'react-redux';
@@ -11,7 +12,6 @@ import {
// ---------------------------------------------------------------------------
import { useUser } from '../../../hooks/useUser';
-import { cn } from '../../../lib/cn';
import { useT } from '../../../lib/i18n/I18nContext';
import {
type BalanceInfo,
@@ -25,8 +25,9 @@ import { Alert, AlertDescription } from '../../ui/Alert';
import Badge from '../../ui/Badge';
import Button from '../../ui/Button';
import Card from '../../ui/Card';
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../../ui/Table';
-import { SettingsEmptyState } from '../controls';
+import DataTable, { type DataTableColumn } from '../../ui/DataTable';
+import EmptyState from '../../ui/EmptyState';
+import { TableCell, TableRow } from '../../ui/Table';
import { useSettingsNavigation } from '../hooks/useSettingsNavigation';
import SettingsPanel from '../layout/SettingsPanel';
import { ChainIcon, NETWORK_MODAL_ICONS, TOKEN_ICONS } from './wallet/chainIcons';
@@ -76,11 +77,21 @@ function truncateAddress(address: string): string {
* its own copy button, its own clipboard state and its own action pair), and
* the columns exist to define the header and the alignment.
*/
-const COLUMNS_FOR = (t: (key: string) => string) => [
- { id: 'network', header: t('walletBalances.colToken') },
- { id: 'address', header: t('walletBalances.colAddress') },
- { id: 'balance', header: t('walletBalances.colBalance'), align: 'right', className: 'pr-4' },
- { id: 'actions', header: t('walletBalances.colActions') },
+const COLUMNS_FOR = (t: (key: string) => string): DataTableColumn<BalanceInfo>[] => [
+ { id: 'network', header: t('walletBalances.colToken'), className: 'whitespace-nowrap' },
+ { id: 'address', header: t('walletBalances.colAddress'), className: 'w-full max-w-0' },
+ {
+ id: 'balance',
+ header: t('walletBalances.colBalance'),
+ align: 'right',
+ className: 'w-px whitespace-nowrap',
+ },
+ {
+ id: 'actions',
+ header: t('walletBalances.colActions'),
+ align: 'right',
+ className: 'w-px whitespace-nowrap',
+ },
];
// ---------------------------------------------------------------------------
@@ -131,10 +142,8 @@ const BalanceRow = ({ balance, onSend, onReceive }: BalanceRowProps) => {
const networkLabel = balanceNetworkLabel(balance);
return (
- <TableRow
- data-testid={`wallet-row-${balanceKey(balance)}`}
- className="hover:bg-surface-muted group">
- <TableCell className="whitespace-nowrap px-4">
+ <TableRow data-testid={`wallet-row-${balanceKey(balance)}`} className="group">
+ <TableCell className="whitespace-nowrap">
<div className="flex items-center gap-3">
<ChainIcon chain={balance.chain} evmNetwork={balance.evmNetwork} />
<div className="flex flex-col">
@@ -146,10 +155,10 @@ const BalanceRow = ({ balance, onSend, onReceive }: BalanceRowProps) => {
)}
</div>
</TableCell>
- <TableCell>
+ <TableCell className="w-full max-w-0">
{/* Address + copy button */}
- <div className="flex items-center justify-start gap-1.5 min-w-0">
- <span className="font-mono text-[12px] text-content-muted truncate">
+ <div className="flex min-w-0 items-center justify-start gap-1.5">
+ <span className="truncate font-mono text-xs text-content-muted" title={balance.address}>
{truncateAddress(balance.address)}
</span>
<Button
@@ -161,32 +170,14 @@ const BalanceRow = ({ balance, onSend, onReceive }: BalanceRowProps) => {
aria-label={t('walletBalances.copyAddress')}
className="shrink-0 text-content-faint hover:text-content-secondary dark:hover:text-content-secondary">
{copied ? (
- <svg
- className="w-3.5 h-3.5 text-sage-500"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2.5}>
- <path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
- </svg>
+ <Check className="h-3.5 w-3.5 text-sage-500" aria-hidden />
) : (
- <svg
- className="w-3.5 h-3.5"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
- />
- </svg>
+ <Copy className="h-3.5 w-3.5" aria-hidden />
)}
</Button>
</div>
</TableCell>
- <TableCell className="whitespace-nowrap text-right pr-4">
+ <TableCell className="w-px whitespace-nowrap text-right">
<div className="flex items-center justify-end gap-1.5">
<span
title={t('walletBalances.rawBalance').replace('{raw}', balance.raw)}
@@ -205,27 +196,16 @@ const BalanceRow = ({ balance, onSend, onReceive }: BalanceRowProps) => {
)}
</div>
</TableCell>
- <TableCell className="w-px whitespace-nowrap text-left">
- <div className="flex justify-start gap-2">
+ <TableCell className="w-px whitespace-nowrap text-right">
+ <div className="flex justify-end gap-2">
<Button
type="button"
variant="secondary"
size="sm"
onClick={() => onSend(balance)}
data-testid={`wallet-send-${balanceKey(balance)}`}
- aria-label={t('walletBalances.send')}>
- <svg
- className="h-3.5 w-3.5"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2.5}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18"
- />
- </svg>
+ aria-label={t('walletBalances.send')}
+ leadingIcon={<ArrowUp className="h-3.5 w-3.5" aria-hidden />}>
{t('walletBalances.send')}
</Button>
<Button
@@ -234,19 +214,8 @@ const BalanceRow = ({ balance, onSend, onReceive }: BalanceRowProps) => {
size="sm"
onClick={() => onReceive(balance)}
data-testid={`wallet-receive-${balanceKey(balance)}`}
- aria-label={t('walletBalances.receive')}>
- <svg
- className="h-3.5 w-3.5"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2.5}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3"
- />
- </svg>
+ aria-label={t('walletBalances.receive')}
+ leadingIcon={<ArrowDown className="h-3.5 w-3.5" aria-hidden />}>
{t('walletBalances.receive')}
</Button>
</div>
@@ -409,48 +378,60 @@ const WalletBalancesPanel = () => {
});
};
- const renderContent = () => {
- if (loading) {
- return (
- <div className="flex items-center justify-center gap-2 py-10 text-content-muted">
- <svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
- <circle
- className="opacity-25"
- cx="12"
- cy="12"
- r="10"
- stroke="currentColor"
- strokeWidth="4"
- />
- <path
- className="opacity-75"
- fill="currentColor"
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
- />
- </svg>
- <span className="text-sm">{t('walletBalances.loading')}</span>
- </div>
- );
- }
-
- if (error) {
- return (
- <div className="space-y-3">
- <Alert variant="destructive">
- <AlertDescription>{t('walletBalances.errorGeneric')}</AlertDescription>
- </Alert>
- <Button type="button" variant="secondary" onClick={() => void loadBalances()}>
- {t('walletBalances.retry')}
- </Button>
- </div>
- );
- }
+ const [query, setQuery] = useState('');
+ const needle = query.trim().toLowerCase();
+ const matchesQuery = (row: BalanceInfo) =>
+ !needle ||
+ row.assetSymbol.toLowerCase().includes(needle) ||
+ balanceNetworkLabel(row).toLowerCase().includes(needle) ||
+ row.address.toLowerCase().includes(needle);
+
+ const refreshButton = (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ onClick={() => void loadBalances()}
+ disabled={loading || isRefreshing}
+ leadingIcon={
+ <RefreshCw
+ className={loading || isRefreshing ? 'h-3.5 w-3.5 animate-spin' : 'h-3.5 w-3.5'}
+ aria-hidden
+ />
+ }>
+ {t('walletBalances.refresh')}
+ </Button>
+ );
+ const manageButton = (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ onClick={() => setIsManageModalOpen(true)}
+ aria-label={t('walletBalances.manageTokens')}
+ leadingIcon={<Settings2 className="h-3.5 w-3.5" aria-hidden />}>
+ {t('walletBalances.manageTokens')}
+ </Button>
+ );
+ const networkButton = (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ onClick={() => setIsNetworkModalOpen(true)}
+ aria-label={selectedNetworkLabel}
+ leadingIcon={<Globe className="h-3.5 w-3.5" aria-hidden />}
+ className="shrink-0">
+ {selectedNetworkLabel}
+ </Button>
+ );
- // A setup notice and network cards make it clear that these are supported
- // networks, not balances or addresses belonging to an unconfigured wallet.
- if (walletConfigured === false) {
+ const renderContent = () => {
+ // Not set up: a setup notice and network cards make it clear these are
+ // supported networks, not balances or addresses of an unconfigured wallet.
+ if (!loading && !error && walletConfigured === false) {
return (
- <div className="space-y-4">
+ <div className="space-y-4 overflow-y-auto">
<Alert variant="warning" role="status" className="flex-wrap items-center justify-between">
<AlertDescription>{t('walletBalances.setupHint')}</AlertDescription>
<Button type="button" size="sm" onClick={() => navigateToSettings('recovery-phrase')}>
@@ -471,183 +452,97 @@ const WalletBalancesPanel = () => {
);
}
- if (balances !== null && balances.length === 0) {
- return (
- <div className="px-4 py-8 text-center">
- <div className="w-12 h-12 rounded-full bg-surface-subtle flex items-center justify-center mx-auto mb-3">
- <svg
- className="w-6 h-6 text-content-faint"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={1.5}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18-3a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6m18 0V5.25A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25V6"
- />
- </svg>
- </div>
- <SettingsEmptyState label={t('walletBalances.emptyState')} />
- </div>
- );
- }
-
- if (balances && balances.length > 0) {
- const visibleRows = filterRows(balances);
-
- if (visibleRows.length === 0) {
- return (
- <Card padded divided={false}>
- <SettingsEmptyState label={t('walletBalances.noFilterMatches')} />
- </Card>
- );
- }
-
- return (
- <Table containerClassName="w-full overflow-x-auto rounded-xl border border-line bg-surface">
- <TableHeader>
- <TableRow className="hover:bg-transparent">
- {COLUMNS_FOR(t).map(col => (
- <TableHead
- key={col.id}
- className={cn(
- col.align === 'right' && 'text-right',
- 'text-content font-medium',
- col.className
- )}>
- <span className="pb-1">{col.header}</span>
- </TableHead>
- ))}
- </TableRow>
- </TableHeader>
- <TableBody>
- {visibleRows.map(balance => (
- <BalanceRow
- key={balanceKey(balance)}
- balance={balance}
- onSend={setSendTarget}
- onReceive={setReceiveTarget}
- />
- ))}
- </TableBody>
- </Table>
- );
- }
-
- return null;
- };
-
- const rowsToRender = walletConfigured === false ? PLACEHOLDER_ROWS : balances || [];
- return (
- <SettingsPanel
- bodyClassName="space-y-4"
- title={
- <div className="flex items-center gap-2.5">
- <svg
- className="w-5 h-5 text-content"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18-3a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6m18 0V5.25A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25V6"
- />
- </svg>
- {t('pages.settings.account.walletBalances')}
- </div>
- }
- description={t('pages.settings.account.walletBalancesDesc')}>
- <div className="w-full max-w-5xl space-y-4">
- <Card padded divided={false}>
- <div className="flex flex-wrap items-center justify-between gap-3">
- <Button
- type="button"
- variant="secondary"
- size="sm"
- onClick={() => setIsNetworkModalOpen(true)}
- aria-label={selectedNetworkLabel}>
- <svg
- className="w-4 h-4 text-content-muted"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor">
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
- />
- </svg>
- {selectedNetworkLabel}
- </Button>
- <SelectNetworkModal
- open={isNetworkModalOpen}
- onClose={() => setIsNetworkModalOpen(false)}
- selectedNetwork={selectedNetwork}
- onSelect={setSelectedNetwork}
- networkFilters={NETWORK_FILTERS.map(filter =>
- filter.id === 'all' ? { ...filter, label: t('walletBalances.allNetworks') } : filter
- )}
- chainIcons={NETWORK_MODAL_ICONS}
- />
- <div className="flex flex-wrap items-center gap-2">
+ const allRows = balances ?? [];
+ const visibleRows = filterRows(allRows).filter(matchesQuery);
+
+ return (
+ <DataTable<BalanceInfo>
+ testId="wallet-balances-table"
+ title={t('walletBalances.tableTitle')}
+ description={t('pages.settings.account.walletBalancesDesc')}
+ actions={
+ <>
+ {refreshButton}
+ {manageButton}
+ </>
+ }
+ toolbarStart={networkButton}
+ search={{
+ value: query,
+ onChange: setQuery,
+ placeholder: t('walletBalances.searchPlaceholder'),
+ testId: 'wallet-balances-search',
+ }}
+ columns={COLUMNS_FOR(t)}
+ rows={error ? [] : visibleRows}
+ rowKey={balance => balanceKey(balance)}
+ renderRow={balance => (
+ <BalanceRow
+ key={balanceKey(balance)}
+ balance={balance}
+ onSend={setSendTarget}
+ onReceive={setReceiveTarget}
+ />
+ )}
+ pagination={{ pageSize: 25 }}
+ loading={loading}
+ loadingLabel={t('walletBalances.loading')}
+ loadingRows={4}
+ error={
+ error ? (
+ <Alert variant="destructive" density="compact" className="items-center justify-between">
+ <AlertDescription>{t('walletBalances.errorGeneric')}</AlertDescription>
<Button
type="button"
variant="secondary"
size="sm"
- onClick={() => void loadBalances()}
- disabled={loading || isRefreshing}>
- <svg
- className={cn(
- 'w-4 h-4 text-content-muted',
- (loading || isRefreshing) && 'animate-spin'
- )}
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2.5}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
- />
- </svg>
- {t('walletBalances.refresh')}
+ onClick={() => void loadBalances()}>
+ {t('walletBalances.retry')}
</Button>
+ </Alert>
+ ) : undefined
+ }
+ empty={
+ error ? null : (
+ <EmptyState
+ label={
+ allRows.length === 0
+ ? t('walletBalances.emptyState')
+ : t('walletBalances.noFilterMatches')
+ }
+ />
+ )
+ }
+ ariaLabel={t('walletBalances.tableTitle')}
+ />
+ );
+ };
- <Button
- type="button"
- variant="secondary"
- size="sm"
- onClick={() => setIsManageModalOpen(true)}
- aria-label={t('walletBalances.manageTokens')}>
- <svg
- className="w-4 h-4 text-content-muted"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth={2.5}>
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
- />
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
- />
- </svg>
- {t('walletBalances.manageTokens')}
- </Button>
- </div>
- </div>
- </Card>
- {renderContent()}
- </div>
+ const rowsToRender = walletConfigured === false ? PLACEHOLDER_ROWS : balances || [];
+ return (
+ // The balances table is the page's main content: it fills the height and
+ // only its rows scroll.
+ <SettingsPanel
+ bodyClassName="flex min-h-0 flex-col gap-4"
+ description={t('pages.settings.account.walletBalancesDesc')}>
+ {walletConfigured === false && !loading && !error && (
+ <div className="flex shrink-0 flex-wrap items-center justify-end gap-2">
+ {networkButton}
+ {refreshButton}
+ {manageButton}
+ </div>
+ )}
+ <SelectNetworkModal
+ open={isNetworkModalOpen}
+ onClose={() => setIsNetworkModalOpen(false)}
+ selectedNetwork={selectedNetwork}
+ onSelect={setSelectedNetwork}
+ networkFilters={NETWORK_FILTERS.map(filter =>
+ filter.id === 'all' ? { ...filter, label: t('walletBalances.allNetworks') } : filter
+ )}
+ chainIcons={NETWORK_MODAL_ICONS}
+ />
+ {renderContent()}
{sendTarget && (
<SendCryptoModal
diff --git a/app/src/components/settings/panels/WalletPanel.tsx b/app/src/components/settings/panels/WalletPanel.tsx
index 9c474c4b0a..33b31510c1 100644
--- a/app/src/components/settings/panels/WalletPanel.tsx
+++ b/app/src/components/settings/panels/WalletPanel.tsx
@@ -29,12 +29,23 @@ export default function WalletPanel() {
value={tab}
onChange={setTab}
tabsAriaLabel={t('wallet.ariaLabel')}
- tabsTestIdPrefix="wallet">
- <div className="min-h-0 space-y-4" data-testid="wallet-panel">
- <Alert variant="warning" role={undefined} className="max-w-5xl">
+ tabsTestIdPrefix="wallet"
+ // Balances is a fill-height table (only its rows scroll); Recovery is a
+ // normal scrolling form.
+ scrollable={tab !== 'balance'}>
+ <div
+ className={tab === 'balance' ? 'flex h-full min-h-0 flex-col gap-4' : 'space-y-4'}
+ data-testid="wallet-panel">
+ <Alert variant="warning" role={undefined} className="shrink-0">
<AlertDescription>{t('walletBalances.earlyAlphaNotice')}</AlertDescription>
</Alert>
- {tab === 'balance' ? <WalletBalancesPanel /> : <RecoveryPhrasePanel />}
+ {tab === 'balance' ? (
+ <div className="min-h-0 flex-1">
+ <WalletBalancesPanel />
+ </div>
+ ) : (
+ <RecoveryPhrasePanel />
+ )}
</div>
</SettingsTabbedPage>
);
diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.ts
index 9d12053273..ea2284be3f 100644
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@ -7097,6 +7097,8 @@ const en: TranslationMap = {
'wallet.tabs.recovery': 'Recovery',
'wallet.ariaLabel': 'Wallet views',
// WalletBalancesPanel strings
+ 'walletBalances.tableTitle': 'Balances',
+ 'walletBalances.searchPlaceholder': 'Search token, network or address…',
'walletBalances.title': 'Wallet Balances',
'walletBalances.earlyAlphaNotice':
'Early Alpha: Wallet balances are still being tested. Amounts and network support may change between releases.',
diff --git a/app/src/pages/WorkflowRunsPage.tsx b/app/src/pages/WorkflowRunsPage.tsx
index 088c8d5783..5d84b57675 100644
--- a/app/src/pages/WorkflowRunsPage.tsx
+++ b/app/src/pages/WorkflowRunsPage.tsx
@@ -6,12 +6,14 @@
* lightweight silent refresh (re-fetches just the runs, not `listFlows()` too)
* so a run doesn't sit on "Running" until the user reloads the page.
*/
-import { useCallback, useEffect, useState } from 'react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { FlowRunStatus } from '../components/flows/FlowRunStatus';
import SettingsTabbedPage from '../components/settings/layout/SettingsTabbedPage';
-import { CenteredLoadingState, ErrorBanner } from '../components/ui/LoadingState';
+import DataTable, { type DataTableColumn } from '../components/ui/DataTable';
+import { ErrorBanner } from '../components/ui/LoadingState';
+import { TableCell, TableRow } from '../components/ui/Table';
import { useFlowRunFinished } from '../hooks/useFlowRunFinished';
import { useFlowRunsLiveRefresh } from '../hooks/useFlowRunsLiveRefresh';
import { useFlowRunsQuery } from '../hooks/useFlowRunsQuery';
@@ -20,13 +22,47 @@ import {
resolveDisplayStatus,
useRunsPendingApprovalSet,
} from '../hooks/useRunsPendingApprovalSet';
+import { cn } from '../lib/cn';
import { useT } from '../lib/i18n/I18nContext';
import {
type Flow,
+ type FlowRun,
type FlowRunStatus as FlowRunStatusValue,
listFlows,
} from '../services/api/flowsApi';
+interface RunRow {
+ run: FlowRun;
+ displayStatus: FlowRunStatusValue;
+ name: string;
+}
+
+/** Date over time, in the user's locale; raw value when unparseable. */
+const DateTimeCell = ({ value }: { value: string }) => {
+ const ts = Date.parse(value);
+ if (Number.isNaN(ts)) return <span>{value}</span>;
+ const date = new Date(ts);
+ return (
+ <span className="flex flex-col leading-tight" title={date.toLocaleString()}>
+ <span className="text-content">{date.toLocaleDateString()}</span>
+ <span className="text-xs text-content-muted">{date.toLocaleTimeString()}</span>
+ </span>
+ );
+};
+
+/** Compact run duration ("850ms", "12s", "3m 04s", "1h 02m"); "—" while running. */
+function formatDuration(startedAt: string, finishedAt?: string | null): string {
+ if (!finishedAt) return '—';
+ const ms = Date.parse(finishedAt) - Date.parse(startedAt);
+ if (!Number.isFinite(ms) || ms < 0) return '—';
+ if (ms < 1000) return `${ms}ms`;
+ const secs = Math.round(ms / 1000);
+ if (secs < 60) return `${secs}s`;
+ const mins = Math.floor(secs / 60);
+ if (mins < 60) return `${mins}m ${String(secs % 60).padStart(2, '0')}s`;
+ return `${Math.floor(mins / 60)}h ${String(mins % 60).padStart(2, '0')}m`;
+}
+
export default function WorkflowRunsPage() {
const { t } = useT();
const navigate = useNavigate();
@@ -78,59 +114,149 @@ export default function WorkflowRunsPage() {
const statusLabel = (status: FlowRunStatusValue) =>
t(`flows.allRuns.status.${status}`, status.replace(/_/g, ' '));
+ const [query, setQuery] = useState('');
+ const [selectedStatus, setSelectedStatus] = useState<ReadonlySet<string>>(new Set());
+
+ const rows = useMemo(
+ () =>
+ runs.map(run => ({
+ run,
+ displayStatus: resolveDisplayStatus(run, pendingRunIds),
+ name: flowNames[run.flow_id] ?? t('flows.allRuns.unknownWorkflow'),
+ })),
+ [runs, pendingRunIds, flowNames, t]
+ );
+
+ const statusOptions = useMemo(
+ () => Array.from(new Set(rows.map(row => row.displayStatus))),
+ [rows]
+ );
+
+ const filteredRows = useMemo(() => {
+ const needle = query.trim().toLowerCase();
+ return rows.filter(row => {
+ if (selectedStatus.size > 0 && !selectedStatus.has(row.displayStatus)) return false;
+ if (!needle) return true;
+ return (
+ row.name.toLowerCase().includes(needle) || (row.run.error ?? '').toLowerCase().includes(needle)
+ );
+ });
+ }, [rows, query, selectedStatus]);
+
+ const openRun = (row: RunRow) => navigate(`/flows/${row.run.flow_id}`);
+
+ const columns: DataTableColumn<RunRow>[] = [
+ {
+ // Status first: the row's first `span` is the status chip.
+ id: 'status',
+ header: t('flows.allRuns.columnStatus'),
+ className: 'w-px whitespace-nowrap',
+ cell: row => (
+ <FlowRunStatus status={row.displayStatus} label={statusLabel(row.displayStatus)} />
+ ),
+ },
+ {
+ id: 'workflow',
+ header: t('flows.allRuns.columnWorkflow'),
+ className: 'w-full max-w-0',
+ cell: row => (
+ <div className="min-w-0">
+ <p className="truncate font-medium text-content" title={row.name}>
+ {row.name}
+ </p>
+ {row.run.error && (
+ <p
+ className="truncate text-xs text-coral-600 dark:text-coral-300"
+ title={row.run.error}>
+ {row.run.error}
+ </p>
+ )}
+ </div>
+ ),
+ },
+ {
+ id: 'started',
+ header: t('flows.allRuns.columnStarted'),
+ className: 'w-px whitespace-nowrap tabular-nums',
+ cell: row => <DateTimeCell value={row.run.started_at} />,
+ },
+ {
+ id: 'duration',
+ header: t('flows.allRuns.columnDuration'),
+ align: 'right',
+ className: 'w-px whitespace-nowrap tabular-nums text-content-muted',
+ cell: row => formatDuration(row.run.started_at, row.run.finished_at),
+ },
+ ];
+
return (
<div className="h-full p-4" data-testid="workflow-runs-page">
<SettingsTabbedPage
title={t('flows.allRuns.title')}
- description={t('flows.allRuns.description')}>
- {/* No wrapper padding: `SettingsTabbedPage`'s body already renders
- `min-h-full pb-4 pt-4`, so a `pt-4` here double-pads the top. */}
- <div>
- {pageLoading ? (
- <CenteredLoadingState label={t('flows.allRuns.loading')} />
- ) : pageError ? (
- <ErrorBanner message={pageError} />
- ) : runs.length === 0 ? (
- <p
- className="py-8 text-center text-sm text-content-muted"
- data-testid="workflow-runs-empty">
- {t('flows.allRuns.empty')}
- </p>
- ) : (
- <ul
- className="divide-y divide-line overflow-hidden rounded-2xl border border-line bg-surface"
- data-testid="workflow-runs-list">
- {runs.map(run => {
- const displayStatus = resolveDisplayStatus(run, pendingRunIds);
- return (
- <li key={run.id}>
- <button
- type="button"
- data-testid={`workflow-run-${run.id}`}
- onClick={() => navigate(`/flows/${run.flow_id}`)}
- className="flex w-full items-center gap-3 p-3 text-left hover:bg-surface-hover">
- <FlowRunStatus
- status={displayStatus}
- label={statusLabel(displayStatus)}
- className="shrink-0 text-[11px]"
- />
- <span className="min-w-0 flex-1 truncate text-sm font-medium text-content">
- {flowNames[run.flow_id] ?? t('flows.allRuns.unknownWorkflow')}
- </span>
- <span className="shrink-0 text-[11px] text-content-faint">
- {new Date(run.started_at).toLocaleString()}
- </span>
- </button>
- {run.error && (
- <p className="px-3 pb-2 text-[11px] text-coral-600 dark:text-coral-300">
- {run.error}
- </p>
- )}
- </li>
- );
- })}
- </ul>
- )}
+ description={t('flows.allRuns.description')}
+ scrollable={false}>
+ {/* Bounded flex column: the runs table fills it and only its rows
+ scroll, never the page. */}
+ <div className="flex h-full min-h-0 flex-col">
+ <DataTable<RunRow>
+ title={t('flows.allRuns.tableTitle')}
+ description={t('flows.allRuns.tableDesc')}
+ columns={columns}
+ rows={filteredRows}
+ rowKey={row => row.run.id}
+ renderRow={row => (
+ <TableRow
+ key={row.run.id}
+ data-testid={`workflow-run-${row.run.id}`}
+ role="link"
+ tabIndex={0}
+ onClick={() => openRun(row)}
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault();
+ openRun(row);
+ }
+ }}
+ className="cursor-pointer focus-visible:bg-surface-hover focus-visible:outline-hidden">
+ {columns.map(column => (
+ <TableCell
+ key={column.id}
+ className={cn(column.align === 'right' && 'text-right', column.className)}>
+ {column.cell?.(row)}
+ </TableCell>
+ ))}
+ </TableRow>
+ )}
+ search={{
+ value: query,
+ onChange: setQuery,
+ placeholder: t('flows.allRuns.searchPlaceholder'),
+ testId: 'workflow-runs-search',
+ }}
+ filters={[
+ {
+ id: 'status',
+ label: t('flows.allRuns.columnStatus'),
+ options: statusOptions.map(status => ({ value: status, label: statusLabel(status) })),
+ selected: selectedStatus,
+ onChange: setSelectedStatus,
+ testId: 'workflow-runs-status-filter',
+ },
+ ]}
+ pagination={{ pageSize: 25, testId: 'workflow-runs-pagination' }}
+ loading={pageLoading}
+ loadingLabel={t('flows.allRuns.loading')}
+ error={pageError ? <ErrorBanner message={pageError} /> : undefined}
+ empty={
+ pageError ? undefined : rows.length === 0 ? (
+ <p className="text-sm text-content-muted" data-testid="workflow-runs-empty">
+ {t('flows.allRuns.empty')}
+ </p>
+ ) : undefined
+ }
+ ariaLabel={t('flows.allRuns.title')}
+ testId={filteredRows.length > 0 ? 'workflow-runs-list' : undefined}
+ />
</div>
</SettingsTabbedPage>
</div>