Handle search error state and cancel wasted API call on filter reset

- Set backendFilteredLogs to empty response on performSearch error so the
  UI shows "0 results" instead of appearing stuck in a loading state
- Cancel debounced search on filter reset instead of firing a request
  whose result would be ignored (hasBackendFilters is false after reset)
- Clear backendFilteredLogs immediately on filter change to prevent
  stale results from previous filter showing during debounce window
- Normalize response.data with nullish coalescing to handle missing data
- Use `not team_object.models` for None-safe emptiness check
This commit is contained in:
Ryan Crabbe 2026-03-28 13:59:17 -07:00
parent 12a55a8a6f
commit fbddab6178
No known key found for this signature in database
2 changed files with 16 additions and 5 deletions

View file

@ -9215,7 +9215,7 @@ def _add_team_models_to_all_models(
for team_object in team_db_objects_typed:
if (
len(team_object.models) == 0 # empty list = all model access
not team_object.models # None or empty list = all model access
or SpecialModelNames.all_proxy_models.value in team_object.models
):
model_list = llm_router.get_model_list()

View file

@ -107,11 +107,21 @@ export function useLogFilterLogic({
},
});
if (currentTimestamp === lastSearchTimestamp.current && response.data) {
setBackendFilteredLogs(response);
if (currentTimestamp === lastSearchTimestamp.current) {
setBackendFilteredLogs({
...response,
data: response.data ?? [],
});
}
} catch (error) {
console.error("Error searching users:", error);
setBackendFilteredLogs({
data: [],
total: 0,
page: 1,
page_size: pageSize,
total_pages: 0,
});
}
},
[accessToken, startTime, endTime, isCustomDate, pageSize, sortBy, sortOrder],
@ -267,6 +277,7 @@ export function useLogFilterLogic({
// Only call debouncedSearch if filters have actually changed
if (JSON.stringify(updatedFilters) !== JSON.stringify(prev)) {
setCurrentPage(1);
setBackendFilteredLogs(null);
debouncedSearch(updatedFilters, 1);
}
@ -281,8 +292,8 @@ export function useLogFilterLogic({
// Clear backend filtered logs to ensure fresh render
setBackendFilteredLogs(null);
// Reset selections
debouncedSearch(defaultFilters, 1);
// Cancel any in-flight debounced search
debouncedSearch.cancel();
};
return {