mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4835] [Feature]: Allow to reorder attached inbounds in client edit window #3364
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3364
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @maxbranson64-eng on GitHub (Jun 2, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4835
Is your feature request related to a problem?
Currently you cannot change how Attached inbounds are sorted for each client. So if you create new inbound it will be added to subscription page as last one. For example if you create local inbound then connect node (that has inbounds) and then create new local inbound. On subsciprion page and in client app inbounds from node will be between local inbounds but I expect local inbounds to be grouped on top of the list.
Describe the solution you'd like
Make it possible to drag and drop inbounds in Attached inbounds section of Client edit window. Order inbounds on subscription page according to the position of inbounds in Attached inbounds section.
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 2, 2026):
Thanks for the detailed request. This is a genuine gap — per-client ordering of attached inbounds is not currently implemented, and the subscription output order is effectively undefined (the query in
sub/subService.go:getInboundsBySubId()has no ORDER BY clause on attached inbounds).Current state (confirmed in source)
database/model/model.go—ClientInboundstructsort_orderfield; onlyclient_id,inbound_id,flow_override,created_atsub/subService.go:235–251SELECT DISTINCT inbounds.id … JOIN client_inbounds— no ORDER BYfrontend/src/pages/clients/ClientFormModal.tsx:574–588<Select mode="multiple">— no drag/reorderA precedent already exists in the codebase.
InboundFallback(same file,model.go:528) already has asort_orderinteger column, and the fallbacks section of the inbound form uses up/down arrow buttons (frontend/src/pages/inbounds/form/FallbacksCard.tsx+useInboundFallbacks.ts) to reorder entries and persist the index assortOrder.What a PR would need to touch
sort_order INT DEFAULT 0column to theclient_inboundstable.GetInboundIdsForRecord()/GetInboundIdsForEmail()in the client service to ORDER BYsort_order, and updateAttach()/Create()to accept and storesort_ordervalues.getInboundsBySubId()(sub/subService.go:235) to JOIN and ORDER BYclient_inbounds.sort_orderso the output respects the custom order.ClientFormModal.tsxwith a reorderable list (drag-and-drop or up/down arrows matching the fallbacks pattern), and sendsort_ordervalues on save.If you'd like to implement this, the fallbacks code (
FallbacksCard.tsx,useInboundFallbacks.ts,InboundFallbackmodel) is the closest existing example to follow.@psyhotm commented on GitHub (Jun 4, 2026):
I can confirm this issue with PostgreSQL backend.
In my setup the inbounds are displayed in the panel in the expected order:
But the generated subscription returns them in a different order, for example:
I checked the PostgreSQL data directly. The
inboundstable ordered byidis correct, andclient_inboundsalso has the expected assignment order. However, a query usingWHERE id IN (...)without an explicitORDER BYreturns rows in a different order.So this is not only a feature request for manual drag-and-drop sorting. There is also a backend correctness issue: subscription output should be deterministic.
A minimal fix would be to add an explicit order in
sub/subService.go:getInboundsBySubId(), for example:@psyhotm commented on GitHub (Jun 10, 2026):
Fixes #4835.
3x-ui-issue-4835-inbound-order.patch
I prepared a patch for this issue.
What it does:
sort_orderfield to theclient_inboundsrelation table.client_inbounds.sort_orderwhen generating subscription links, so VPN clients receive nodes in the same order as configured for that client.inbound_idwhen no explicit order exists.This fixes the issue where subscription node order may change unpredictably, especially with PostgreSQL, because the old query used
WHERE id IN (...)without an explicitORDER BY.Patch file is available and can be turned into a PR if this approach looks acceptable.
Механика такая:
под полем выбора появится отдельный список выбранных inbound’ов с drag-handle слева.
Перетаскиваешь строки в нужный порядок, жмешь Сохранить, и именно этот порядок уйдет в подписку клиента.
[ 🇷🇺 Россия ] [ 🇳🇱 Нидерланды ] [ 🇫🇷 Франция ]
⠿ 🇷🇺 Россия
⠿ 🇳🇱 Нидерланды
⠿ 🇫🇷 Франция
Можно будет поменять, например, на:
⠿ 🇷🇺 Россия
⠿ 🇫🇷 Франция
⠿ 🇳🇱 Нидерланды
@MHSanaei commented on GitHub (Jul 3, 2026):
This is now supported: each inbound has a Subscription sort index field (in the inbound create/edit form, also shown as a column in the inbound list), and subscription output — raw, HTML page, JSON, and Clash — is ordered by that index with ID as tiebreaker. That also fixes the non-deterministic ordering you observed on PostgreSQL, since the query now has an explicit ORDER BY.
For your example, give your local inbounds lower sort indexes than the node inbounds and they'll be grouped on top for every client.
Per-client ordering (a different order for each client) is intentionally not part of this mechanism — if you specifically need that, please open a focused follow-up issue; @psyhotm's patch would be a natural starting point there.