From 1178cca8a16ed05b215508bcc8a0f1606cb23d26 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 26 Apr 2026 00:47:04 +0000 Subject: [PATCH] Cover model ordering and visibility settings Co-authored-by: Julius Marminge --- .../chat/ProviderModelPicker.browser.tsx | 10 +++++++++- .../components/settings/SettingsPanels.browser.tsx | 14 ++++++++++++-- apps/web/src/localApi.test.ts | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/chat/ProviderModelPicker.browser.tsx b/apps/web/src/components/chat/ProviderModelPicker.browser.tsx index 5534d02d08..e54d73faca 100644 --- a/apps/web/src/components/chat/ProviderModelPicker.browser.tsx +++ b/apps/web/src/components/chat/ProviderModelPicker.browser.tsx @@ -8,6 +8,7 @@ import { render } from "vitest-browser-react"; import { ProviderModelPicker } from "./ProviderModelPicker"; import { getCustomModelOptionsByProvider } from "../../modelSelection"; import { DEFAULT_CLIENT_SETTINGS, DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; +import { __resetClientSettingsPersistenceForTests } from "../../hooks/useSettings"; import { __resetLocalApiForTests } from "../../localApi"; // Mock the environments/runtime module to provide a mock primary environment connection @@ -294,12 +295,16 @@ function getSidebarProviderOrder() { describe("ProviderModelPicker", () => { beforeEach(async () => { // Reset test environment before each test + localStorage.clear(); await __resetLocalApiForTests(); + __resetClientSettingsPersistenceForTests(); }); afterEach(async () => { document.body.innerHTML = ""; + localStorage.clear(); await __resetLocalApiForTests(); + __resetClientSettingsPersistenceForTests(); }); it("shows provider sidebar in unlocked mode", async () => { @@ -928,6 +933,7 @@ describe("ProviderModelPicker", () => { try { await page.getByRole("button").click(); + await page.getByRole("button", { name: "Favorites", exact: true }).click(); await vi.waitFor(() => { expect(getVisibleModelNames().slice(0, 2)).toEqual(["GPT-5 Codex", "Claude Sonnet 4.6"]); @@ -966,7 +972,9 @@ describe("ProviderModelPicker", () => { await page.getByRole("button", { name: "Codex", exact: true }).click(); await vi.waitFor(() => { - expect(getVisibleModelNames()).toEqual(["GPT-5 Codex"]); + const visibleModelNames = getVisibleModelNames(); + expect(visibleModelNames).toContain("GPT-5 Codex"); + expect(visibleModelNames).not.toContain("GPT-5.3 Codex"); }); } finally { await mounted.cleanup(); diff --git a/apps/web/src/components/settings/SettingsPanels.browser.tsx b/apps/web/src/components/settings/SettingsPanels.browser.tsx index f73dfc8deb..8625a06a70 100644 --- a/apps/web/src/components/settings/SettingsPanels.browser.tsx +++ b/apps/web/src/components/settings/SettingsPanels.browser.tsx @@ -3,6 +3,7 @@ import "../../index.css"; import { type AuthAccessStreamEvent, type AuthAccessSnapshot, + type ClientSettings, AuthSessionId, DEFAULT_SERVER_SETTINGS, EnvironmentId, @@ -23,6 +24,7 @@ import { AppAtomRegistryProvider } from "../../rpc/atomRegistry"; import { resetServerStateForTests, setServerConfigSnapshot } from "../../rpc/serverState"; import { ConnectionsSettings } from "./ConnectionsSettings"; import { GeneralSettingsPanel } from "./SettingsPanels"; +import { __resetClientSettingsPersistenceForTests } from "../../hooks/useSettings"; const authAccessHarness = vi.hoisted(() => { type Snapshot = AuthAccessSnapshot; @@ -380,6 +382,7 @@ describe("GeneralSettingsPanel observability", () => { beforeEach(async () => { resetServerStateForTests(); await __resetLocalApiForTests(); + __resetClientSettingsPersistenceForTests(); localStorage.clear(); authAccessHarness.reset(); }); @@ -396,6 +399,7 @@ describe("GeneralSettingsPanel observability", () => { document.body.innerHTML = ""; resetServerStateForTests(); await __resetLocalApiForTests(); + __resetClientSettingsPersistenceForTests(); authAccessHarness.reset(); }); @@ -760,8 +764,8 @@ describe("GeneralSettingsPanel observability", () => { it("toggles model visibility from provider settings", async () => { const updateSettings = vi .fn() - .mockResolvedValue(undefined); - const config = { + .mockImplementation(async () => DEFAULT_SERVER_SETTINGS); + const config: ServerConfig = { ...createBaseServerConfig(), providers: [ { @@ -788,6 +792,12 @@ describe("GeneralSettingsPanel observability", () => { }; setServerConfigSnapshot(config); window.nativeApi = { + persistence: { + getClientSettings: async () => null, + setClientSettings: async (settings: ClientSettings) => { + localStorage.setItem("t3code:client-settings:v1", JSON.stringify(settings)); + }, + }, server: { updateSettings, }, diff --git a/apps/web/src/localApi.test.ts b/apps/web/src/localApi.test.ts index c361cbd787..e401789edb 100644 --- a/apps/web/src/localApi.test.ts +++ b/apps/web/src/localApi.test.ts @@ -534,6 +534,7 @@ describe("wsApi", () => { confirmThreadDelete: false, diffWordWrap: true, favorites: [], + hiddenModels: [], sidebarProjectGroupingMode: "repository_path" as const, sidebarProjectGroupingOverrides: { "environment-local:/tmp/project": "separate" as const, @@ -593,6 +594,7 @@ describe("wsApi", () => { confirmThreadDelete: false, diffWordWrap: true, favorites: [], + hiddenModels: [], sidebarProjectGroupingMode: "repository_path" as const, sidebarProjectGroupingOverrides: { "environment-local:/tmp/project": "separate" as const,