fix(ui): drop duplicate v2/team/list fetch racing OldTeams' paginated fetch

The /?page=teams route had two parallel mount-effects writing to the same
`teams` state: page.tsx fired v2TeamListCall(page=1, page_size=100) and
OldTeams.tsx fired v2TeamListCall(page=1, page_size=10) via fetchTeamsV2().
Whichever response landed last won, so the table sometimes rendered all
teams and sometimes only the first 10 — manifesting as "loads 10, refresh
loads 10 more" depending on which fetch resolved second.

OldTeams already owns its own paginated team-fetching state (currentPage,
pageSize, totalTeams) and is the only consumer of `teams` on this route.
The page-level fetch was redundant; removing it eliminates the race and
lets pagination/sort/filter behave consistently.

The race was introduced in 883611aa91 (2026-03-19, "Modernize teams
table with AntD, server-side pagination, and v2 API"), which switched
the long-existing page-level fetch from v1 to v2(size=100). Before that,
both writers happened to return the same dataset so the duplicate was
invisible.
This commit is contained in:
Ryan Crabbe 2026-05-05 15:18:19 -07:00
parent f318ef03bd
commit 9a8819b8cc
No known key found for this signature in database

View file

@ -8,7 +8,6 @@ import AgentsPanel from "@/components/agents";
import BudgetPanel from "@/components/budgets/budget_panel";
import CacheDashboard from "@/components/cache_dashboard";
import ClaudeCodePluginsPanel from "@/components/claude_code_plugins";
import { teamListCall as v2TeamListCall } from "@/app/(dashboard)/hooks/teams/useTeams";
import LoadingScreen from "@/components/common_components/LoadingScreen";
import { CostTrackingSettings } from "@/components/CostTrackingSettings";
import GeneralSettings from "@/components/general_settings";
@ -353,11 +352,6 @@ function CreateKeyPageContent() {
if (accessToken && userID && userRole) {
fetchUserModels(userID, userRole, accessToken, setUserModels);
}
if (accessToken && userID && userRole) {
v2TeamListCall(accessToken, 1, 100, {
userID: userRole !== "Admin" && userRole !== "Admin Viewer" ? userID : null,
}).then((response) => setTeams(response.teams ?? [])).catch(console.error);
}
if (accessToken) {
fetchOrganizations(accessToken, setOrganizations);
}