This commit is contained in:
lzhan011 2026-10-07 12:31:14 -05:00 • committed by GitHub
commit d3f4bc4f23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View file

@ -250,6 +250,39 @@ describe("AllModelsTab", () => {
expect(lastModelsInfoCall().page).toBe(1);
});
it("drops the team filter and the page when switching to all proxy models", async () => {
// "All Proxy Models" promises every model the user can reach, so the team
// must stop narrowing the query -- and the page has to go back to 1 like it
// does for every other control that changes the result set.
const user = userEvent.setup();
setModelsInfo([makeRow()], 200);
const onUrlUpdate = vi.fn<OnUrlUpdateFunction>();
renderWithProviders(<AllModelsTab {...defaultProps} />, {
searchParams: { page: "3", filter_team: "team-1" },
onUrlUpdate,
});
await waitFor(() => {
expect(lastModelsInfoCall().teamId).toBe("team-1");
});
expect(lastModelsInfoCall().page).toBe(3);
await user.click(screen.getByTestId("models-view-select"));
await user.click(await screen.findByRole("option", { name: "All Proxy Models" }));
await waitFor(() => {
expect(lastModelsInfoCall().teamId).toBeUndefined();
});
expect(lastUrlParams(onUrlUpdate)?.get("page")).toBeNull();
await user.click(screen.getByTestId("models-view-select"));
await user.click(await screen.findByRole("option", { name: "Current Team Models" }));
await waitFor(() => {
expect(lastModelsInfoCall().teamId).toBe("team-1");
});
});
it("debounces the model name search into the server query", async () => {
renderWithProviders(<AllModelsTab {...defaultProps} />);

View file

@ -101,7 +101,11 @@ const AllModelsTab = ({
const [deleteLoading, setDeleteLoading] = useState(false);
const [pausingModelId, setPausingModelId] = useState<string | null>(null);
const teamIdForQuery = selectedTeamValue === PERSONAL_TEAM_VALUE ? undefined : selectedTeamValue;
// Scoped by the view mode, not just by the team picker: in "all available
// models" the team must not narrow the query, or the tab shows the current
// team's models under a heading that promises every model the user can reach.
const teamIdForQuery =
modelViewMode === "current_team" && selectedTeamValue !== PERSONAL_TEAM_VALUE ? selectedTeamValue : undefined;
const isConcreteModelGroup =
Boolean(selectedModelGroup) &&
selectedModelGroup !== ALL_MODEL_GROUPS_VALUE &&
@ -210,7 +214,10 @@ const AllModelsTab = ({
};
const handleViewModeChange = (value: ModelViewMode) => {
void setTableState({ view_mode: value });
// `page: null` like every other handler that changes the result set --
// without it, switching view while past page 1 keeps the old page number
// against a different, usually shorter, list.
void setTableState({ view_mode: value, page: null });
};
const resetFilters = () => {