[GH-ISSUE #6237] [Feature]: Add client autocomplete/browser to routing rule fields #4234

Open
opened 2026-10-31 20:38:10 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @neerro on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6237

The recently merged pull request (#6165) introduced a fantastic "category browser" for geosite and geoip databases, which solves the problem of having to remember and type category names from memory for routing rules.

However, this problem also exists for Client fields. In many routing rules, such as those that route traffic to or from specific clients (e.g., in "outbound" or "fallback" rules), we need to specify a client by their email or ID.

Currently, the user must type the client identifier manually. This is error-prone and inconvenient, especially when a panel has many clients. A typo here means the rule will not apply to the intended client, and the panel provides no immediate feedback or help to prevent this.

Describe the solution you'd like

I would like to see the same pattern used in the source-IP, IP, and domain fields (#6165) applied to any field in the rule form that expects a client identifier (usually email).

Specifically, I propose that for client selection fields in the routing form:

A "database" button (or a similar "browse clients" button) is added next to the client input field.

Clicking this button opens a browser modal that displays a searchable list of all existing clients currently configured in the panel.

The user can search, preview, and multi-select clients from this list.

Upon selection, the chosen client identifiers (emails) are merged into the field in the correct format (e.g., a comma-separated list).

The field should also support validation to check if a typed identifier matches an existing client, providing a warning if not.

Why this is important

This enhancement would bring a consistent UX to the routing rules panel, making it much more user-friendly. It eliminates guesswork, reduces errors, and makes the panel more accessible, especially for users managing complex routing configurations with many clients.

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

This is a natural extension of the UX introduced in #6165.

The backend could expose a new endpoint (e.g., /panel/api/xray/clients) to list all available clients (emails) from the inbound configurations for the browser to use.

The frontend component (GeoTokenInput or a similar component) could be adapted to accept a "type" prop (e.g., type="client"), which would then fetch data from a different API source to power its browser modal.

Which parts of the panel would this affect?

Frontend (UI / panel pages)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @neerro on GitHub (Aug 17, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6237 ### Is your feature request related to a problem? The recently merged pull request (#6165) introduced a fantastic "category browser" for geosite and geoip databases, which solves the problem of having to remember and type category names from memory for routing rules. However, this problem also exists for Client fields. In many routing rules, such as those that route traffic to or from specific clients (e.g., in "outbound" or "fallback" rules), we need to specify a client by their email or ID. Currently, the user must type the client identifier manually. This is error-prone and inconvenient, especially when a panel has many clients. A typo here means the rule will not apply to the intended client, and the panel provides no immediate feedback or help to prevent this. ### Describe the solution you'd like I would like to see the same pattern used in the source-IP, IP, and domain fields (#6165) applied to any field in the rule form that expects a client identifier (usually email). Specifically, I propose that for client selection fields in the routing form: A "database" button (or a similar "browse clients" button) is added next to the client input field. Clicking this button opens a browser modal that displays a searchable list of all existing clients currently configured in the panel. The user can search, preview, and multi-select clients from this list. Upon selection, the chosen client identifiers (emails) are merged into the field in the correct format (e.g., a comma-separated list). The field should also support validation to check if a typed identifier matches an existing client, providing a warning if not. **Why this is important** This enhancement would bring a consistent UX to the routing rules panel, making it much more user-friendly. It eliminates guesswork, reduces errors, and makes the panel more accessible, especially for users managing complex routing configurations with many clients. ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples This is a natural extension of the UX introduced in #6165. The backend could expose a new endpoint (e.g., /panel/api/xray/clients) to list all available clients (emails) from the inbound configurations for the browser to use. The frontend component (GeoTokenInput or a similar component) could be adapted to accept a "type" prop (e.g., type="client"), which would then fetch data from a different API source to power its browser modal. ### Which parts of the panel would this affect? Frontend (UI / panel pages) ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 17, 2026):

The request is accurate about the current state of the form, and most of what it asks for can be built without the new backend endpoint you propose.

Confirmed in the source:

  • In frontend/src/pages/xray/routing/RuleFormModal.tsx, the ip field (line 257) and the domain field (line 268) render <GeoTokenInput>, while the user field (lines 271-280) is a plain <Input placeholder="email address" />. The inconsistency you describe is real.
  • The neighbouring inboundTag, outboundTag and balancerTag fields in that same form (lines 293-313) are already <Select>s populated from existing panel data, so a data-driven picker here follows an established pattern.

On the proposed /panel/api/xray/clients endpoint, that data is already served:

  • GET /panel/api/clients/list is registered at internal/web/controller/client.go:48 and returns every client with email, group, enable and inboundIds.
  • GET /panel/api/clients/list/paged sits next to it (client.go:49) and accepts search and filter query params, which is the better source for a panel with many clients.
  • frontend/src/pages/inbounds/clients/AttachExistingClientsModal.tsx:58 already consumes /panel/api/clients/list to render close to the UI you describe: a searchable, group-filterable, multi-select client table. A routing-rule picker could reuse that shape instead of adding an endpoint.

The validation half is also well-defined. ClientRecord.Email is unique panel-wide (gorm:"uniqueIndex;not null", internal/database/model/model.go:903), and the email written into an inbound's settings.clients is the identity key Xray itself sees (splitSettingsClients, internal/xray/hot_diff.go:211-213). So "does this typed string match an existing client" has an exact answer, and it can be answered in the browser from the already-fetched list, with no server round-trip. Geodata validation needs one (GeoTokenInput.tsx:41, debounced 600 ms at line 14), which is why the two cases are not symmetric.

Two points worth settling before any implementation:

  1. Adapting GeoTokenInput through a type prop, as suggested, would mix an unrelated data source and a different validation path into a component that is currently geodata-specific: it hardcodes GeoBrowserModal and the geodata warning keys (GeoTokenInput.tsx:18-24 and 104-113). A separate small component reusing the same addonAfter database-button pattern may stay cleaner. That is a maintainer call.
  2. A client browser would list every panel client, but routing rules only apply to traffic that goes through Xray. MTProto inbounds run in a separate mtg-multi process outside Xray (internal/mtproto/), so a client that exists only on an MTProto inbound would never be matched by a user rule. Whether the picker filters or marks those is worth deciding up front. This second point is inferred from the process architecture, not from a specific matching routine I read.

I found no existing issue requesting this, so it stays open with the enhancement label as filed.

@MHSanaei for a decision on whether to take this, and on which of the two component shapes above to prefer.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5313640822 --> @github-actions[bot] commented on GitHub (Aug 17, 2026): The request is accurate about the current state of the form, and most of what it asks for can be built without the new backend endpoint you propose. Confirmed in the source: - In `frontend/src/pages/xray/routing/RuleFormModal.tsx`, the `ip` field (line 257) and the `domain` field (line 268) render `<GeoTokenInput>`, while the `user` field (lines 271-280) is a plain `<Input placeholder="email address" />`. The inconsistency you describe is real. - The neighbouring `inboundTag`, `outboundTag` and `balancerTag` fields in that same form (lines 293-313) are already `<Select>`s populated from existing panel data, so a data-driven picker here follows an established pattern. On the proposed `/panel/api/xray/clients` endpoint, that data is already served: - `GET /panel/api/clients/list` is registered at `internal/web/controller/client.go:48` and returns every client with `email`, `group`, `enable` and `inboundIds`. - `GET /panel/api/clients/list/paged` sits next to it (`client.go:49`) and accepts `search` and `filter` query params, which is the better source for a panel with many clients. - `frontend/src/pages/inbounds/clients/AttachExistingClientsModal.tsx:58` already consumes `/panel/api/clients/list` to render close to the UI you describe: a searchable, group-filterable, multi-select client table. A routing-rule picker could reuse that shape instead of adding an endpoint. The validation half is also well-defined. `ClientRecord.Email` is unique panel-wide (`gorm:"uniqueIndex;not null"`, `internal/database/model/model.go:903`), and the email written into an inbound's `settings.clients` is the identity key Xray itself sees (`splitSettingsClients`, `internal/xray/hot_diff.go:211-213`). So "does this typed string match an existing client" has an exact answer, and it can be answered in the browser from the already-fetched list, with no server round-trip. Geodata validation needs one (`GeoTokenInput.tsx:41`, debounced 600 ms at line 14), which is why the two cases are not symmetric. Two points worth settling before any implementation: 1. Adapting `GeoTokenInput` through a `type` prop, as suggested, would mix an unrelated data source and a different validation path into a component that is currently geodata-specific: it hardcodes `GeoBrowserModal` and the geodata warning keys (`GeoTokenInput.tsx:18-24` and `104-113`). A separate small component reusing the same `addonAfter` database-button pattern may stay cleaner. That is a maintainer call. 2. A client browser would list every panel client, but routing rules only apply to traffic that goes through Xray. MTProto inbounds run in a separate `mtg-multi` process outside Xray (`internal/mtproto/`), so a client that exists only on an MTProto inbound would never be matched by a `user` rule. Whether the picker filters or marks those is worth deciding up front. This second point is inferred from the process architecture, not from a specific matching routine I read. I found no existing issue requesting this, so it stays open with the `enhancement` label as filed. @MHSanaei for a decision on whether to take this, and on which of the two component shapes above to prefer. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@neerro commented on GitHub (Aug 17, 2026):

I'd like to expand this. The panel recently introduced the Group feature, which allows organizing users by themes or categories. This is extremely useful for administrators.

Therefore, I propose we go a step further and add the ability to select not only clients but also client groups in the routing rule form.

Here's how I envision this working:

  1. A new field (or option), such as User Group, appears in the routing rule form.
  2. This field would also include a "browse" button, similar to the GeoTokenInput component introduced in #6165.
  3. Clicking it opens a modal window with a searchable list of all existing groups created in the panel.
  4. You can select one or multiple groups (multi-select), just like with clients.
  5. Upon application, the selected groups would be translated into a format Xray understands. Since Xray operates at the email level, this likely means the rule should expand to a list of user emails belonging to the selected groups.

Why this is beneficial:

  • Scalability: If you have 100+ clients organized into groups (e.g., "Premium Subscription", "Free Tier", "Corporate"), configuring rules per group is far more efficient than configuring them per individual client.
  • Centralized Management: A rule applied to a group automatically extends to all new clients added to that group, without needing to edit the routing rules each time.
  • Consistency: This extends the same core philosophy as PR #6165 (assisting with field input) but at a higher, more logical level (groups → clients/emails).

I believe this would become a highly valued feature for administrators managing large user bases.

<!-- gh-comment-id:5314754139 --> @neerro commented on GitHub (Aug 17, 2026): I'd like to expand this. The panel recently introduced the **Group** feature, which allows organizing users by themes or categories. This is extremely useful for administrators. Therefore, I propose we go a step further and add the ability to select not only **clients** but also **client groups** in the routing rule form. **Here's how I envision this working:** 1. A new field (or option), such as `User Group`, appears in the routing rule form. 2. This field would also include a "browse" button, similar to the `GeoTokenInput` component introduced in #6165. 3. Clicking it opens a modal window with a searchable list of all existing groups created in the panel. 4. You can select **one or multiple groups** (multi-select), just like with clients. 5. Upon application, the selected groups would be translated into a format Xray understands. Since Xray operates at the `email` level, this likely means the rule should expand to a list of `user` emails belonging to the selected groups. **Why this is beneficial:** * **Scalability:** If you have 100+ clients organized into groups (e.g., "Premium Subscription", "Free Tier", "Corporate"), configuring rules per group is far more efficient than configuring them per individual client. * **Centralized Management:** A rule applied to a group automatically extends to all new clients added to that group, without needing to edit the routing rules each time. * **Consistency:** This extends the same core philosophy as PR #6165 (assisting with field input) but at a higher, more logical level (groups → clients/emails). I believe this would become a highly valued feature for administrators managing large user bases.
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#4234
No description provided.