[PR #4500] [MERGED] Reduce list-page payloads with slim/paged endpoints #5710

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4500
Author: @MHSanaei
Created: 5/23/2026
Status: ✅ Merged
Merged: 5/23/2026
Merged by: @MHSanaei

Base: main ← Head: feat/perf-list-pagination


📝 Commits (6)

  • 6279c6d perf(inbounds): slim list payload + lazy hydrate for row actions
  • b3db26c perf(clients): server-side pagination + slim row payload
  • b74465e perf(settings): use /inbounds/options for LDAP tag picker
  • 4242f8c perf(clients): de-duplicate options + paged list fetches
  • 8864284 perf(inbounds): share nodes list with form modal instead of refetching
  • 7babfcc docs(api): register /clients/list/paged endpoint

📊 Changes

11 files changed (+700 additions, -124 deletions)

View changed files

📝 frontend/src/hooks/useClients.ts (+108 -14)
📝 frontend/src/pages/api-docs/endpoints.js (+23 -0)
📝 frontend/src/pages/clients/ClientsPage.tsx (+62 -87)
📝 frontend/src/pages/inbounds/InboundFormModal.tsx (+3 -2)
📝 frontend/src/pages/inbounds/InboundsPage.tsx (+35 -18)
📝 frontend/src/pages/inbounds/useInbounds.ts (+22 -1)
📝 frontend/src/pages/settings/GeneralTab.tsx (+3 -1)
📝 web/controller/client.go (+16 -0)
📝 web/controller/inbound.go (+13 -0)
📝 web/service/client.go (+346 -0)
📝 web/service/inbound.go (+69 -1)

📄 Description

Summary

Removes the heaviest load-time round-trips from the panel's three list
pages (inbounds, clients, settings) by reshaping the API responses to
ship only what each page actually renders, paginating the clients list
on the server, and de-duplicating fetches that were firing twice on
every page open.

On a panel managing thousands of clients the inbounds and clients
pages used to ship megabytes of JSON on every refresh — the page would
hang while the browser parsed and re-rendered a payload that the table
only ever showed 25 rows of. After this PR the same page-loads ship
tens of KB.

What's in here

Slim list endpoints

  • New `GET /panel/api/inbounds/list/slim` — strips every per-client
    field besides email/enable/comment from `settings.clients[]` and skips
    UUID/SubId enrichment on `ClientStats`. The inbounds page only reads
    those three to roll up its client counts and badges
  • The inbounds page calls `/get/:id` through a new `hydrateInbound`
    helper just-in-time before opening edit/info/qr/export/clone — slim
    list never has to carry uuids/passwords/flows

Paginated clients endpoint

  • New `GET /panel/api/clients/list/paged` — filters, sorts, and
    paginates server-side and returns a slim row shape (no uuid /
    password / auth / flow / security / reverse / tgId per client).
    Page size capped at 200
  • Response also carries a `summary` object computed across the full
    DB row set (`{ total, active, online[], depleted[], expiring[], deactive[] }`)
    so the clients-page stat cards stay stable as the user paginates / filters
  • `useClients` exposes `{ clients (current page), total, filtered, query,
    setQuery, summary, hydrate }`. ClientsPage feeds its filter / sort /
    page state into `setQuery` via a single effect, debounces the search
    box by 300ms, and hydrates the full record via `/get/:email` before
    opening edit / info / qr modals

Settings-page picker

  • `InboundOption` now includes `Tag`, and the General settings tab calls
    `/panel/api/inbounds/options` instead of `/list` for the LDAP
    inbound-tag picker. Previously that one dropdown was the reason the
    settings page pulled every inbound with all its embedded clients

De-duplication

  • `useClients.setQuery` shallow-compares before storing — ClientsPage
    reconstructs the params object every render, but identical values are
    now a no-op instead of causing the hook's effect to refire and
    re-fetch `/clients/list/paged`
  • `/panel/api/inbounds/options` is fetched once on hook mount in its own
    effect (used to ride along with the clients fetch and got hit twice
    before either response landed)
  • `InboundFormModal` no longer calls `useNodes()` itself. It now takes
    an `availableNodes` prop from the page so `/panel/api/nodes/list`
    fires once per visit instead of twice (the modal is always mounted,
    even when closed)

Test plan

  • Inbounds page loads with full client counters and badges on every
    row; opening edit / info / qr / export / clipboard / clone still
    shows full client data
  • Clients page: search debounces (no fetch on every keystroke),
    filter / protocol / sort all round-trip to server, pagination
    controls reflect server `filtered` count
  • Clients page dashboard stat cards show DB-wide counts regardless
    of current filter / page
  • Edit / Info / QR on a client shows the full record (uuid,
    password, flow, ...) — confirms hydrate fires
  • Network tab on clients page: exactly one `/inbounds/options` and
    one `/clients/list/paged` on initial load
  • Network tab on inbounds page: exactly one `/nodes/list` on
    initial load
  • Settings → General tab: LDAP tag dropdown still lists all
    inbounds with `tag (protocol@port)` labels; the Network tab no
    longer shows `/inbounds/list` for the settings page
  • Bulk delete / bulk adjust / reset-traffic still work on the
    paged clients page

🔄 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/4500 **Author:** [@MHSanaei](https://github.com/MHSanaei) **Created:** 5/23/2026 **Status:** ✅ Merged **Merged:** 5/23/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/perf-list-pagination` --- ### 📝 Commits (6) - [`6279c6d`](https://github.com/MHSanaei/3x-ui/commit/6279c6d849d165814e33cbb3e2fc85c7252e0074) perf(inbounds): slim list payload + lazy hydrate for row actions - [`b3db26c`](https://github.com/MHSanaei/3x-ui/commit/b3db26c4d8e1a668b5b37a4f182d111fad918380) perf(clients): server-side pagination + slim row payload - [`b74465e`](https://github.com/MHSanaei/3x-ui/commit/b74465e869ac14b97d7b6a40de44537e9d053457) perf(settings): use /inbounds/options for LDAP tag picker - [`4242f8c`](https://github.com/MHSanaei/3x-ui/commit/4242f8c8816fff3375bbf89a5e1b905effa00015) perf(clients): de-duplicate options + paged list fetches - [`8864284`](https://github.com/MHSanaei/3x-ui/commit/88642844d37fc300244e4c68849cd54137112901) perf(inbounds): share nodes list with form modal instead of refetching - [`7babfcc`](https://github.com/MHSanaei/3x-ui/commit/7babfcce1bf5fe29130ef16646defeb0460398f8) docs(api): register /clients/list/paged endpoint ### 📊 Changes **11 files changed** (+700 additions, -124 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/hooks/useClients.ts` (+108 -14) 📝 `frontend/src/pages/api-docs/endpoints.js` (+23 -0) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+62 -87) 📝 `frontend/src/pages/inbounds/InboundFormModal.tsx` (+3 -2) 📝 `frontend/src/pages/inbounds/InboundsPage.tsx` (+35 -18) 📝 `frontend/src/pages/inbounds/useInbounds.ts` (+22 -1) 📝 `frontend/src/pages/settings/GeneralTab.tsx` (+3 -1) 📝 `web/controller/client.go` (+16 -0) 📝 `web/controller/inbound.go` (+13 -0) 📝 `web/service/client.go` (+346 -0) 📝 `web/service/inbound.go` (+69 -1) </details> ### 📄 Description ## Summary Removes the heaviest load-time round-trips from the panel's three list pages (inbounds, clients, settings) by reshaping the API responses to ship only what each page actually renders, paginating the clients list on the server, and de-duplicating fetches that were firing twice on every page open. On a panel managing thousands of clients the inbounds and clients pages used to ship megabytes of JSON on every refresh — the page would hang while the browser parsed and re-rendered a payload that the table only ever showed 25 rows of. After this PR the same page-loads ship tens of KB. ## What's in here ### Slim list endpoints - New \`GET /panel/api/inbounds/list/slim\` — strips every per-client field besides email/enable/comment from \`settings.clients[]\` and skips UUID/SubId enrichment on \`ClientStats\`. The inbounds page only reads those three to roll up its client counts and badges - The inbounds page calls \`/get/:id\` through a new \`hydrateInbound\` helper just-in-time before opening edit/info/qr/export/clone — slim list never has to carry uuids/passwords/flows ### Paginated clients endpoint - New \`GET /panel/api/clients/list/paged\` — filters, sorts, and paginates server-side and returns a slim row shape (no uuid / password / auth / flow / security / reverse / tgId per client). Page size capped at 200 - Response also carries a \`summary\` object computed across the full DB row set (\`{ total, active, online[], depleted[], expiring[], deactive[] }\`) so the clients-page stat cards stay stable as the user paginates / filters - \`useClients\` exposes \`{ clients (current page), total, filtered, query, setQuery, summary, hydrate }\`. ClientsPage feeds its filter / sort / page state into \`setQuery\` via a single effect, debounces the search box by 300ms, and hydrates the full record via \`/get/:email\` before opening edit / info / qr modals ### Settings-page picker - \`InboundOption\` now includes \`Tag\`, and the General settings tab calls \`/panel/api/inbounds/options\` instead of \`/list\` for the LDAP inbound-tag picker. Previously that one dropdown was the reason the settings page pulled every inbound with all its embedded clients ### De-duplication - \`useClients.setQuery\` shallow-compares before storing — ClientsPage reconstructs the params object every render, but identical values are now a no-op instead of causing the hook's effect to refire and re-fetch \`/clients/list/paged\` - \`/panel/api/inbounds/options\` is fetched once on hook mount in its own effect (used to ride along with the clients fetch and got hit twice before either response landed) - \`InboundFormModal\` no longer calls \`useNodes()\` itself. It now takes an \`availableNodes\` prop from the page so \`/panel/api/nodes/list\` fires once per visit instead of twice (the modal is always mounted, even when closed) ## Test plan - [ ] Inbounds page loads with full client counters and badges on every row; opening edit / info / qr / export / clipboard / clone still shows full client data - [ ] Clients page: search debounces (no fetch on every keystroke), filter / protocol / sort all round-trip to server, pagination controls reflect server \`filtered\` count - [ ] Clients page dashboard stat cards show DB-wide counts regardless of current filter / page - [ ] Edit / Info / QR on a client shows the full record (uuid, password, flow, ...) — confirms hydrate fires - [ ] Network tab on clients page: exactly one \`/inbounds/options\` and one \`/clients/list/paged\` on initial load - [ ] Network tab on inbounds page: exactly one \`/nodes/list\` on initial load - [ ] Settings → General tab: LDAP tag dropdown still lists all inbounds with \`tag (protocol@port)\` labels; the Network tab no longer shows \`/inbounds/list\` for the settings page - [ ] Bulk delete / bulk adjust / reset-traffic still work on the paged clients page --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:03:31 +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#5710
No description provided.