From f5caa34ebe7a99c59bd8805cc565fd39b7a2747c Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 20 Feb 2026 16:03:48 -0800 Subject: [PATCH] [Fix] UI - Logs: disable main query while backend filters are active When backend filters (Key Alias, Key Hash, etc.) were active, the main logs query still refetched whenever startTime/endTime/sort/page changed, firing a redundant unfiltered server request whose result was discarded. Expose hasBackendFilters from useLogFilterLogic and use it to gate the main query's enabled condition. Co-Authored-By: Claude Sonnet 4.6 --- .../src/components/view_logs/index.tsx | 16 ++++++++++++++-- .../components/view_logs/log_filter_logic.tsx | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsx index 83e889d2d6..0cdca512e9 100644 --- a/ui/litellm-dashboard/src/components/view_logs/index.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx @@ -91,6 +91,11 @@ export default function SpendLogsTable({ const [sortBy, setSortBy] = useState("startTime"); const [sortOrder, setSortOrder] = useState<"asc" | "desc">("desc"); + // Tracks whether any filter that uses performSearch (backend) is active. + // Used to disable the main query so it doesn't fire redundant unfiltered requests + // when time range / sort / page changes while a backend filter is in effect. + const [isMainQueryEnabled, setIsMainQueryEnabled] = useState(true); + const queryClient = useQueryClient(); const [isLiveTail, setIsLiveTail] = useState(() => { @@ -212,7 +217,7 @@ export default function SpendLogsTable({ return response; }, - enabled: !!accessToken && !!token && !!userRole && !!userID && activeTab === "request logs", + enabled: !!accessToken && !!token && !!userRole && !!userID && activeTab === "request logs" && isMainQueryEnabled, refetchInterval: isLiveTail && currentPage === 1 ? 15000 : false, placeholderData: keepPreviousData, refetchIntervalInBackground: true, @@ -235,6 +240,7 @@ export default function SpendLogsTable({ const { filters, filteredLogs, + hasBackendFilters, allTeams: hookAllTeams, allKeyAliases, handleFilterChange, @@ -264,6 +270,12 @@ export default function SpendLogsTable({ setCurrentPage(1); }, [handleFilterResetFromHook]); + // Disable the main query whenever backend filters are active so it doesn't fire + // redundant unfiltered requests when time range / sort / page changes. + useEffect(() => { + setIsMainQueryEnabled(!hasBackendFilters); + }, [hasBackendFilters]); + // Sync filter state into the individual selectedX state variables used by the main query useEffect(() => { if (!accessToken) return; @@ -673,7 +685,7 @@ export default function SpendLogsTable({ - {isLiveTail && currentPage === 1 && ( + {isLiveTail && currentPage === 1 && isMainQueryEnabled && (
Auto-refreshing every 15 seconds diff --git a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx index 0701d38af4..097519d2f3 100644 --- a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx @@ -309,6 +309,7 @@ export function useLogFilterLogic({ return { filters, filteredLogs, + hasBackendFilters, allKeyAliases, allTeams, handleFilterChange,