[PR #6502] [MERGED] fix(clients): preserve traffic reset schedule when toggling enable #6312

Closed
opened 2026-11-02 04:07:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6502
Author: @alireza4682
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei

Base: main ← Head: fix/client-toggle-traffic-reset


📝 Commits (1)

  • ffb2278 fix(clients): preserve traffic reset schedule when toggling enable

📊 Changes

2 files changed (+54 additions, -0 deletions)

View changed files

📝 frontend/src/hooks/useClients.ts (+2 -0)
➕ frontend/src/test/client-toggle-traffic-reset.test.tsx (+52 -0)

📄 Description

Summary

Preserve trafficReset and trafficResetDay from the hydrated client when toggling its enabled state in the clients list.

Why

The toggle builds a replacement update payload but omits these two fields. ClientService.Update normalizes the absent cycle to never, so toggling a client configured for monthly resets on day 15 silently removes its schedule. Both enable and disable now retain that schedule.

Type of change

  • Bug fix

Areas affected

  • Frontend (UI / panel pages)
  • Statistics / traffic counters

How was this tested?

  • Added a hook regression test for both toggle directions. It starts with a stale list row and checks that the HTTP update carries the freshly hydrated monthly/day-15 schedule.
  • Confirmed both cases fail on the original implementation and pass with the fix.
  • npm test -- --project unit --project components: 120 files / 1,383 tests passed.
  • npm run lint, npm run typecheck, npm run build, and formatting checks for the changed files passed.
  • Follow-up verification with Go 1.27.1: make test-go passed on macOS with local socket access enabled. This does not cover the environment-gated PostgreSQL, Xray E2E, or scale tests.
  • The complete make verify gate has not passed. Storybook browser testing is blocked locally: downloading Chromium returns a location-based HTTP 403, and the installed-Chrome fallback exits during launch. Keeping this PR as draft pending complete verification.

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior through the hook's HTTP payload.
  • I added regression tests for the new behavior.
  • go build ./... and the full test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • 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/6502 **Author:** [@alireza4682](https://github.com/alireza4682) **Created:** 9/13/2026 **Status:** ✅ Merged **Merged:** 9/13/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/client-toggle-traffic-reset` --- ### 📝 Commits (1) - [`ffb2278`](https://github.com/MHSanaei/3x-ui/commit/ffb227876aa045485d415523fce062b43e4fe923) fix(clients): preserve traffic reset schedule when toggling enable ### 📊 Changes **2 files changed** (+54 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/hooks/useClients.ts` (+2 -0) ➕ `frontend/src/test/client-toggle-traffic-reset.test.tsx` (+52 -0) </details> ### 📄 Description ## Summary Preserve `trafficReset` and `trafficResetDay` from the hydrated client when toggling its enabled state in the clients list. ## Why The toggle builds a replacement update payload but omits these two fields. `ClientService.Update` normalizes the absent cycle to `never`, so toggling a client configured for monthly resets on day 15 silently removes its schedule. Both enable and disable now retain that schedule. ## Type of change - [x] Bug fix ## Areas affected - [x] Frontend (UI / panel pages) - [x] Statistics / traffic counters ## How was this tested? - Added a hook regression test for both toggle directions. It starts with a stale list row and checks that the HTTP update carries the freshly hydrated monthly/day-15 schedule. - Confirmed both cases fail on the original implementation and pass with the fix. - `npm test -- --project unit --project components`: 120 files / 1,383 tests passed. - `npm run lint`, `npm run typecheck`, `npm run build`, and formatting checks for the changed files passed. - Follow-up verification with Go 1.27.1: `make test-go` passed on macOS with local socket access enabled. This does not cover the environment-gated PostgreSQL, Xray E2E, or scale tests. - The complete `make verify` gate has not passed. Storybook browser testing is blocked locally: downloading Chromium returns a location-based HTTP 403, and the installed-Chrome fallback exits during launch. Keeping this PR as draft pending complete verification. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior through the hook's HTTP payload. - [x] I added regression tests for the new behavior. - [ ] `go build ./...` and the full test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [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>
bsakaguchi 2026-11-02 04:07:52 +07:00
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#6312
No description provided.