mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-18 04:18:15 +00:00
fix(ui): Fetch button ignores active filters on Request Logs page (#25788)
When backend filters (e.g. Key Alias) are active on the Request Logs page, the manual Fetch button called logs.refetch() which re-runs the main TanStack Query. That query does not carry backend-only filter params such as key_alias, so the button had two problems: 1. It fired a redundant API request without the active filters. 2. It did not refresh the filtered result set — backendFilteredLogs stayed frozen at the last debounce-triggered fetch. Fix: expose refetchWithFilters() from useLogFilterLogic and route the Fetch button through it when hasBackendFilters is true. This cancels any in-flight debounce and calls performSearch with the current filter state, keeping all active filters intact. Co-authored-by: Bytechoreographer <Bytechoreographer@users.noreply.github.com> Co-authored-by: Claude Sonnet 4 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Bytechoreographer
Claude Sonnet 4
parent
947931858e
commit
4b2fd870ca
@@ -243,6 +243,7 @@ export default function SpendLogsTable({
|
||||
allTeams,
|
||||
handleFilterChange,
|
||||
handleFilterReset: handleFilterResetFromHook,
|
||||
refetchWithFilters,
|
||||
} = useLogFilterLogic({
|
||||
logs: logsData,
|
||||
accessToken,
|
||||
@@ -363,7 +364,14 @@ export default function SpendLogsTable({
|
||||
|
||||
// Add this function to handle manual refresh
|
||||
const handleRefresh = () => {
|
||||
logs.refetch();
|
||||
if (hasBackendFilters) {
|
||||
// When backend filters (e.g. Key Alias) are active the main TanStack Query
|
||||
// is disabled and its params do not include filter values like key_alias.
|
||||
// Route through the filter-aware refetch so all active filters are preserved.
|
||||
refetchWithFilters();
|
||||
} else {
|
||||
logs.refetch();
|
||||
}
|
||||
};
|
||||
|
||||
const handleRowClick = (log: LogEntry) => {
|
||||
|
||||
@@ -299,6 +299,20 @@ export function useLogFilterLogic({
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
// Expose a filter-aware refetch so callers (e.g. the manual Fetch button) can
|
||||
// refresh results while keeping all active backend filters intact. The plain
|
||||
// `logs.refetch()` in the parent only re-runs the main TanStack Query, which
|
||||
// does not carry key_alias or other backend-only filter params.
|
||||
const refetchWithFilters = useCallback(
|
||||
(page = currentPage) => {
|
||||
if (hasBackendFilters && accessToken) {
|
||||
debouncedSearch.cancel();
|
||||
performSearch(filters, page);
|
||||
}
|
||||
},
|
||||
[hasBackendFilters, accessToken, filters, currentPage, performSearch, debouncedSearch],
|
||||
);
|
||||
|
||||
return {
|
||||
filters,
|
||||
filteredLogs,
|
||||
@@ -306,5 +320,6 @@ export function useLogFilterLogic({
|
||||
allTeams,
|
||||
handleFilterChange,
|
||||
handleFilterReset,
|
||||
refetchWithFilters,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user