From 9a6d30bfe6e0d45ad3540e5b58b8c47222d992f8 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Thu, 2 Jul 2026 20:23:15 +0800 Subject: [PATCH] Fix: send agent log date filters as local wall-clock strings (#16575) --- web/src/services/agent-service.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/web/src/services/agent-service.ts b/web/src/services/agent-service.ts index fee6709eae..78fbfd82b3 100644 --- a/web/src/services/agent-service.ts +++ b/web/src/services/agent-service.ts @@ -6,6 +6,7 @@ import { IAgentWebhookTraceRequest } from '@/interfaces/request/agent'; import api from '@/utils/api'; import { registerNextServer } from '@/utils/register-server'; import request from '@/utils/request'; +import dayjs from 'dayjs'; const { createAgent, @@ -167,7 +168,30 @@ export const fetchAgentLogsByCanvasId = ( canvasId: string, params: IAgentLogsRequest, ) => { - return request.get(methods.fetchAgentLogs.url(canvasId), { params: params }); + // Serialize Date values as local wall-clock strings ("YYYY-MM-DD HH:mm:ss"). + // Axios' default serializer turns a Date into a UTC ISO string, which the + // backend then shifts by the server timezone — causing the picked local day + // to mismatch the server-local dates shown in the table. Sending a plain + // local datetime makes the backend compare it as-is against stored dates. + // from_date snaps to the start of the day (00:00:00), to_date to the end + // (23:59:59), so the full picked day range is covered. + const normalizeDate = (value: string | Date | undefined, isEnd = false) => { + if (!(value instanceof Date)) return value; + const day = dayjs(value); + return (isEnd ? day.endOf('day') : day.startOf('day')).format( + 'YYYY-MM-DD HH:mm:ss', + ); + }; + + const normalizedParams: IAgentLogsRequest = { + ...params, + from_date: normalizeDate(params.from_date), + to_date: normalizeDate(params.to_date, true), + }; + + return request.get(methods.fetchAgentLogs.url(canvasId), { + params: normalizedParams, + }); }; export const fetchAgentLogsById = (canvasId: string, sessionId: string) => {