This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 7352b09cd fix(message): keep a manually refreshed trace when the tab 
is re-entered (#5956)
7352b09cd is described below

commit 7352b09cde21e963cfb3e68507ee887bb24bfe80
Author: 烤化の初雪 <[email protected]>
AuthorDate: Fri Nov 27 12:15:52 2026 +0800

    fix(message): keep a manually refreshed trace when the tab is re-entered 
(#5956)
---
 .../__tests__/MessagePageAsyncState.test.tsx       | 28 ++++++++++++++++++++++
 web/src/pages/instance/message.tsx                 |  9 +++++++
 2 files changed, 37 insertions(+)

diff --git a/web/src/pages/instance/__tests__/MessagePageAsyncState.test.tsx 
b/web/src/pages/instance/__tests__/MessagePageAsyncState.test.tsx
index 82317ef73..50c993dfb 100644
--- a/web/src/pages/instance/__tests__/MessagePageAsyncState.test.tsx
+++ b/web/src/pages/instance/__tests__/MessagePageAsyncState.test.tsx
@@ -377,6 +377,34 @@ describe('MessagePage async request ownership', () => {
     expect(serviceMocks.getMessageTrace).toHaveBeenCalledTimes(1);
   });
 
+  it('keeps a manually refreshed trace when the tab is re-entered', async () 
=> {
+    serviceMocks.queryMessages.mockResolvedValue([createMessage('message-a')]);
+    serviceMocks.getMessageTrace
+      .mockResolvedValueOnce(createTrace('first-trace'))
+      .mockResolvedValueOnce(createTrace('refreshed-trace'));
+    const user = userEvent.setup({ pointerEventsCheck: 0 });
+    renderPage();
+    await selectTopic(user);
+
+    await user.click(screen.getByRole('button', { name: /^search查询$/ }));
+    const row = await screen.findByRole('row', { name: /message-a/ });
+    await user.click(within(row).getByRole('button', { name: /详情/ }));
+    const dialog = await screen.findByRole('dialog', { name: '消息详情' });
+
+    await user.click(within(dialog).getByText('消息轨迹'));
+    expect(await within(dialog).findByText('first-trace 
description')).toBeInTheDocument();
+
+    // An explicit lookup of the same msgId supersedes the cached snapshot ...
+    await user.click(within(dialog).getByRole('button', { name: /查询轨迹/ }));
+    expect(await within(dialog).findByText('refreshed-trace 
description')).toBeInTheDocument();
+
+    // ... and a tab round-trip must not bring the superseded one back.
+    await user.click(within(dialog).getByText('消息内容'));
+    await user.click(within(dialog).getByText('消息轨迹'));
+    expect(await within(dialog).findByText('refreshed-trace 
description')).toBeInTheDocument();
+    expect(within(dialog).queryByText('first-trace 
description')).not.toBeInTheDocument();
+  });
+
   it('requiresGroupAndClientBeforeDirectConsumeTest', async () => {
     serviceMocks.queryMessages.mockResolvedValue([createMessage('message-a')]);
     serviceMocks.consumeMessageDirectly.mockResolvedValue({
diff --git a/web/src/pages/instance/message.tsx 
b/web/src/pages/instance/message.tsx
index b5d1d8c8e..7210060aa 100644
--- a/web/src/pages/instance/message.tsx
+++ b/web/src/pages/instance/message.tsx
@@ -800,6 +800,15 @@ const MessagePageContent = ({
       if (traceGenerationRef.current !== requestGeneration) return;
       setTraceData(result);
       setTraceError(null);
+      // The tab entry reads a per-message cache, so a manual lookup has to 
publish its fresher
+      // result there: otherwise switching tabs and coming back re-serves the 
snapshot this query
+      // just superseded.
+      if (traceQueryMode === 'msgid' && selectedMsg) {
+        traceCacheRef.current.set(
+          JSON.stringify([selectedInstanceId, selectedMsg.topic, value, 
customTraceTopic.trim()]),
+          Promise.resolve(result),
+        );
+      }
     } catch (error) {
       if (traceGenerationRef.current === requestGeneration) {
         setTraceError(describeThrownMessage(error) || 
t('messagePage.traceLoadFailed'));

Reply via email to