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

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


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new df805305b fix(web): render message query history timestamps as UTC 
(#4222)
df805305b is described below

commit df805305b56b10a6981a13bf950888201f5727f3
Author: halaxy <[email protected]>
AuthorDate: Wed Sep 16 16:00:05 2026 +0800

    fix(web): render message query history timestamps as UTC (#4222)
    
    Backend stamps queriedAt/latestQueryAt with Clock.systemUTC() into
    LocalDateTime values that serialize without an offset. The drawer
    parsed them with new Date(...).toLocaleString(), so browsers treated
    them as local time and shifted the displayed timestamps.
    
    Use formatUtcDateTime, which already handles offset-less UTC strings
    the same way as the alert lastTriggered fix.
    
    Fixes #4221
---
 web/src/components/MessageQueryHistoryDrawer.tsx   |  9 +++----
 .../__tests__/MessageQueryHistoryDrawer.test.tsx   | 31 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/web/src/components/MessageQueryHistoryDrawer.tsx 
b/web/src/components/MessageQueryHistoryDrawer.tsx
index 9c4b0e08e..8d83f0052 100644
--- a/web/src/components/MessageQueryHistoryDrawer.tsx
+++ b/web/src/components/MessageQueryHistoryDrawer.tsx
@@ -16,6 +16,7 @@ import {
   type TraceQueryHistory,
 } from '../api/messageHistory';
 import { useLang } from '../i18n/LangContext';
+import { formatUtcDateTime } from '../utils/format';
 
 interface Props {
   open: boolean;
@@ -26,11 +27,9 @@ interface Props {
 }
 
 const PAGE_SIZE = 20;
-const formatTime = (value?: string) => {
-  if (!value) return '-';
-  const timestamp = new Date(value);
-  return Number.isNaN(timestamp.getTime()) ? '-' : timestamp.toLocaleString();
-};
+// Backend stores Clock.systemUTC() LocalDateTime values without an offset.
+// formatUtcDateTime appends Z so the viewer's timezone is applied correctly.
+const formatTime = (value?: string) => formatUtcDateTime(value);
 
 const MessageQueryHistoryDrawer = ({
   open,
diff --git a/web/src/components/__tests__/MessageQueryHistoryDrawer.test.tsx 
b/web/src/components/__tests__/MessageQueryHistoryDrawer.test.tsx
index 3de2391b1..22bd40759 100644
--- a/web/src/components/__tests__/MessageQueryHistoryDrawer.test.tsx
+++ b/web/src/components/__tests__/MessageQueryHistoryDrawer.test.tsx
@@ -11,6 +11,7 @@ import { App } from 'antd';
 import MessageQueryHistoryDrawer from '../MessageQueryHistoryDrawer';
 import { LangProvider } from '../../i18n/LangContext';
 import { LANGUAGE_STORAGE_KEY } from '../../i18n/languagePreference';
+import { formatUtcDateTime } from '../../utils/format';
 import {
   getQueryHistorySummary,
   listMessageQueryHistory,
@@ -120,6 +121,36 @@ describe('MessageQueryHistoryDrawer', () => {
     expect(screen.getByRole('button', { name: /重\s*试/ })).toBeEnabled();
   });
 
+  it('treats offset-less queriedAt values as UTC', async () => {
+    vi.mocked(listMessageQueryHistory).mockResolvedValue({
+      items: [
+        {
+          id: 1,
+          queryType: 'KEY',
+          topic: 'orders',
+          messageKey: 'order-1',
+          resultCount: 2,
+          queriedBy: 'alice',
+          queriedAt: '2026-08-05T12:00:00',
+        },
+      ],
+      total: 1,
+      page: 1,
+      size: 20,
+    });
+
+    render(
+      <App>
+        <LangProvider>
+          <MessageQueryHistoryDrawer open clusterId="instance-a" 
onClose={vi.fn()} />
+        </LangProvider>
+      </App>,
+    );
+
+    expect(await screen.findByText('order-1')).toBeInTheDocument();
+    
expect(screen.getByText(formatUtcDateTime('2026-08-05T12:00:00'))).toBeInTheDocument();
+  });
+
   it('renders query history drawer copy in English mode', async () => {
     localStorage.setItem(LANGUAGE_STORAGE_KEY, 'en');
     render(

Reply via email to