mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6517] [MERGED] feat(sub): add opt-in month-end expiry presentation #6324
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#6324
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6517
Author: @JacktheRanger
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @MHSanaei
Base:
main← Head:codex/calendar-expiry-presentation📝 Commits (1)
c0982befeat(sub): add opt-in month-end expiry presentation📊 Changes
32 files changed (+412 additions, -8 deletions)
View changed files
📝
docs/content/docs/en/config/subscription.mdx(+25 -0)📝
docs/public/openapi.json(+8 -0)📝
frontend/public/openapi.json(+8 -0)📝
frontend/src/generated/examples.ts(+2 -0)📝
frontend/src/generated/schemas.ts(+8 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/models/setting.ts(+1 -0)📝
frontend/src/pages/settings/SubscriptionGeneralTab.tsx(+11 -0)📝
frontend/src/schemas/setting.ts(+1 -0)➕
frontend/src/test/calendar-expire-setting.test.tsx(+27 -0)➕
internal/sub/calendar_expire.go(+21 -0)➕
internal/sub/calendar_expire_test.go(+241 -0)📝
internal/sub/clash_service.go(+1 -1)📝
internal/sub/controller.go(+1 -1)📝
internal/sub/json_service.go(+1 -1)📝
internal/sub/service.go(+20 -5)📝
internal/web/entity/entity.go(+1 -0)📝
internal/web/service/setting.go(+5 -0)📝
internal/web/translation/ar-EG.json(+2 -0)...and 12 more files
📄 Description
Motivation and research
Refs #6516. Presentation-only follow-up to #6300 and #6457; the calendar-renewal/accounting fix is not changed.
For AWS/Azure-style monthly allowances, the real cutoff remains the first of the following month at midnight, but an operator may want an existing subscription client's native expiry date to show the last valid day of the current month.
Clash Verge Rev's official header documentation describes expiry-card metadata from
Subscription-Userinfo. Its native card implementation formats that timestamp as a date. Adding a remark variable alone cannot change that native field.This PR is a draft for maintainer agreement on the explicit, opt-in compatibility tradeoff. The default continues reporting the exact cutoff.
User-facing behavior
Add Subscription → Information → Month-end subscription expiry display (
subCalendarExpireInclusive, defaultfalse).When enabled, report
expire = cutoff - 1 secondonly if:1.1at midnight in the configured panel timezone, and the immediately preceding second belongs to the previous month.Example in the same timezone: stored cutoff
2030-10-01 00:00:00→ subscription header2030-09-30 23:59:59.The last condition excludes a later repeated midnight during a DST rollback. Other renewal days, fixed-day interval mode, arbitrary/non-midnight times, fractional-midnight timestamps, legacy
23:59:59inputs, first-use durations, unlimited expiries, mixed modes, and differing cutoffs retain existing output.Raw/Base64, JSON, Clash/Mihomo, explicit Mihomo, and legacy Clash endpoints share the same formatter. The next subscription request reads a changed setting; clients still need to refresh cached metadata.
Implementation scope
Stored expiry, real access cutoff, calendar renewal, renewal allowances, traffic counters, Xray configuration, existing expiry remark variables, and HTML/
format=infopage cutoff remain unchanged.Validation
Environment: macOS arm64, Go 1.27.1, Node 24.19.0, golangci-lint 2.13.2.
go test ./internal/sub -run '^TestSubscriptionCalendarExpireInclusive' -count=1— passed. Real database + HTTP coverage across all five format routes; month lengths/leap year; UTC/Taipei/New York; Havana repeated midnight; fractional/arbitrary/legacy expiries; authoritative client renewal mode; mixed identities/cutoffs; settings save/read/on-off round trip; first-use normalization; canonical info cutoff and unchanged scheduling/accounting.go test -race -shuffle=on -count=1 ./internal/sub -run '^TestSubscriptionCalendarExpireInclusive'— passed.cd frontend && npm test -- --project components src/test/calendar-expire-setting.test.tsx— passed in a standalone run (one new case); checks default-off UI and the exact update payload.STORYBOOK_DISABLE_TELEMETRY=1 make verify— passed: codegen freshness, Go/frontend lint, frontend formatting/typecheck/MSW worker consistency, shuffled uncached Go suite, frontend unit/component/Chromium Storybook tests (150 files / 1,487 tests), production frontend + Go builds, and static Storybook build.cd docs && pnpm gen:api— regenerated successfully; API MDX unchanged.cd docs && pnpm typecheck,pnpm lint,pnpm test— passed (12 test files / 106 tests).git diff --check— passed.Red/green checks: the enabled month-end and all-calendar aggregate cases failed against unchanged production code before implementation. The later Havana midnight case failed without the previous-month guard and passed with it. The new UI case failed before the switch was added.
Not verified: importing into a running third-party client, live Xray/multi-node enforcement, live PostgreSQL, or the entire repository's race/vulnerability/fuzz gates. The default Go suite can skip environment-gated tests; no live compatibility claim is made.
Compatibility, privacy, and intentional exclusions
Enabling the option changes header semantics deliberately: apps receive the last-valid instant one second before the actual cutoff, and apps that treat metadata as a deadline may consider it expired one second early. Apps may format timestamps in their own timezone; a matching panel/client timezone is necessary for the same month-end date. The UI help and docs state these limitations.
Disabled remains the existing byte-for-byte header format/value. No credentials, subscription identities, extra user data, telemetry, or new network requests are added by this feature.
This does not add
VALID_THROUGH_*remark variables or change panel/info cutoff presentation, does not force client timezone/formatting, and does not refund renewal counts already consumed by the old bug. Those are separate from the native expiry-header goal.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.