mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5370] [Feature]: Batch Edit Selected Inbounds — Modify Common Parameters Across Multiple Inbounds at Once #3758
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#3758
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 @jshir700 on GitHub (Jun 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5370
Is your feature request related to a problem?
If you manage more than a handful of inbounds, you've almost certainly faced this: you need to make the same small change across many inbounds, and the only tool available is to open each one's edit modal, make the change, save it, wait for the panel to respond, and repeat — sometimes dozens or hundreds of times.
This isn't just inconvenient — it actively encourages bad practices. When updating 20 inbounds one-by-one takes 10 minutes, operators start asking "can I script this?" or "do I really need to change all of them?" or worse, they just skip the maintenance and leave stale configurations running. And the manual process is error-prone: you'll inevitably mistype a value on the 14th inbound or forget to save one.
Concretely, here are the operations that currently require a full edit cycle per inbound but should really be a one-shot bulk operation:
hostafter CDN domain changeThe existing checkbox selection on the inbound list page already supports multi-select. But the only bulk action it offers is delete. Everything else is single-inbound only.
Describe the solution you'd like
The core idea is simple: select multiple inbounds → click "Batch Edit" → pick the fields you want to change → apply once.
But there's a subtle design challenge. A batch edit isn't the same as opening an empty form and filling it in. The semantics are fundamentally different:
This means the batch edit UI needs to communicate a three-way state for each field, not just a value:
And because the selected inbounds might have different protocols, different transport networks, or different security configurations, the UI also needs to show only the controls that make sense for the current selection, and hide the rest.
How it works — user perspective
On the
InboundsPage, select two or more inbounds by ticking their checkboxes.A "Batch Edit" button appears in the toolbar (alongside the existing bulk delete and the selected-count tag).
Clicking it opens a modal with 4 tab pages:
Each control starts in a "Keep original" state. You only touch the controls you want to change. If you want to update the WS path but leave everything else alone, you fill in only the WS path field and click Apply.
As you interact with each control, a compact preview line below it shows the current value of that field for every selected inbound — so you can see what you're about to overwrite before you commit.
Click Apply. A single API call updates all selected inbounds, reporting back how many succeeded and which (if any) were skipped and why.
Design decisions explained
Why a new API endpoint instead of calling the existing
update/:idN times from the frontend?The frontend could call
/panel/api/inbounds/update/:idonce per selected inbound in a loop. But that means N sequential HTTP requests, N auth checks, N WebSocket broadcasts — it's chatty and slow. A dedicatedPOST /panel/api/inbounds/bulkUpdateendpoint packages all the changes into one request and lets the backend iterate efficiently, reporting partial success in a single response.Why "Keep original" for controls instead of having the user fill in every field?
Because batch editing is about making targeted changes, not full replacements. If you have 30 inbounds and you just want to disable them, you shouldn't need to also re-type every inbound's port, listen address, stream settings, and TLS config. The "keep original" semantics mean the batch edit is always additive — it only changes what you explicitly touch.
Why hide network/security/protocol cards that don't apply to the selection?
Imagine you selected 5 WS inbounds and 5 gRPC inbounds. If we showed the full set of every possible field, the modal would be overwhelming: 20+ stream settings controls, TLS controls, Reality controls, protocol controls — most of them irrelevant to the inbounds you selected. Worse, you could accidentally set a field on inbounds where it doesn't apply, which would either be silently ignored (confusing) or cause an error (frustrating).
Instead, by gating each card on whether the selected inbounds actually use that network type or security type, the modal adapts to the selection. Select only WS inbounds → only WS fields appear. Select 5 WS + 5 gRPC → both appear, side by side. Select a mix that has nothing in common → General tab is enough, and the other tabs are disabled.
Why three-state booleans (Switch with indeterminate)?
A simple on/off switch has a hidden problem: what does "off" mean? Does it mean "set enable to false" or does it mean "I didn't touch enable"? In a batch edit, these are different actions. The three-state approach resolves this:
The user sees at a glance which fields they've touched and which fields will remain as-is.
Why show current values per inbound?
The biggest risk in batch editing is overwriting something you didn't intend to. If you're updating the WS host field, but a few inbounds in your selection have a different host value than the rest, you should know before you click Apply. The per-inbound preview line below each field serves exactly this purpose — it shows the current value of that field for each selected inbound, so you can verify the change is safe before committing.
Why partial success instead of rollback-on-failure?
The inbounds are independent — updating one doesn't affect another. If inbound #3 fails because of a port conflict, there's no reason to roll back inbounds #1 and #2 which succeeded. Partial success means the operator only has to re-check the failed ones, not redo the entire batch.
Why does subSortIndex (batch reorder) need special treatment?
The existing single-inbound form has a
subSortIndexfield (database columnSubSortIndex, default:1) that controls the sort order of the inbound's links in subscription output — lower values appear first, ties broken by ID. If you were to include it in the General tab like any other field (a plainInputNumber), every selected inbound would receive the same sort value — rendering the sort meaningless. The purpose of batch reordering is to arrange inbounds into a sequential order, not to stamp them all with an identical number.This means reorder is fundamentally different from the other fields in the batch edit:
So instead of a simple input, the modal provides a dedicated batch reorder card inside the General tab. And instead of adding a separate endpoint, the
bulkUpdaterequest body includes an optionalreorderfield that carries the ordered inbound IDs — the backend applies field changes first, then updatesSubSortIndexon each inbound based on its position.Batch Reorder — detailed UX
Inside the General tab, when two or more inbounds are selected, a "Batch Reorder" card appears. The user can rearrange inbounds into their desired order using either interaction method:
Initial order = the current list display order on the inbounds page before the user opened the modal.
Row identifier: Each row shows
remark (protocol-network-port)so the user can identify inbounds at a glance without needing to cross-reference with the inbound list page.Computed value: The right-hand column shows the
SubSortIndexvalue updated in real time as rows are moved:startValue + positionIndex × step. Default: start=1, step=10. The step of 10 leaves gaps (1, 11, 21...) so the operator can later manually insert other inbounds between them using the single-edit form.Preview string: A compact one-line preview below the card shows the final ordered sequence of remarks — useful for a quick sanity check.
Submission flow:
The
bulkUpdaterequest body includes an optionalreorderfield alongside the other field changes:The backend processes in order:
reorder.idsis present and non-empty, update each inbound'sSubSortIndexby position: position-0 getsstartAt(default 1), position-1 getsstartAt + step(default 11), etc.This keeps the API unified — the frontend sends one request, the backend applies everything atomically (or reports partial success for the field changes if some inbounds fail).
API shape
The request body separates concerns into five sections — four for value edits, one for reorder:
fields— simple key-value pairs for the inbound's database columns. A key is only applied if its value is non-null. The frontend sendsnullfor every control the user didn't touch.streamSettings— network-level settings grouped by transport type. Only the settings matching the inbound's current network are applied:externalProxy— cross-cutting, not tied to a specific network type. The UI groups this under the Network tab but it applies regardless of the inbound's transport:security— TLS and Reality settings, again dispatched by the inbound's security type:protocolSettings— per-protocol adjustments:reorder— optional batch reordering. When present, the backend assignsSubSortIndexvalues sequentially based on position in theidsarray, after applying all field changes above:startAtdefaults to 1 andstepdefaults to 10 — both match the defaults shown in the UI modal. The backend assigns position-0 →startAt, position-1 →startAt + step, etc.Response:
Files involved
internal/web/controller/inbound.gobulkUpdateInboundshandler; register routeinternal/web/service/inbound.goUpdateInboundPartialmethod applying non-null diffs + reorder logicinternal/web/web.goPOST /panel/api/inbounds/bulkUpdatefrontend/src/pages/inbounds/form/BatchEditModal.tsxfrontend/src/pages/inbounds/list/InboundList.tsx'batchEdit'key to action menu, conditionally shown when ≥2 inbounds selected; addonBulkEditpropfrontend/src/pages/inbounds/InboundsPage.tsxBatchEditModal, manage open/close state + selected inbounds, wire menu actioninternal/web/translation/*.jsonAlternatives you've considered
Export → edit JSON → re-import. The panel already supports exporting a single inbound as JSON and importing it. But this is a "replace the whole thing" operation — you must serialise every client, every byte of stream settings, every sniffing rule. For an inbound with hundreds of clients, that's megabytes of JSON to edit just to change one field. And there's no way to do this for multiple inbounds at once without a separate script.
Script the REST API. A command-line tool that calls
/panel/api/inbounds/update/:idin a loop for each selected inbound is technically possible. But it requires SSH or API-token access, understanding of the JSON shapes (which differ by protocol), and manual error handling for things like port conflicts. For most panel operators — who are panel administrators, not developers — this is not a practical solution.Just open and edit each one. This is the status quo, and it's the baseline we're comparing against. It works for 2-3 inbounds. For 10+, it's painful. For 50+, it's almost unusable. The time cost scales linearly with the number of inbounds, and the error rate goes up with fatigue.
Reuse the
InboundFormModalwith a multi-inbound mode. The existing edit modal is designed around a single inbound: it loads the full record, binds every field, and on save sends the complete state. Making it support batch editing would require either (a) loading all selected inbounds into a single form (impossible when they have different values for the same fields), or (b) adding "keep original" semantics to every control, which would complicate the single-edit flow for no benefit. A dedicated modal is cleaner and keeps both flows simple.Concrete use cases
Use case 1: CDN domain migration. You operate a panel behind a CDN that requires changing the origin domain. You have 45 inbounds across 3 protocols (VMess-WS, VLESS-WS, Trojan-WS). All use WebSocket with the same
hostfield pointing to your CDN. The CDN provider changes the origin endpoint fromold-cdn.example.comtonew-cdn.example.com.Without batch edit: 45 inbounds × (open modal → edit host → save → wait) = ~25 minutes of repetitive work. With batch edit: select all 45 → Batch Edit → Network tab → WebSocket → type the new host → Apply. 30 seconds.
Use case 2: Temporary maintenance window. You need to take 12 specific inbounds offline for 2 hours to test a new Xray core version. After testing, you need to bring them back online.
Without batch edit: disable each of 12 inbounds manually, then manually re-enable them later. If you lose track of which ones you disabled, you might leave some offline permanently. With batch edit: select the 12 → Batch Edit → General → Enable → Off → Apply. After testing: select the same 12 → Enable → On → Apply. Two clicks each way.
Use case 3: Tiered service management. You run a service with "bronze" (expiry: 30 days, 50GB), "silver" (expiry: 60 days, 100GB), and "gold" (expiry: 90 days, 200GB) tiers. At the start of each month, you need to create new batches and adjust limits. When you decide to increase the "silver" tier from 100GB to 150GB, you need to update 35 existing inbounds.
Without batch edit: you can't practically update 35 existing inbounds — you'd typically create new ones and migrate clients manually, because the effort of editing 35 is too high. With batch edit: select the 35 silver-tier inbounds → set total → Apply. Done in 10 seconds.
Use case 4: Emergency security patch. A vulnerability is discovered in a specific TLS version or cipher suite. You need to update
minVersionfrom1.1to1.2on every TLS inbound immediately.Without batch edit: you're racing the clock, manually updating each inbound while the panel is potentially vulnerable. With batch edit: select all TLS inbounds → Security tab → TLS → set Min Version → Apply. Takes as long as it takes to type "1.2".
Use case 5: Manual reorder after server consolidation. You've just consolidated 3 servers down to 1. You have 40 inbounds from the old servers imported into one panel, and their subscription sort order is a mess — inbounds from server A, then server C, then server B interleaved. You need to reorder them into a clean sequence: all HTTP inbounds first, then all VMess, then VLESS, then Trojan, then Shadowsocks, with each group sorted by port. Currently you'd have to open each inbound individually and set its
subSortIndexby hand, while trying to keep a mental map of which values you've already used. With batch edit: multi-select the inbounds you want to arrange, drag them into order inside the modal, set start=1 step=10 → Apply. If you change your mind, re-open and reorder again — the new sequence overwrites the old one.Appendix: i18n keys
The following new keys need to be added across all
internal/web/translation/*.jsonfiles:pages.inbounds.batchEditInboundspages.inbounds.batchEditTabGeneralpages.inbounds.batchEditTabNetworkpages.inbounds.batchEditTabSecuritypages.inbounds.batchEditTabProtocolpages.inbounds.batchEditKeepOriginalpages.inbounds.batchEditKeepClientOriginalspages.inbounds.batchEditNotSetpages.inbounds.batchEditApplypages.inbounds.batchEditSavedpages.inbounds.batchEditPartialErrorpages.inbounds.batchEditNoMatchingInboundspages.inbounds.batchEditNoMatchingClientspages.inbounds.batchEditAndMorepages.inbounds.batchEditHostpages.inbounds.batchEditPathpages.inbounds.batchEditServiceNamepages.inbounds.batchEditAuthoritypages.inbounds.batchEditMultiModepages.inbounds.batchEditHeartbeatpages.inbounds.batchEditHttpCamouflagepages.inbounds.batchEditSeedpages.inbounds.batchEditMtupages.inbounds.batchEditTtipages.inbounds.batchEditUplinkCappages.inbounds.batchEditDownlinkCappages.inbounds.batchEditHeaderTypepages.inbounds.batchEditEnableSockoptpages.inbounds.batchEditSockoptHintpages.inbounds.batchEditClearFallbackspages.inbounds.batchEditFlowpages.inbounds.batchEditVersionpages.inbounds.batchEditAuthpages.inbounds.batchEditUdpIdleTimeoutpages.inbounds.batchEditMasqueradepages.inbounds.batchEditMasqTypepages.inbounds.batchEditClearUdpMaskspages.inbounds.batchEditQuicParamspages.inbounds.batchEditCongestionpages.inbounds.batchEditDebugpages.inbounds.batchEditBrutalUppages.inbounds.batchEditBrutalDownpages.inbounds.batchEditUdpHoppages.inbounds.batchEditHopPortspages.inbounds.batchEditHopIntervalpages.inbounds.batchEditMaxIdlepages.inbounds.batchEditKeepAlivepages.inbounds.batchEditInitStreamRecvpages.inbounds.batchEditMaxStreamRecvpages.inbounds.batchEditMaxIncomingStreamspages.inbounds.batchEditDecryptionpages.inbounds.batchEditEncryptionpages.inbounds.batchEditMinVersionpages.inbounds.batchEditMaxVersionpages.inbounds.batchEditRejectUnknownSnipages.inbounds.batchEditDisableSystemRootpages.inbounds.batchEditSessionResumptionpages.inbounds.batchEditAlpnpages.inbounds.batchEditCipherSuitespages.inbounds.batchEditServerNamepages.inbounds.batchEditPublicKeypages.inbounds.batchEditShortIdpages.inbounds.batchEditSpiderXpages.inbounds.batchEditMldsaVerifypages.inbounds.batchEditModepages.inbounds.batchEditNoSseHeaderpages.inbounds.batchEditShowCurrentpages.inbounds.batchReorderpages.inbounds.batchReorderStartpages.inbounds.batchReorderSteppages.inbounds.batchReorderDragpages.inbounds.batchReorderMoveUppages.inbounds.batchReorderMoveDownpages.inbounds.batchReorderPreviewMockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Backend (API endpoints, login, settings)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 16, 2026):
This is a valid feature request. The panel has no bulk-edit capability for inbounds today, only bulk delete. Here is what was confirmed in the source and what the implementation would require.
What already exists (confirmed in source)
InboundList.tsxmaintainsselectedRowKeys: number[]and the toolbar already renders a bulk-delete button when the selection is non-empty (InboundList.tsx:54,117-120,175-180).POST /panel/api/inbounds/bulkDel(internal/web/controller/inbound.go:73) is the only bulk inbound endpoint. Its pattern — a request struct with anidsarray, per-item error reporting viaBulkDelInboundResult/BulkDelInboundReport, a single Xray restart flag, and one WebSocket broadcast — is the right template for a bulk-update endpoint.ClientBulkAdjustModal.tsx,BulkAttachInboundsModal.tsx,BulkDetachInboundsModal.tsx,BulkAddToGroupModal.tsx, andClientBulkAddModal.tsxall exist and show the established frontend pattern for bulk modal flows.POST /panel/api/inbounds/setEnable/:id(inbound.go:75) already handles the targeted single-field update case for the enable flag, for exactly the reason the request identifies: the fullUpdateInboundpath re-serialises the entire settings JSON including all clients, which is prohibitively heavy for interactive use on large inbounds.What would need to be added
Backend (Go):
POST /panel/api/inbounds/bulkUpdateroute and handler ininternal/web/controller/inbound.go, modelled afterbulkDelInbounds. The handler receives a request body containing the target IDs and a sparse diff (only fields the user touched), iterates over the IDs, applies the diff to each loaded inbound record, and collects per-item success/failure.internal/web/service/inbound.go— the request calls it something likeUpdateInboundPartial— that reads the existing row, overlays only the non-null diff fields, then delegates to the existingUpdateInboundmethod. The existingUpdateInboundsignature isfunc (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound, bool, error)(inbound.go:928), so the partial method sits on top of it rather than replacing it.streamSettingsandsniffingbecause those columns are stored as raw JSON strings in themodel.Inboundstruct, not as typed sub-structs at the GORM layer. Each affected sub-document needs to be unmarshalled, patched, and re-marshalled individually.Frontend (React/TypeScript):
BatchEditModalcomponent. The existingInboundFormModal(single-inbound edit) is not reusable here without significant rework — it is built around loading one complete record and binding every field. A dedicated modal is the right call, consistent with howClientBulkAdjustModalis kept separate from the single-client edit flow.SwitchorInputNumber. The modal will need a small wrapper that adds an explicit "keep original" state per field — either via a checkbox alongside each control or via a wrapper component.InboundList.tsxandInboundsPage.tsxwould each need minor additions: a "Batch Edit" button in the selection toolbar (alongside the existing delete button), state for the modal's open/closed status, and a prop chain to carry the selection into the modal.internal/web/translation/would need the new i18n keys. Theen-US.jsonkeys can be added first and other locales filled in via community contributions; the i18n engine falls back to the key string if a translation is missing, so the feature can ship without all 13 languages complete.Design notes from the request that hold up against the source
The proposal to avoid calling
update/:idN times from the frontend is correct. Each call toupdateInboundfetches the fullGetInboundrecord (which includes the fullsettingsJSON with all clients), serialises it back, validates it, and triggers a WebSocket broadcast. Doing this serially for 50 inbounds is slow and chatty. A singlebulkUpdatecall with one broadcast at the end is the right approach, matching the pattern already used bybulkDelInbounds.The partial-success semantics proposed (report skipped IDs with reasons, do not roll back successful ones) also match what
DelInbounds/BulkDelInboundResultalready does for bulk delete.Scope callout
The i18n section of the request lists ~65 new keys. That is a significant translation burden across 13 languages. Maintainers may want to scope the initial PR to
en-US.jsononly and accept follow-up PRs for other locales, as has been done in this repo before.If you plan to open a PR, the backend half (new route + service method) is a reasonable starting point and can be reviewed independently of the frontend modal.
This reply was generated automatically; a maintainer may follow up.