[PR #6948] feat(clients): append external links in bulk adjustments #6534

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

📋 Pull Request Information

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

Base: main ← Head: codex/bulk-append-external-links


📝 Commits (2)

  • f57433f feat(clients): append external links in bulk adjustments
  • 7147b77 fix(clients): isolate bulk queries and surface link validation

📊 Changes

41 files changed (+1900 additions, -365 deletions)

View changed files

📝 docs/content/docs/en/reference/api/clients.mdx (+26 -5)
📝 docs/public/openapi.json (+159 -14)
📝 frontend/public/openapi.json (+159 -14)
📝 frontend/src/generated/examples.ts (+22 -0)
📝 frontend/src/generated/schemas.ts (+101 -0)
📝 frontend/src/generated/types.ts (+26 -0)
📝 frontend/src/generated/zod.ts (+30 -0)
📝 frontend/src/hooks/useClients.ts (+14 -9)
📝 frontend/src/pages/api-docs/endpoints.ts (+42 -4)
➕ frontend/src/pages/clients/ClientBulkAdjustModal.css (+4 -0)
➕ frontend/src/pages/clients/ClientBulkAdjustModal.stories.tsx (+64 -0)
📝 frontend/src/pages/clients/ClientBulkAdjustModal.tsx (+134 -64)
➕ frontend/src/pages/clients/ClientExternalLinksFields.tsx (+171 -0)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+21 -205)
📝 frontend/src/pages/clients/ClientsPage.tsx (+2 -1)
📝 frontend/src/schemas/client.ts (+3 -0)
➕ frontend/src/schemas/external-link.ts (+58 -0)
➕ frontend/src/test/client-bulk-external-links.test.tsx (+180 -0)
📝 internal/web/controller/client.go (+19 -7)
➕ internal/web/controller/client_bulk_external_link_test.go (+96 -0)

...and 21 more files

📄 Description

Summary

Clients → Bulk Adjust currently cannot add external links or subscriptions to a selection. Add an Append external links mode that reuses the client editor's Link/Subscription fields and appends to the existing per-client lists, preserving existing entries, metadata, and order. Invalid rows display inline feedback; the single-client editor opens its Links tab before an invalid entry can be saved.

Why

Closes #6816.

A separate append mode gives link additions a single transaction without mixing them with quota or runtime adjustments. The existing limits/settings mode keeps its behavior. The implementation uses the existing client external-link model and normalizeExternalLinks, with batched reads/inserts and per-client (kind, value) duplicate detection.

The closed #5625/#6571 reviews informed the batching, metadata preservation, optional-field documentation, and complete locale/codegen updates.

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?

  • TDD: the new HTTP regression first failed because the existing endpoint ignored externalLinks and reported “no adjustment specified”; the component regression failed on the absent append tab.
  • Regression coverage includes multiple selected clients, both kinds, existing metadata/order preservation, duplicates within the input and against stored rows, retries, missing/invalid clients, full input validation, mixed-mode rejection, insert-batch rollback, and existing Bulk Adjust behavior.
  • Tests verify two SELECTs for 60 clients and four SELECTs across the 400-client query boundary. The 401-client regression first reproduced the accumulated GORM filter bug. Concurrent retry tests exercise SQLite and a real local PostgreSQL instance; the PostgreSQL retry test spans 401 selected clients, and a deferred PostgreSQL commit failure verifies zero committed additions.
  • make verify passed, including 217 frontend test files / 2,026 tests and the Go/frontend/Storybook builds.
  • make race: the initial full local run passed. The final local rerun passed the changed service package but hit the unchanged Discord heartbeat flood test with a broken pipe; that package passed when rerun alone with the same shuffle seed. The final commit also passed the full CI race job.
  • Targeted Go HTTP/service tests, PostgreSQL regression, browser story/accessibility checks, and frontend component tests passed.
  • API artifacts were regenerated and make gen-check docs-openapi-check passed. Documentation typecheck, lint, format check, and all 112 tests passed.
  • Desktop and 390 px mobile previews have no horizontal overflow or clipped inputs.

Local gates ran in a Linux checkout whose changed files matched the working checkout byte for byte.

Screenshots / recordings

Desktop append mode

Mobile (390 px)

Mobile append mode

Breaking changes

None. API callers use externalLinks on POST /panel/api/clients/bulkAdjust separately from other adjustments. The response reports added/duplicate row counts, missing-client errors, and the number of clients receiving additions. Append requests do not restart Xray.

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/6948 **Author:** [@HamedSanaei](https://github.com/HamedSanaei) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/bulk-append-external-links` --- ### 📝 Commits (2) - [`f57433f`](https://github.com/MHSanaei/3x-ui/commit/f57433fe3521919fd35731cdba8d46826793832b) feat(clients): append external links in bulk adjustments - [`7147b77`](https://github.com/MHSanaei/3x-ui/commit/7147b77383fd2af6ddee2967d5aa6515d1b8f460) fix(clients): isolate bulk queries and surface link validation ### 📊 Changes **41 files changed** (+1900 additions, -365 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/clients.mdx` (+26 -5) 📝 `docs/public/openapi.json` (+159 -14) 📝 `frontend/public/openapi.json` (+159 -14) 📝 `frontend/src/generated/examples.ts` (+22 -0) 📝 `frontend/src/generated/schemas.ts` (+101 -0) 📝 `frontend/src/generated/types.ts` (+26 -0) 📝 `frontend/src/generated/zod.ts` (+30 -0) 📝 `frontend/src/hooks/useClients.ts` (+14 -9) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+42 -4) ➕ `frontend/src/pages/clients/ClientBulkAdjustModal.css` (+4 -0) ➕ `frontend/src/pages/clients/ClientBulkAdjustModal.stories.tsx` (+64 -0) 📝 `frontend/src/pages/clients/ClientBulkAdjustModal.tsx` (+134 -64) ➕ `frontend/src/pages/clients/ClientExternalLinksFields.tsx` (+171 -0) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+21 -205) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+2 -1) 📝 `frontend/src/schemas/client.ts` (+3 -0) ➕ `frontend/src/schemas/external-link.ts` (+58 -0) ➕ `frontend/src/test/client-bulk-external-links.test.tsx` (+180 -0) 📝 `internal/web/controller/client.go` (+19 -7) ➕ `internal/web/controller/client_bulk_external_link_test.go` (+96 -0) _...and 21 more files_ </details> ### 📄 Description ## Summary Clients → Bulk Adjust currently cannot add external links or subscriptions to a selection. Add an **Append external links** mode that reuses the client editor's Link/Subscription fields and appends to the existing per-client lists, preserving existing entries, metadata, and order. Invalid rows display inline feedback; the single-client editor opens its Links tab before an invalid entry can be saved. ## Why Closes #6816. A separate append mode gives link additions a single transaction without mixing them with quota or runtime adjustments. The existing limits/settings mode keeps its behavior. The implementation uses the existing client external-link model and `normalizeExternalLinks`, with batched reads/inserts and per-client `(kind, value)` duplicate detection. The closed #5625/#6571 reviews informed the batching, metadata preservation, optional-field documentation, and complete locale/codegen updates. ## 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) - [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? - TDD: the new HTTP regression first failed because the existing endpoint ignored `externalLinks` and reported “no adjustment specified”; the component regression failed on the absent append tab. - Regression coverage includes multiple selected clients, both kinds, existing metadata/order preservation, duplicates within the input and against stored rows, retries, missing/invalid clients, full input validation, mixed-mode rejection, insert-batch rollback, and existing Bulk Adjust behavior. - Tests verify two SELECTs for 60 clients and four SELECTs across the 400-client query boundary. The 401-client regression first reproduced the accumulated GORM filter bug. Concurrent retry tests exercise SQLite and a real local PostgreSQL instance; the PostgreSQL retry test spans 401 selected clients, and a deferred PostgreSQL commit failure verifies zero committed additions. - `make verify` passed, including 217 frontend test files / 2,026 tests and the Go/frontend/Storybook builds. - `make race`: the initial full local run passed. The final local rerun passed the changed service package but hit the unchanged Discord heartbeat flood test with a broken pipe; that package passed when rerun alone with the same shuffle seed. The final commit also passed the full CI race job. - Targeted Go HTTP/service tests, PostgreSQL regression, browser story/accessibility checks, and frontend component tests passed. - API artifacts were regenerated and `make gen-check docs-openapi-check` passed. Documentation typecheck, lint, format check, and all 112 tests passed. - Desktop and 390 px mobile previews have no horizontal overflow or clipped inputs. Local gates ran in a Linux checkout whose changed files matched the working checkout byte for byte. ## Screenshots / recordings ![Desktop append mode](https://raw.githubusercontent.com/HamedSanaei/3x-ui/69339c3a29bc320b3c9a892b965fc8a4a6fd36cd/desktop.png) <details> <summary>Mobile (390 px)</summary> ![Mobile append mode](https://raw.githubusercontent.com/HamedSanaei/3x-ui/69339c3a29bc320b3c9a892b965fc8a4a6fd36cd/mobile.png) </details> ## Breaking changes None. API callers use `externalLinks` on `POST /panel/api/clients/bulkAdjust` separately from other adjustments. The response reports added/duplicate row counts, missing-client errors, and the number of clients receiving additions. Append requests do not restart Xray. ## 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#6534
No description provided.