Skip to content

fix(studio): export users against the committed search term - #4263

Closed
unbridled-41 wants to merge 1 commit into
apache:rocketmq-studiofrom
unbridled-41:fix/user-export-committed-search
Closed

unbridled-41 wants to merge 1 commit into
apache:rocketmq-studiofrom
unbridled-41:fix/user-export-committed-search

Conversation

@unbridled-41

Copy link
Copy Markdown
Contributor

Fixes #4262.

Problem / Evidence

The studio user inventory loads its table from a debounced (committed) search (listStudioUsers receives search: debouncedSearch || undefined, UserManagement.tsx:134), but the "导出" (export) button rebuilt its query from the live input value (search: search.trim() || undefined, UserManagement.tsx:268, with the live search in its dependency array at line 282). Typing a refinement and clicking export within the 300 ms debounce window - or while the matching refetch is still in flight - downloaded a CSV for a search the displayed table never showed.

Regression test red on 6c24d2e: after the debounce settles on alpha, refining the input to alpha-beta and exporting synchronously makes the export API receive search: "alpha-beta" while the table still shows the alpha results. Sibling pages already do this correctly: ops/audit.tsx exports from debouncedSearchText, settings/CloudCredentialTab.tsx and settings/DataSourceTab.tsx from their debouncedSearch.

Root cause / Fix

handleExportUsers now sends search: debouncedSearch || undefined - the committed value the visible table was loaded with - and reads debouncedSearch (instead of search) in its dependency array. This is the export-side twin of the committed-query semantics established by #4005 for the message page pagination.

Priority & scoring

PRIORITY 70 = 影响 26(导出物是本页的审计/清单工件,内容与用户所见列表不一致且静默发生)+ 波及 11(仅本页导出按钮)+ 可复现 18(防抖窗口内"输入→导出"是常规操作序列,确定性复现)+ 维护价值 15(#4005 既有语义的导出孪生,三个兄弟页已正确,一致性收敛)。FIX_CONFIDENCE 95:单值替换 + 依赖数组同步,行为由兄弟页与既有测试共同锚定。

Tests

  • New regression UserManagementPage > exports users matching the committed search, not live input is deterministic: after the committed search is awaited, the refinement and the export click run inside one synchronous act block so the 300 ms debounce cannot commit in between (a first draft that raced the real 300 ms timer proved load-fragile under the full suite and was rewritten before commit). Red on unfixed code (Tests run: 7, 1 failed - export received alpha-beta) and green after the fix (7 passed), verified by stashing the fix.
  • Module suite: UserManagement.test.tsx 7/7 passed (re-run after the lint-staged reformat).
  • Full web suite on this branch (npx vitest run): 982 tests, 979 passed, 3 failures - all in untouched files from the known load-fragile family (MetricsExplorer.test.tsx ×1, ConsumerPage.test.tsx ×2); both files pass isolated (25/25 and 31/31). My test passes in the full run.
  • tsc -b clean, eslint clean on both touched files, npm run build succeeds (built in 9.67s).

Risk

Low: one-value change scoped to the export handler; filtering semantics (admin/enabled) untouched. Users who typed a new term and waited for the table to refresh see identical behavior; only the stale-window export changes, from "unseen query" to "displayed query".

The user inventory table loads from the debounced (committed) search, but
`handleExportUsers` rebuilt its query from the live input value. Typing a
refinement and clicking export within the 300 ms debounce window downloaded a
CSV for a search the displayed table never showed - and an in-flight refetch
was bypassed the same way. The export now sends `debouncedSearch`, the same
value the visible table was loaded with, matching how the audit, cloud
credential and data source pages already scope their exports.

Regression test: commits a search, refines the input, and exports inside one
synchronous block so the debounce cannot commit in between; the export request
must still carry the committed term.
@unbridled-41

unbridled-41 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Verification evidence

  • CI (this head): run 34730761774 ("CI", pull_request, head e9455a81008a1ca58b1bd2907826ff2c26b37e97) — conclusion startup_failure, check-runs 0. Upstream workflow fails at startup for every branch (unapproved Docker actions, [studio] CI workflow fails at startup due to unapproved Docker actions #4136); local verification below covers the compile/test/build surface.
  • Red (actual output, on 6c24d2e code): UserManagement.test.tsx > exports users matching the committed search, not live input — waitFor timed out because downloadStudioUsers (the export API) was called with search: 'alpha-beta' (the live input) instead of search: 'alpha' (the committed value). Summary Tests 1 failed | 6 passed (7). Verified with the fix stashed; restored for the green run.
  • Module tests (after fix): UserManagement.test.tsx 7/7 passed, re-run after lint-staged's prettier reformat.
  • Full suite + baseline: npx vitest run on this branch → 982 tests, 979 passed, 3 failures — all in untouched files of the known load-fragile family (MetricsExplorer.test.tsx > restores profile, range, and source from query history, ConsumerPage.test.tsx > shows group health diagnostics... + > invalidates the reset preview...). Isolation re-runs: MetricsExplorer 25/25, ConsumerPage 31/31 — load fragility, not regressions. The new test passes inside the full run. (Pristine-baseline correction: a fresh npx vitest run in a clean worktree at 6c24d2e measures 981 tests with 3 load-fragile failures (NotificationDeliveriesPage x1, MetricsExplorer x1, ConsumerPage x1 - the per-run fragile set varies run to run), so this branch's 982 = 981 pristine + 1 new regression; the earlier "982" recordings across rounds 8-13 were branch totals that each carried their own new tests.)
  • Build: npm run build succeeds (✓ built in 9.67s); npx tsc -b clean; npx eslint clean on both touched files (0 error / 0 warning).
  • Diff self-check: git show --numstat = web/src/pages/studio/UserManagement.tsx +4/−2, web/src/pages/studio/__tests__/UserManagement.test.tsx +36/−0. 2 files, no unrelated changes.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — code changes look good.


Automated review by github-manager-bot

lizhimins pushed a commit that referenced this pull request Sep 16, 2026
#4331)

Incorporates ten related front-end fixes from the same author:

- #4175 render the rule last-triggered time as UTC
- #4189 keep the selected range when the metrics instance changes
- #4245 reload the paginated group list after creating groups
- #4249 edit topic configuration from the topic page
- #4254 reset the silence form when the maintenance dialog is dismissed
- #4263 export users against the committed search term
- #4265 re-run the custom query when the dashboard instance changes
- #4283 reset the queue browser pull indicators when the queue list reloads
- #4285 surface the validation reason when a silence cannot be built
- #4322 invalidate the in-flight connection query when the topic changes
@lizhimins

Copy link
Copy Markdown
Member

Merged as part of #4331 — squashed into rocketmq-studio as 6334f9238.

Your change here (exporting users against the committed search term) is included.

We grouped 11 of your related front-end fixes into a single commit so the history stays reviewable; the other PRs in the group are closed with the same note. Everything was cherry-picked onto the current baseline with you kept as the author, and your tests came along with the change.

Thanks for the consistently well-tested patches.

@lizhimins lizhimins closed this Sep 16, 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.

3 participants