[GH-ISSUE #6763] [Feature]: Conditional remark templates for limited and unlimited clients #4504

Open
opened 2026-10-31 20:40:07 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @nxabc on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6763

Yes.

The current subscription remark template looks inconsistent depending on whether traffic and expiration limits are enabled.

For example, when limits are enabled:

✅Tom|📊85GB|⏳30D

This contains useful information, but the remark can become quite long and may be truncated in some proxy clients.

When traffic and expiration limits are disabled, the remaining traffic and expiration fields disappear, leaving only something like:

✅Tom

This looks too short and visually empty.

So the same template can be too long in one situation and too short in another, which affects readability and overall appearance.

Describe the solution you'd like

I would like the remark template system to support conditional display logic based on whether traffic and expiration limits are enabled.

The goal is to let users freely combine existing variables such as:

{{STATUS_EMOJI}}
{{EMAIL}}
{{INBOUND}}
{{TRAFFIC_LEFT}}
{{DAYS_LEFT}}

depending on the client status.

For example:

Limited:
✅Tom|📊85GB|⏳30D

When traffic and expiration limits are disabled:

Unlimited:
✅美国-VLESS+Reality

Another possible layout could be:

Unlimited:
✅美国-VLESS+Reality-Tom

This shows why a general conditional mechanism would be more useful than adding one hard-coded variable.

A possible syntax could be:

{{IF_TRAFFIC_LIMITED}}
{{STATUS_EMOJI}}{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D
{{ELSE}}
{{STATUS_EMOJI}}{{INBOUND}}-{{EMAIL}}
{{END}}

The exact syntax is not important. The key requirement is that the same remark template can produce different layouts automatically depending on whether traffic or expiration limits are enabled.

Expected behavior:

  • If traffic is limited, show the limited-client layout.
  • If traffic is unlimited, show the unlimited-client layout.
  • If expiration is limited or unlimited, it should also be possible to use that as a condition.
  • Existing remark variables should remain backward compatible.
  • Separators such as -, |, icons, and text should be user-defined.
  • Empty conditional branches should not leave duplicate separators or extra spaces.

This would allow many different combinations and greatly improve the flexibility, readability, visual consistency, and overall appearance of subscription remarks.

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?

  • 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 @nxabc on GitHub (Oct 7, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6763 ### Is your feature request related to a problem? Yes. The current subscription remark template looks inconsistent depending on whether traffic and expiration limits are enabled. For example, when limits are enabled: ```text ✅Tom|📊85GB|⏳30D ``` This contains useful information, but the remark can become quite long and may be truncated in some proxy clients. When traffic and expiration limits are disabled, the remaining traffic and expiration fields disappear, leaving only something like: ```text ✅Tom ``` This looks too short and visually empty. So the same template can be too long in one situation and too short in another, which affects readability and overall appearance. ### Describe the solution you'd like I would like the remark template system to support conditional display logic based on whether traffic and expiration limits are enabled. The goal is to let users freely combine existing variables such as: ```text {{STATUS_EMOJI}} {{EMAIL}} {{INBOUND}} {{TRAFFIC_LEFT}} {{DAYS_LEFT}} ``` depending on the client status. For example: ```text Limited: ✅Tom|📊85GB|⏳30D ``` When traffic and expiration limits are disabled: ```text Unlimited: ✅美国-VLESS+Reality ``` Another possible layout could be: ```text Unlimited: ✅美国-VLESS+Reality-Tom ``` This shows why a general conditional mechanism would be more useful than adding one hard-coded variable. A possible syntax could be: ```text {{IF_TRAFFIC_LIMITED}} {{STATUS_EMOJI}}{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D {{ELSE}} {{STATUS_EMOJI}}{{INBOUND}}-{{EMAIL}} {{END}} ``` The exact syntax is not important. The key requirement is that the same remark template can produce different layouts automatically depending on whether traffic or expiration limits are enabled. Expected behavior: - If traffic is limited, show the limited-client layout. - If traffic is unlimited, show the unlimited-client layout. - If expiration is limited or unlimited, it should also be possible to use that as a condition. - Existing remark variables should remain backward compatible. - Separators such as `-`, `|`, icons, and text should be user-defined. - Empty conditional branches should not leave duplicate separators or extra spaces. This would allow many different combinations and greatly improve the flexibility, readability, visual consistency, and overall appearance of subscription remarks. ### 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? - [ ] I'd like to implement this feature myself and open a PR. - [ ] 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 (Oct 7, 2026):

This is a valid feature request. The remark template has no conditional (if / else) syntax today. All it can do with a limit is hide it: a |-separated segment that holds nothing but an unlimited quota or expiry is dropped. So ✅Tom|📊85GB|⏳30D turns into ✅Tom, and nothing can be shown in its place.

How it works now, from internal/sub/remark_vars.go:

  • expandRemarkVars (line 133) splits the template on | and expands each segment on its own: segments := strings.Split(template, "|"). Its doc comment states the intent: "an unlimited client gets "host" instead of "host|📊∞|⏳∞D"."
  • expandSegment (line 163) drops a segment when every token in it is empty or renders ∞. That only applies to the tokens in unlimitedDropTokens (lines 71-76): TRAFFIC_LEFT, TRAFFIC_TOTAL, DAYS_LEFT and TIME_LEFT.
  • The only placeholder pattern is `\{\{([A-Z_]+)\}\}` (line 41), and remarkVarValue (lines 193-290) has no condition or branch tokens. An unknown token such as {{IF_TRAFFIC_LIMITED}} resolves to "" (line 127: "Unknown tokens resolve to "" (never the literal text)").

What you can do today: separators already behave the way you want. Dropped | segments leave no stray |, and a - between two tokens is removed when one side is empty (lines 155-162). Only the unlimited/limited swap is missing. For example, this template:

{{STATUS_EMOJI}}{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D

gives ✅美国-VLESS+Reality-Tom for an unlimited client and ✅美国-VLESS+Reality-Tom|📊85GB|⏳30D for a limited one. The limited form is longer, which is the trade-off you describe. No current template can show {{INBOUND}} only when a client is unlimited.

What the feature would need: a conditional block in expandRemarkVars, evaluated before the | split. It would need at least two conditions: traffic limited (Total > 0) and expiry limited (ExpiryTime != 0). Existing templates would stay unchanged as long as they contain no block. Any new syntax also has to pass through filterRemarkTemplate (line 555), which strips usage tokens for some display contexts. It would also need to be reflected in the frontend token help and in the docs.

I found no earlier request for this. Related but different issues about the remark template: #5443, #5998, #5618.

Verdict: Feature request

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

<!-- gh-comment-id:6038322393 --> @github-actions[bot] commented on GitHub (Oct 7, 2026): This is a valid feature request. The remark template has no conditional (`if / else`) syntax today. All it can do with a limit is hide it: a `|`-separated segment that holds nothing but an unlimited quota or expiry is dropped. So `✅Tom|📊85GB|⏳30D` turns into `✅Tom`, and nothing can be shown in its place. How it works now, from `internal/sub/remark_vars.go`: - `expandRemarkVars` (line 133) splits the template on `|` and expands each segment on its own: `segments := strings.Split(template, "|")`. Its doc comment states the intent: *"an unlimited client gets "host" instead of "host|📊∞|⏳∞D"."* - `expandSegment` (line 163) drops a segment when every token in it is empty or renders `∞`. That only applies to the tokens in `unlimitedDropTokens` (lines 71-76): `TRAFFIC_LEFT`, `TRAFFIC_TOTAL`, `DAYS_LEFT` and `TIME_LEFT`. - The only placeholder pattern is `` `\{\{([A-Z_]+)\}\}` `` (line 41), and `remarkVarValue` (lines 193-290) has no condition or branch tokens. An unknown token such as `{{IF_TRAFFIC_LIMITED}}` resolves to `""` (line 127: *"Unknown tokens resolve to "" (never the literal text)"*). **What you can do today:** separators already behave the way you want. Dropped `|` segments leave no stray `|`, and a `-` between two tokens is removed when one side is empty (lines 155-162). Only the unlimited/limited swap is missing. For example, this template: ```text {{STATUS_EMOJI}}{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D ``` gives `✅美国-VLESS+Reality-Tom` for an unlimited client and `✅美国-VLESS+Reality-Tom|📊85GB|⏳30D` for a limited one. The limited form is longer, which is the trade-off you describe. No current template can show `{{INBOUND}}` *only* when a client is unlimited. **What the feature would need:** a conditional block in `expandRemarkVars`, evaluated before the `|` split. It would need at least two conditions: traffic limited (`Total > 0`) and expiry limited (`ExpiryTime != 0`). Existing templates would stay unchanged as long as they contain no block. Any new syntax also has to pass through `filterRemarkTemplate` (line 555), which strips usage tokens for some display contexts. It would also need to be reflected in the frontend token help and in the docs. I found no earlier request for this. Related but different issues about the remark template: #5443, #5998, #5618. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4504
No description provided.