[PR #6969] feat(sub): default subscription ordering to Hosts order #6551

Open
opened 2026-11-02 04:09:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6969
Author: @HamedSanaei
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: codex/default-subscription-host-order


📝 Commits (1)

  • c59de58 feat(sub): default subscription ordering to Hosts order

📊 Changes

21 files changed (+105 additions, -58 deletions)

View changed files

📝 docs/content/docs/en/config/subscription.mdx (+23 -3)
➕ docs/public/images/subscription-node-order-default.png (+0 -0)
📝 frontend/src/models/setting.ts (+1 -1)
📝 frontend/src/test/subscription-general-tab.test.tsx (+6 -6)
📝 internal/sub/host_order_test.go (+2 -0)
📝 internal/web/service/setting.go (+2 -2)
📝 internal/web/service/setting_sub_info_node_test.go (+29 -4)
📝 internal/web/translation/ar-EG.json (+3 -3)
📝 internal/web/translation/en-US.json (+3 -3)
📝 internal/web/translation/es-ES.json (+3 -3)
📝 internal/web/translation/fa-IR.json (+3 -3)
📝 internal/web/translation/id-ID.json (+3 -3)
📝 internal/web/translation/ja-JP.json (+3 -3)
📝 internal/web/translation/pt-BR.json (+3 -3)
📝 internal/web/translation/ru-RU.json (+3 -3)
📝 internal/web/translation/sk-SK.json (+3 -3)
📝 internal/web/translation/tr-TR.json (+3 -3)
📝 internal/web/translation/uk-UA.json (+3 -3)
📝 internal/web/translation/vi-VN.json (+3 -3)
📝 internal/web/translation/zh-CN.json (+3 -3)

...and 1 more files

📄 Description

Summary

Use Hosts order as the default for Subscription Node Ordering, so subscriptions follow the order configured on the Hosts page without an extra settings change. Preserve every stored mode, including values written by previous Settings saves.

Why

Hosts already supports global ordering across inbounds, but the default still groups subscription entries by inbound. Users can reorder Hosts and reasonably expect that order to reach their subscriptions without discovering another setting.

Refs #6895.

Type of change

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

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?

  • Followed red → green: confirmed failures for default subscription output, the settings default, omitted-mode saves, and the displayed selection before changing production code.
  • Extended the real database-backed Raw, Clash and JSON subscription regression to verify the default global Hosts order, explicit Inbound order, explicit Hosts order, and subsequent Host reordering.
  • Updated settings persistence and rejection tests to protect a saved Inbound order choice. Added coverage for saving other settings with the ordering mode omitted or empty.
  • Updated the component regression for the default selection, switching to Inbound order, and displaying that saved choice. The existing settings-hook save/reload test remains covered.
  • GOFLAGS=-p=2 make verify.
  • GOFLAGS=-p=2 make race.
  • Docs: pnpm typecheck, pnpm lint, pnpm format:check, pnpm test (112 tests), pnpm gen:api with no generated diff, and pnpm build.
  • After copy review: targeted translation, subscription settings, and inbound form regressions passed (28 tests); reran docs checks/build and frontend lint, format, typecheck, and build.
  • Final CI: all 12 checks passed on c59de589ea58a55c03de5eb5d5b265b24ee76067, including race, real PostgreSQL jobs, fuzz smoke, and master/node end-to-end tests.
  • Chromium: rendered the actual Subscription settings tab with default settings, checked Hosts order, switched to Inbound order, and checked the select fits a 390px mobile viewport.

Screenshots / recordings

Subscription Node Ordering defaults to Hosts order

The screenshot renders the actual subscription settings tab with default settings in a local component preview.

Breaking changes

The default changes for new installations and existing panels with no stored ordering mode, including upgrades from before this option existed. Those panels switch on the next subscription refresh without any settings or Host edit. Hosts with equal sort order use their remarks to break ties; migrated Host groups from different inbounds can interleave; inbounds without applicable Hosts follow Host entries regardless of their subscription sort index. A client app that automatically selects the first node can therefore change servers.

Every stored mode is preserved, including inbound-first written by saving any Settings field after the option was introduced. A saved row does not distinguish a deliberate ordering selection from a full Settings save. To retain inbound-based ordering, select and save Inbound order before upgrading if the current version offers it; otherwise select it after upgrading and refresh the subscription. Requests that omit the mode or send an empty value use the new default.

The subscription guide and the inbound sort-order tooltip in all 14 locales explain the difference between the two modes. This intentionally changes the default; it does not fix a defect in the previous opt-in implementation.

No API shape or database schema changes, migration, or Xray restart is required. The existing sorting algorithms are unchanged; client applications can still apply their own sorting.

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/6969 **Author:** [@HamedSanaei](https://github.com/HamedSanaei) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/default-subscription-host-order` --- ### 📝 Commits (1) - [`c59de58`](https://github.com/MHSanaei/3x-ui/commit/c59de589ea58a55c03de5eb5d5b265b24ee76067) feat(sub): default subscription ordering to Hosts order ### 📊 Changes **21 files changed** (+105 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/config/subscription.mdx` (+23 -3) ➕ `docs/public/images/subscription-node-order-default.png` (+0 -0) 📝 `frontend/src/models/setting.ts` (+1 -1) 📝 `frontend/src/test/subscription-general-tab.test.tsx` (+6 -6) 📝 `internal/sub/host_order_test.go` (+2 -0) 📝 `internal/web/service/setting.go` (+2 -2) 📝 `internal/web/service/setting_sub_info_node_test.go` (+29 -4) 📝 `internal/web/translation/ar-EG.json` (+3 -3) 📝 `internal/web/translation/en-US.json` (+3 -3) 📝 `internal/web/translation/es-ES.json` (+3 -3) 📝 `internal/web/translation/fa-IR.json` (+3 -3) 📝 `internal/web/translation/id-ID.json` (+3 -3) 📝 `internal/web/translation/ja-JP.json` (+3 -3) 📝 `internal/web/translation/pt-BR.json` (+3 -3) 📝 `internal/web/translation/ru-RU.json` (+3 -3) 📝 `internal/web/translation/sk-SK.json` (+3 -3) 📝 `internal/web/translation/tr-TR.json` (+3 -3) 📝 `internal/web/translation/uk-UA.json` (+3 -3) 📝 `internal/web/translation/vi-VN.json` (+3 -3) 📝 `internal/web/translation/zh-CN.json` (+3 -3) _...and 1 more files_ </details> ### 📄 Description ## Summary Use **Hosts order** as the default for Subscription Node Ordering, so subscriptions follow the order configured on the Hosts page without an extra settings change. Preserve every stored mode, including values written by previous Settings saves. ## Why Hosts already supports global ordering across inbounds, but the default still groups subscription entries by inbound. Users can reorder Hosts and reasonably expect that order to reach their subscriptions without discovering another setting. Refs #6895. ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [x] Other (intentional default behavior change) ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] 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? - Followed red → green: confirmed failures for default subscription output, the settings default, omitted-mode saves, and the displayed selection before changing production code. - Extended the real database-backed Raw, Clash and JSON subscription regression to verify the default global Hosts order, explicit Inbound order, explicit Hosts order, and subsequent Host reordering. - Updated settings persistence and rejection tests to protect a saved Inbound order choice. Added coverage for saving other settings with the ordering mode omitted or empty. - Updated the component regression for the default selection, switching to Inbound order, and displaying that saved choice. The existing settings-hook save/reload test remains covered. - `GOFLAGS=-p=2 make verify`. - `GOFLAGS=-p=2 make race`. - Docs: `pnpm typecheck`, `pnpm lint`, `pnpm format:check`, `pnpm test` (112 tests), `pnpm gen:api` with no generated diff, and `pnpm build`. - After copy review: targeted translation, subscription settings, and inbound form regressions passed (28 tests); reran docs checks/build and frontend lint, format, typecheck, and build. - Final CI: all 12 checks passed on `c59de589ea58a55c03de5eb5d5b265b24ee76067`, including race, real PostgreSQL jobs, fuzz smoke, and master/node end-to-end tests. - Chromium: rendered the actual Subscription settings tab with default settings, checked Hosts order, switched to Inbound order, and checked the select fits a 390px mobile viewport. ## Screenshots / recordings ![Subscription Node Ordering defaults to Hosts order](https://raw.githubusercontent.com/HamedSanaei/3x-ui/codex/default-subscription-host-order/docs/public/images/subscription-node-order-default.png) The screenshot renders the actual subscription settings tab with default settings in a local component preview. ## Breaking changes The default changes for new installations and existing panels with no stored ordering mode, including upgrades from before this option existed. Those panels switch on the next subscription refresh without any settings or Host edit. Hosts with equal sort order use their remarks to break ties; migrated Host groups from different inbounds can interleave; inbounds without applicable Hosts follow Host entries regardless of their subscription sort index. A client app that automatically selects the first node can therefore change servers. Every stored mode is preserved, including `inbound-first` written by saving any Settings field after the option was introduced. A saved row does not distinguish a deliberate ordering selection from a full Settings save. To retain inbound-based ordering, select and save Inbound order before upgrading if the current version offers it; otherwise select it after upgrading and refresh the subscription. Requests that omit the mode or send an empty value use the new default. The subscription guide and the inbound sort-order tooltip in all 14 locales explain the difference between the two modes. This intentionally changes the default; it does not fix a defect in the previous opt-in implementation. No API shape or database schema changes, migration, or Xray restart is required. The existing sorting algorithms are unchanged; client applications can still apply their own sorting. ## 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. - [x] 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>
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#6551
No description provided.