feat(ui): show per-inbound live speed (#5261)

* feat(utils): add speedFormat utility and tests

* feat(inbounds): add InboundSpeedEntry type

* feat(inbounds): add speed column to inbound list

* feat(inbounds): show speed in inbound stats modal

* feat(inbounds): compute inbound speed from traffic deltas

* feat(inbounds): wire inbound speed through page

* feat(i18n): add speed translation for all locales

* refactor(inbounds): dedupe live-speed UI and harden formatting

Extract a shared InboundSpeedTag component and isActiveSpeed guard used by the speed column and stats modal, unify InboundSpeedEntry into a single type, and route speedFormat through sizeFormat.

Also guard sizeFormat against non-finite input (no more "NaN PB/s") and clear stale per-inbound speeds when a traffic poll returns no deltas.

---------

Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Nikan ZeyaeiandSanaei authored and GitHub committed 2026-06-14 22:39:40 +02:00 Unverified
1 parent 1c75034957
commit f4bbaf40f0
22 files changed
+198 -5

No files matched your search

@@ -82,6 +82,7 @@ export default function InboundsPage() {
clientCount,
onlineClients,
lastOnlineMap,
inboundSpeed,
totals,
expireDiff,
trafficDiff,
@@ -620,6 +621,7 @@ export default function InboundsPage() {
clientCount={clientCount}
onlineClients={onlineClients}
lastOnlineMap={lastOnlineMap}
inboundSpeed={inboundSpeed}
expireDiff={expireDiff}
trafficDiff={trafficDiff}
pageSize={pageSize}
@@ -36,6 +36,7 @@ export default function InboundList({
dbInbounds,
clientCount,
lastOnlineMap: _lastOnlineMap,
inboundSpeed,
expireDiff,
trafficDiff,
pageSize,
@@ -124,6 +125,7 @@ export default function InboundList({
hasActiveNode,
nodesById,
clientCount,
inboundSpeed,
subEnable,
expireDiff,
trafficDiff,
@@ -271,6 +273,7 @@ export default function InboundList({
hasActiveNode={hasActiveNode}
nodesById={nodesById}
clientCount={clientCount}
inboundSpeed={inboundSpeed}
trafficDiff={trafficDiff}
expireDiff={expireDiff}
onClose={() => setStatsRecord(null)}
@@ -0,0 +1,39 @@
import { Tag, Tooltip } from 'antd';
import { SizeFormatter } from '@/utils';
import type { InboundSpeedEntry } from './types';
// True when an inbound has live throughput worth showing.
export function isActiveSpeed(speed?: InboundSpeedEntry): speed is InboundSpeedEntry {
return !!speed && (speed.up > 0 || speed.down > 0);
}
interface InboundSpeedTagProps {
speed: InboundSpeedEntry;
withTooltip?: boolean;
}
// Blue "↑ up / ↓ down" rate tag, optionally with a stacked breakdown tooltip.
export function InboundSpeedTag({ speed, withTooltip = false }: InboundSpeedTagProps) {
const tag = (
<Tag color="blue">
↑ {SizeFormatter.speedFormat(speed.up)}
{' / '}
↓ {SizeFormatter.speedFormat(speed.down)}
</Tag>
);
if (!withTooltip) return tag;
return (
<Tooltip
title={(
<div>
<div>↑ {SizeFormatter.speedFormat(speed.up)}</div>
<div>↓ {SizeFormatter.speedFormat(speed.down)}</div>
</div>
)}
>
{tag}
</Tooltip>
);
}
Loaded 3 of 22 files, more files were not shown because too many files have changed in this diff. Show more