diff --git a/src/app/[orgId]/settings/logs/access/page.tsx b/src/app/[orgId]/settings/logs/access/page.tsx index 72661a15e..3fe572d4e 100644 --- a/src/app/[orgId]/settings/logs/access/page.tsx +++ b/src/app/[orgId]/settings/logs/access/page.tsx @@ -149,6 +149,23 @@ export default function GeneralPage() { setCurrentPage(newPage); }; + const handleRefresh = () => { + // When the end date has no explicit time, it represents an + // open-ended "up to now" upper bound. Since dateRange is only + // recomputed on user interaction, that upper bound otherwise stays + // frozen at whenever the page first loaded, so refreshing would + // never surface logs created since then. Bump it to the current + // time so the query key changes and refetches the latest window. + if (dateRange.endDate?.date && !dateRange.endDate.time) { + setDateRange((prev) => ({ + ...prev, + endDate: { date: new Date() } + })); + } else { + refetch(); + } + }; + const handlePageSizeChange = (newPageSize: number) => { setPageSize(newPageSize); setCurrentPage(0); @@ -492,7 +509,7 @@ export default function GeneralPage() { columns={columns} data={rows} title={t("accessLogs")} - onRefresh={() => refetch()} + onRefresh={handleRefresh} isRefreshing={isFetching} onExport={() => startTransition(exportData)} isExporting={isExporting} diff --git a/src/app/[orgId]/settings/logs/action/page.tsx b/src/app/[orgId]/settings/logs/action/page.tsx index 3418030f5..7bbbca9ef 100644 --- a/src/app/[orgId]/settings/logs/action/page.tsx +++ b/src/app/[orgId]/settings/logs/action/page.tsx @@ -135,6 +135,23 @@ export default function GeneralPage() { setCurrentPage(newPage); }; + const handleRefresh = () => { + // When the end date has no explicit time, it represents an + // open-ended "up to now" upper bound. Since dateRange is only + // recomputed on user interaction, that upper bound otherwise stays + // frozen at whenever the page first loaded, so refreshing would + // never surface logs created since then. Bump it to the current + // time so the query key changes and refetches the latest window. + if (dateRange.endDate?.date && !dateRange.endDate.time) { + setDateRange((prev) => ({ + ...prev, + endDate: { date: new Date() } + })); + } else { + refetch(); + } + }; + const handlePageSizeChange = (newPageSize: number) => { setPageSize(newPageSize); setCurrentPage(0); @@ -340,7 +357,7 @@ export default function GeneralPage() { title={t("actionLogs")} searchPlaceholder={t("searchLogs")} searchColumn="action" - onRefresh={() => refetch()} + onRefresh={handleRefresh} isRefreshing={isFetching} onExport={() => startTransition(exportData)} isExporting={isExporting} diff --git a/src/app/[orgId]/settings/logs/ai/page.tsx b/src/app/[orgId]/settings/logs/ai/page.tsx index 512278a6c..81c2dcf4b 100644 --- a/src/app/[orgId]/settings/logs/ai/page.tsx +++ b/src/app/[orgId]/settings/logs/ai/page.tsx @@ -158,6 +158,23 @@ export default function AiSessionLogsPage() { setCurrentPage(newPage); }; + const handleRefresh = () => { + // When the end date has no explicit time, it represents an + // open-ended "up to now" upper bound. Since dateRange is only + // recomputed on user interaction, that upper bound otherwise stays + // frozen at whenever the page first loaded, so refreshing would + // never surface logs created since then. Bump it to the current + // time so the query key changes and refetches the latest window. + if (dateRange.endDate?.date && !dateRange.endDate.time) { + setDateRange((prev) => ({ + ...prev, + endDate: { date: new Date() } + })); + } else { + refetch(); + } + }; + const handlePageSizeChange = (newPageSize: number) => { setPageSize(newPageSize); setCurrentPage(0); @@ -617,7 +634,7 @@ export default function AiSessionLogsPage() { title={t("aiSessionLogs")} searchPlaceholder={t("searchLogs")} searchColumn="providerName" - onRefresh={() => refetch()} + onRefresh={handleRefresh} isRefreshing={isFetching} onExport={() => startTransition(exportData)} isExporting={isExporting} diff --git a/src/app/[orgId]/settings/logs/connection/page.tsx b/src/app/[orgId]/settings/logs/connection/page.tsx index fdf588e7a..c77839f5f 100644 --- a/src/app/[orgId]/settings/logs/connection/page.tsx +++ b/src/app/[orgId]/settings/logs/connection/page.tsx @@ -170,6 +170,23 @@ export default function ConnectionLogsPage() { setCurrentPage(newPage); }; + const handleRefresh = () => { + // When the end date has no explicit time, it represents an + // open-ended "up to now" upper bound. Since dateRange is only + // recomputed on user interaction, that upper bound otherwise stays + // frozen at whenever the page first loaded, so refreshing would + // never surface logs created since then. Bump it to the current + // time so the query key changes and refetches the latest window. + if (dateRange.endDate?.date && !dateRange.endDate.time) { + setDateRange((prev) => ({ + ...prev, + endDate: { date: new Date() } + })); + } else { + refetch(); + } + }; + const handlePageSizeChange = (newPageSize: number) => { setPageSize(newPageSize); setCurrentPage(0); @@ -561,7 +578,7 @@ export default function ConnectionLogsPage() { title={t("connectionLogs")} searchPlaceholder={t("searchLogs")} searchColumn="protocol" - onRefresh={() => refetch()} + onRefresh={handleRefresh} isRefreshing={isFetching} onExport={() => startTransition(exportData)} isExporting={isExporting} diff --git a/src/app/[orgId]/settings/logs/request/page.tsx b/src/app/[orgId]/settings/logs/request/page.tsx index 32e4f4b86..5266e42ce 100644 --- a/src/app/[orgId]/settings/logs/request/page.tsx +++ b/src/app/[orgId]/settings/logs/request/page.tsx @@ -151,6 +151,23 @@ export default function GeneralPage() { setCurrentPage(newPage); }; + const handleRefresh = () => { + // When the end date has no explicit time, it represents an + // open-ended "up to now" upper bound. Since dateRange is only + // recomputed on user interaction, that upper bound otherwise stays + // frozen at whenever the page first loaded, so refreshing would + // never surface logs created since then. Bump it to the current + // time so the query key changes and refetches the latest window. + if (dateRange.endDate?.date && !dateRange.endDate.time) { + setDateRange((prev) => ({ + ...prev, + endDate: { date: new Date() } + })); + } else { + refetch(); + } + }; + const handlePageSizeChange = (newPageSize: number) => { setPageSize(newPageSize); setCurrentPage(0); @@ -663,7 +680,7 @@ export default function GeneralPage() { title={t("requestLogs")} searchPlaceholder={t("searchLogs")} searchColumn="host" - onRefresh={() => refetch()} + onRefresh={handleRefresh} isRefreshing={isFetching} onExport={() => startTransition(exportData)} isExporting={isExporting} diff --git a/src/lib/queries.ts b/src/lib/queries.ts index c58c6c567..c8c682200 100644 --- a/src/lib/queries.ts +++ b/src/lib/queries.ts @@ -1114,12 +1114,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1145,12 +1139,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1176,12 +1164,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1207,12 +1189,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1238,12 +1214,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1269,12 +1239,6 @@ export const logQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }) }; @@ -1327,12 +1291,6 @@ export const aiUsageAnalyticsQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1358,12 +1316,6 @@ export const aiUsageAnalyticsQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1389,12 +1341,6 @@ export const aiUsageAnalyticsQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1420,12 +1366,6 @@ export const aiUsageAnalyticsQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }), @@ -1451,12 +1391,6 @@ export const aiUsageAnalyticsQueries = { signal }); return res.data.data; - }, - refetchInterval: (query) => { - if (query.state.data) { - return durationToMs(30, "seconds"); - } - return false; } }) };