From d5a1785f0ab44043960a7d396476074bbd5704e6 Mon Sep 17 00:00:00 2001 From: tanjiro <56165694+NANDINI-star@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:41:08 +0900 Subject: [PATCH] add live tail state to session storage (#12335) --- .../src/components/view_logs/index.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsx index d55aa94bdac..10ba2dc3465 100644 --- a/ui/litellm-dashboard/src/components/view_logs/index.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx @@ -102,7 +102,15 @@ export default function SpendLogsTable({ const queryClient = useQueryClient(); - const [isLiveTail, setIsLiveTail] = useState(true); // Default to true + const [isLiveTail, setIsLiveTail] = useState(() => { + const storedValue = sessionStorage.getItem("isLiveTail"); + // default to true if nothing is stored + return storedValue !== null ? JSON.parse(storedValue) : true; + }); + + useEffect(() => { + sessionStorage.setItem("isLiveTail", JSON.stringify(isLiveTail)); + }, [isLiveTail]); const [selectedTimeInterval, setSelectedTimeInterval] = useState<{ value: number; unit: string }>({ value: 24, @@ -244,7 +252,7 @@ export default function SpendLogsTable({ return response; }, enabled: !!accessToken && !!token && !!userRole && !!userID && activeTab === "request logs", - refetchInterval: isLiveTail ? 15000 : false, + refetchInterval: isLiveTail && currentPage === 1 ? 15000 : false, refetchIntervalInBackground: true, }); @@ -735,7 +743,7 @@ export default function SpendLogsTable({ - {isLiveTail && ( + {isLiveTail && currentPage === 1 && (