[PR #5261] [MERGED] feat(ui): show per-inbound live speed #5834

Closed
opened 2026-11-02 04:04:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5261
Author: @NikanZeyaei
Created: 6/13/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @MHSanaei

Base: main ← Head: feature/inbound-speed


📝 Commits (10+)

  • 604bbdb feat(utils): add speedFormat utility and tests
  • b8460ad feat(inbounds): add InboundSpeedEntry type
  • 1071722 feat(inbounds): add speed column to inbound list
  • 6673990 feat(inbounds): show speed in inbound stats modal
  • 121d684 feat(inbounds): compute inbound speed from traffic deltas
  • b28aed3 feat(inbounds): wire inbound speed through page
  • f10a5d3 feat(i18n): add speed translation for all locales
  • 87261cc Merge branch 'main' into feature/inbound-speed
  • cfa3e7c Merge branch 'main' into feature/inbound-speed
  • 3c893a5 refactor(inbounds): dedupe live-speed UI and harden formatting

📊 Changes

22 files changed (+198 additions, -5 deletions)

View changed files

📝 frontend/src/pages/inbounds/InboundsPage.tsx (+2 -0)
📝 frontend/src/pages/inbounds/list/InboundList.tsx (+3 -0)
➕ frontend/src/pages/inbounds/list/InboundSpeedTag.tsx (+39 -0)
📝 frontend/src/pages/inbounds/list/InboundStatsModal.tsx (+14 -1)
📝 frontend/src/pages/inbounds/list/types.ts (+6 -0)
📝 frontend/src/pages/inbounds/list/useInboundColumns.tsx (+18 -2)
📝 frontend/src/pages/inbounds/useInbounds.ts (+43 -1)
➕ frontend/src/test/size-formatter.test.ts (+54 -0)
📝 frontend/src/utils/index.ts (+6 -1)
📝 internal/web/translation/ar-EG.json (+1 -0)
📝 internal/web/translation/en-US.json (+1 -0)
📝 internal/web/translation/es-ES.json (+1 -0)
📝 internal/web/translation/fa-IR.json (+1 -0)
📝 internal/web/translation/id-ID.json (+1 -0)
📝 internal/web/translation/ja-JP.json (+1 -0)
📝 internal/web/translation/pt-BR.json (+1 -0)
📝 internal/web/translation/ru-RU.json (+1 -0)
📝 internal/web/translation/tr-TR.json (+1 -0)
📝 internal/web/translation/uk-UA.json (+1 -0)
📝 internal/web/translation/vi-VN.json (+1 -0)

...and 2 more files

📄 Description

Summary

Closes #4886

Adds a live speed column to the inbounds list showing per-inbound upload/download throughput (bytes/sec). The speed is also shown in the mobile stats modal. The backend already broadcasts per-inbound byte deltas over the WebSocket every 5 seconds; this PR closes the frontend UX gap by consuming those deltas and rendering them.

Why

Users could see cumulative traffic per inbound, but had no way to tell how much bandwidth an inbound was using right now. The WebSocket traffic message already carries traffics: [{ tag, up, down, isInbound }], so no backend data work was needed — only frontend display and formatting.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  1. cd frontend && npm run typecheck — passes.
  2. cd frontend && npm run test -- size-formatter.test.ts --run — passes.
  3. go build ./internal/xray/... ./internal/web/... — passes.

Implementation details

Frontend (TypeScript/React):

  • Added SizeFormatter.speedFormat(bps) in frontend/src/utils/index.ts for "↑ X KB/s / ↓ Y MB/s" style rendering, plus unit tests in frontend/src/test/size-formatter.test.ts.
  • Added InboundSpeedEntry type in frontend/src/pages/inbounds/list/types.ts.
  • Updated frontend/src/pages/inbounds/useInbounds.ts:
    • Consumes payload.traffics from the WebSocket traffic event.
    • Filters for inbound traffic entries (IsInbound !== false) and maps Tag to inbound rows.
    • Computes speed as delta.Up / 5 and delta.Down / 5 to get bytes/sec.
    • Exposes inboundSpeed: Record<number, InboundSpeed>.
  • Added a "Speed" column in frontend/src/pages/inbounds/list/useInboundColumns.tsx, wired through frontend/src/pages/inbounds/list/InboundList.tsx.
  • Added speed display in frontend/src/pages/inbounds/list/InboundStatsModal.tsx for the mobile card view.
  • Passed inboundSpeed through frontend/src/pages/inbounds/InboundsPage.tsx.

Translations:

  • Added pages.inbounds.speed key to all 13 supported language files.

Files changed

  • frontend/src/utils/index.ts
  • frontend/src/test/size-formatter.test.ts
  • frontend/src/pages/inbounds/list/types.ts
  • frontend/src/pages/inbounds/useInbounds.ts
  • frontend/src/pages/inbounds/list/useInboundColumns.tsx
  • frontend/src/pages/inbounds/list/InboundList.tsx
  • frontend/src/pages/inbounds/list/InboundStatsModal.tsx
  • frontend/src/pages/inbounds/InboundsPage.tsx
  • internal/web/translation/en-US.json
  • internal/web/translation/vi-VN.json
  • internal/web/translation/zh-CN.json
  • internal/web/translation/zh-TW.json
  • internal/web/translation/ru-RU.json
  • internal/web/translation/pt-BR.json
  • internal/web/translation/uk-UA.json
  • internal/web/translation/tr-TR.json
  • internal/web/translation/id-ID.json
  • internal/web/translation/ja-JP.json
  • internal/web/translation/fa-IR.json
  • internal/web/translation/es-ES.json
  • internal/web/translation/ar-EG.json

Screenshots / recordings

2026-06-13 10 59 48

https://github.com/user-attachments/assets/b1ae8262-dceb-48a2-9caf-9abf062b8b07

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5261 **Author:** [@NikanZeyaei](https://github.com/NikanZeyaei) **Created:** 6/13/2026 **Status:** ✅ Merged **Merged:** 6/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feature/inbound-speed` --- ### 📝 Commits (10+) - [`604bbdb`](https://github.com/MHSanaei/3x-ui/commit/604bbdbe6944edfb37770d9e118da18f91400044) feat(utils): add speedFormat utility and tests - [`b8460ad`](https://github.com/MHSanaei/3x-ui/commit/b8460ad5debde6f4f81244d5efd8b89eedd4b6d7) feat(inbounds): add InboundSpeedEntry type - [`1071722`](https://github.com/MHSanaei/3x-ui/commit/1071722a21a68159bb6a7e0eea513a5f86e61662) feat(inbounds): add speed column to inbound list - [`6673990`](https://github.com/MHSanaei/3x-ui/commit/6673990a3a184d64925e2578ce61e04a2a7c4258) feat(inbounds): show speed in inbound stats modal - [`121d684`](https://github.com/MHSanaei/3x-ui/commit/121d68433641f2c28142b3c7620100d9c14cbd99) feat(inbounds): compute inbound speed from traffic deltas - [`b28aed3`](https://github.com/MHSanaei/3x-ui/commit/b28aed31c894b508df3fa7da776788bd8344d21e) feat(inbounds): wire inbound speed through page - [`f10a5d3`](https://github.com/MHSanaei/3x-ui/commit/f10a5d378884bbb1fd6f6a441a5c0dc6ed1d5599) feat(i18n): add speed translation for all locales - [`87261cc`](https://github.com/MHSanaei/3x-ui/commit/87261cc5a9612ed9eb8b4e92047392b9e0a4f760) Merge branch 'main' into feature/inbound-speed - [`cfa3e7c`](https://github.com/MHSanaei/3x-ui/commit/cfa3e7cd00045617c9315f943acab2053fdf6769) Merge branch 'main' into feature/inbound-speed - [`3c893a5`](https://github.com/MHSanaei/3x-ui/commit/3c893a52213ab48486a6a1021efcde44b8be15c6) refactor(inbounds): dedupe live-speed UI and harden formatting ### 📊 Changes **22 files changed** (+198 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/inbounds/InboundsPage.tsx` (+2 -0) 📝 `frontend/src/pages/inbounds/list/InboundList.tsx` (+3 -0) ➕ `frontend/src/pages/inbounds/list/InboundSpeedTag.tsx` (+39 -0) 📝 `frontend/src/pages/inbounds/list/InboundStatsModal.tsx` (+14 -1) 📝 `frontend/src/pages/inbounds/list/types.ts` (+6 -0) 📝 `frontend/src/pages/inbounds/list/useInboundColumns.tsx` (+18 -2) 📝 `frontend/src/pages/inbounds/useInbounds.ts` (+43 -1) ➕ `frontend/src/test/size-formatter.test.ts` (+54 -0) 📝 `frontend/src/utils/index.ts` (+6 -1) 📝 `internal/web/translation/ar-EG.json` (+1 -0) 📝 `internal/web/translation/en-US.json` (+1 -0) 📝 `internal/web/translation/es-ES.json` (+1 -0) 📝 `internal/web/translation/fa-IR.json` (+1 -0) 📝 `internal/web/translation/id-ID.json` (+1 -0) 📝 `internal/web/translation/ja-JP.json` (+1 -0) 📝 `internal/web/translation/pt-BR.json` (+1 -0) 📝 `internal/web/translation/ru-RU.json` (+1 -0) 📝 `internal/web/translation/tr-TR.json` (+1 -0) 📝 `internal/web/translation/uk-UA.json` (+1 -0) 📝 `internal/web/translation/vi-VN.json` (+1 -0) _...and 2 more files_ </details> ### 📄 Description ## Summary Closes #4886 Adds a live **speed** column to the inbounds list showing per-inbound upload/download throughput (bytes/sec). The speed is also shown in the mobile stats modal. The backend already broadcasts per-inbound byte deltas over the WebSocket every 5 seconds; this PR closes the frontend UX gap by consuming those deltas and rendering them. ## Why Users could see cumulative traffic per inbound, but had no way to tell how much bandwidth an inbound was using right now. The WebSocket traffic message already carries `traffics: [{ tag, up, down, isInbound }]`, so no backend data work was needed — only frontend display and formatting. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [x] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. `cd frontend && npm run typecheck` — passes. 2. `cd frontend && npm run test -- size-formatter.test.ts --run` — passes. 3. `go build ./internal/xray/... ./internal/web/...` — passes. ## Implementation details **Frontend (TypeScript/React):** - Added `SizeFormatter.speedFormat(bps)` in `frontend/src/utils/index.ts` for "↑ X KB/s / ↓ Y MB/s" style rendering, plus unit tests in `frontend/src/test/size-formatter.test.ts`. - Added `InboundSpeedEntry` type in `frontend/src/pages/inbounds/list/types.ts`. - Updated `frontend/src/pages/inbounds/useInbounds.ts`: - Consumes `payload.traffics` from the WebSocket traffic event. - Filters for inbound traffic entries (`IsInbound !== false`) and maps `Tag` to inbound rows. - Computes speed as `delta.Up / 5` and `delta.Down / 5` to get bytes/sec. - Exposes `inboundSpeed: Record<number, InboundSpeed>`. - Added a "Speed" column in `frontend/src/pages/inbounds/list/useInboundColumns.tsx`, wired through `frontend/src/pages/inbounds/list/InboundList.tsx`. - Added speed display in `frontend/src/pages/inbounds/list/InboundStatsModal.tsx` for the mobile card view. - Passed `inboundSpeed` through `frontend/src/pages/inbounds/InboundsPage.tsx`. **Translations:** - Added `pages.inbounds.speed` key to all 13 supported language files. ## Files changed - `frontend/src/utils/index.ts` - `frontend/src/test/size-formatter.test.ts` - `frontend/src/pages/inbounds/list/types.ts` - `frontend/src/pages/inbounds/useInbounds.ts` - `frontend/src/pages/inbounds/list/useInboundColumns.tsx` - `frontend/src/pages/inbounds/list/InboundList.tsx` - `frontend/src/pages/inbounds/list/InboundStatsModal.tsx` - `frontend/src/pages/inbounds/InboundsPage.tsx` - `internal/web/translation/en-US.json` - `internal/web/translation/vi-VN.json` - `internal/web/translation/zh-CN.json` - `internal/web/translation/zh-TW.json` - `internal/web/translation/ru-RU.json` - `internal/web/translation/pt-BR.json` - `internal/web/translation/uk-UA.json` - `internal/web/translation/tr-TR.json` - `internal/web/translation/id-ID.json` - `internal/web/translation/ja-JP.json` - `internal/web/translation/fa-IR.json` - `internal/web/translation/es-ES.json` - `internal/web/translation/ar-EG.json` ## Screenshots / recordings <img width="1280" height="176" alt="2026-06-13 10 59 48" src="https://github.com/user-attachments/assets/687f20eb-3774-4261-8560-bdbe6cc34af1" /> https://github.com/user-attachments/assets/b1ae8262-dceb-48a2-9caf-9abf062b8b07 ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5834
No description provided.