unbridled-41 opened a new pull request, #4752:
URL: https://github.com/apache/rocketmq-dashboard/pull/4752

   Fixes #4751.
   
   ## Problem
   
   Switching the dead-letter message detail drawer to another group keeps the 
previous group's rows and total. The header switches to the new group; the 
payload below it does not.
   
   - `web/src/pages/instance/dlq.tsx:336-347` — `openDetailDrawer` cleared 
`detailPage`, `detailSelectedMsgIds` and `detailError`, but not 
`detailMessages`/`detailTotal`.
   - `web/src/pages/instance/dlq.tsx:353-382` — `loadDetailMessages` writes 
rows and total only on success, so a rejection leaves the previous payload in 
place and only adds `detailError`.
   - Render state driven by that payload: `dataSource={detailMessages}` 
(`:916`) under the new title (`:828`), `disabled={detailTotal === 0}` for the 
export (`:895`), and the batch resend acting on the visible stale selection 
(`:986-996`).
   
   Result: group A's messages appear under group B's title while B loads, stay 
there if B's load fails, and can be exported or resend in bulk for the wrong 
group.
   
   ## Root cause
   
   `openDetailDrawer` treated a group change as no scope change at all. The 
file already clears that payload on the other two scope changes — the 
instance/refresh block (`:166-190`, the pair at `:176-177`) and the drawer's 
close handler (`:838`), both added by #4487 for exactly this reason — so the 
group switch was the single uncovered case.
   
   ## Fix
   
   Clear `detailMessages`/`detailTotal` in `openDetailDrawer` (4 lines 
including the comment), so the drawer starts empty for the group being opened. 
A failed or in-flight load now renders the header, the error and an empty table 
with the export disabled, instead of the previous group's messages.
   
   ## Tests
   
   Red before the fix (`web/src/pages/instance/__tests__/DLQPage.test.tsx`, new 
case "drops the previous group messages when the next detail load fails"):
   
   ```
    FAIL  src/pages/instance/__tests__/DLQPage.test.tsx > DLQ page > drops the 
previous group messages when the next detail load fails
    ❯ src/pages/instance/__tests__/DLQPage.test.tsx:304:59
      expect(screen.queryByText('order-dead-letter-1')).not.toBeInTheDocument()
      Tests  1 failed | 21 passed (22)
   ```
   
   Commands and results after the fix, run from `web/`:
   
   - `npx vitest run src/pages/instance/__tests__/DLQPage.test.tsx 
--maxWorkers=2` → **22 passed** (1 file).
   - `npx vitest run src/pages/instance --maxWorkers=2` → **170 passed** (8 
files), including the pre-existing "does not let an old-instance detail resend 
overwrite the new instance drawer" race coverage.
   - `npx tsc -b` → clean; `npx eslint src/pages/instance/dlq.tsx 
src/pages/instance/__tests__/DLQPage.test.tsx` → 0 errors (1 pre-existing 
`react-refresh/only-export-components` warning on `dlq.tsx:82`, untouched by 
this change).
   
   The new case asserts all three consequences: the error is shown, the 
previous group's row is gone, and the export button is disabled.
   
   ## Duplicate check
   
   Searched open PRs (205) and issues (214) for `dlq`, `detailMessages`, 
`消息明细`, `drawer`, `stale detail`, `switch group`: the DLQ items are #4407 
(backlog analysis), #4577/#4579 (the group *search* term surviving an instance 
switch), #4592 (queues abandoned mid-scan), #4677 (parallel group stats), #4702 
(Excel redelivery count), #4718 (zero-length window) — none covers the drawer 
payload. The historical #4487 isolated the instance switch and the drawer close 
only.
   
   ## Base branch
   
   Targets the development trunk `rocketmq-studio`. GitHub interprets closing 
keywords only for pull requests that target the repository default branch, and 
that is still `master`, so merging will not close #4751 automatically — it 
needs to be closed by hand.
   
   ## Risk
   
   Low: the drawer starts empty for the newly opened group, which is what the 
same file already does when the drawer closes and when the instance changes. 
Pagination and the in-place reload after a resend are untouched.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to