Skip to content

fix(inbounds): list clients in the detach/attach modals when they mount open - #6736

Merged
MHSanaei merged 3 commits into
MHSanaei:mainfrom
drakeo338:claude/6733-fix
Oct 5, 2026
Merged

MHSanaei merged 3 commits into
MHSanaei:mainfrom
drakeo338:claude/6733-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

Summary

The detach and attach client modals now load their client rows when first mounted already open.

Why

Fixes #6733. DetachClientsModal (and AttachClientsModal, same pattern) seeded its synced-source state so a modal first mounted open saw no change on first render and never loaded the rows; the table stayed empty until closed and reopened. Both now load on mount when open.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Added detach-clients-modal and attach-clients-modal tests that mount the modal open; both fail on the base commit and pass with the fix.

Screenshots / recordings

N/A

Breaking changes

None

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

Not ticked: I ran only the two new tests on HEAD, not go build, lint, typecheck, or the full build.

DetachClientsModal seeded its synced-source state with the open source,
so a modal first mounted with open and a source saw no change on its
first render and never read the client rows. The table stayed empty
until the modal was closed and reopened.

Seed the state with null so the first open render loads the rows, as
the reset-during-render check already expects. The test mounts the
modal already open and fails without this change.

Fixes MHSanaei#6733
AttachClientsModal seeds its synced-source state the same way
DetachClientsModal did, so a modal first mounted with open and a source
saw no change on its first render and never read the client rows. The
table stayed empty, and nothing was pre-selected, until the modal was
closed and reopened.

Seed the state with null here too. The test mounts the attach modal
already open and fails without this change.

Refs MHSanaei#6733
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No blocking issues. 0 HIGH / 0 MEDIUM / 1 LOW, 0 pre-existing

  • LOW: CI never ran on this head. The CI workflow run (pull_request) for b23a3cb sits at action_required, waiting for a maintainer to approve it as a fork run. The only check run on the commit is this review job. So make verify, which covers the two new Vitest files, typecheck and lint, has not run here, and the PR body says the author ran only the two new tests. Nothing below is confirmed by CI.

The fix is correct as read. Before the change, useState(openSource) seeded syncedSource with the value that was already open. InboundsPage.tsx mounts both modals under LazyMount when={…Open}, so their first render always has open === true, and the openSource !== syncedSource branch was skipped on that render. That is the empty table #6733 reports. With a null seed, the branch runs on the first open render (DetachClientsModal.tsx:57, AttachClientsModal.tsx:63). Closing still resets syncedSource to null, so reopening loads the rows again as before.

Reviewed head: b23a3cb

Coverage (4 files, +81/−2):

  • Issue [Bug]: Attached clients list is empty on the first opening of "Unlink Clients" #6733 (Detach empty on first open): fixed. The issue bot's root cause matches the diff. The same seed in Attach is fixed too.
  • DetachClientsModal.tsx / AttachClientsModal.tsx: the render-time sync branch was read for the first-mount, close and reopen paths. No double-load and no render loop: the branch converges once syncedSource === openSource.
  • Other useState(open…) seeds in the head: AttachExistingClientsModal.tsx:54 fetches in a useEffect gated only on open && target, so its list still loads. The seed only skips the initial setLoading(true). ClientInfoModal.tsx:142 and ClientQrModal.tsx:390 only clear state on close. HostFormModal.tsx:102 is mounted directly in HostsPage.tsx:225, not under LazyMount. I found no visible empty-list symptom in any of them.
  • Tests: both new tests mount the modal already open and assert the row emails, and Attach also asserts the row checkboxes are checked. Reading the base code, clientRows stays [] on first render, so both tests would fail on base. This was read, not run, because CI did not execute.
  • No backend, wire-format, endpoint, migration or workflow files are touched.

@MHSanaei
MHSanaei merged commit d4a7086 into MHSanaei:main Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Attached clients list is empty on the first opening of "Unlink Clients"

2 participants