Skip to content

Commit d8e48a3

Browse files
committed
fix(web): find the fallback model in Settings search
1 parent 15fe283 commit d8e48a3

5 files changed

Lines changed: 74 additions & 3 deletions

File tree

‎apps/web/src/components/settings/ProjectDefaultsSettings.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
229229
serverScoped
230230
settingKeys={["fallbackModelSelection"]}
231231
mixed={mixedFallback}
232-
id="fallback-model"
233-
title="Fallback model"
232+
{...searchableSetting("fallback-model")}
234233
description="Used for new threads when the default model's provider is out of usage."
235234
resetAction={
236235
mixedFallback || settings.fallbackModelSelection !== null ? (

‎apps/web/src/components/settings/ProjectSettingsPanel.browser.test.tsx‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import { buildSidebarProjectSnapshots } from "../../sidebarProjectGrouping";
138138
import { ProjectSettingsPanel } from "./ProjectSettingsPanel";
139139
import { ProjectsSettings } from "./ProjectsSettings";
140140
import { SettingsScopeProvider } from "./SettingsScopeContext";
141+
import { SettingsScopeNotice } from "./SettingsScopeNotice";
141142
import { validateSettingsScopeSearch, type SettingsScopeSearch } from "./settingsScope";
142143
import { retainSettingsScope, validateSettingsRouteSearch } from "./settingsScopeNavigation";
143144

@@ -533,6 +534,48 @@ describe("project identity reset", () => {
533534
});
534535
});
535536

537+
it("opens the fallback search target across all environments from a checkout", async () => {
538+
setup();
539+
const root = createRootRoute();
540+
const settings = createRoute({
541+
getParentRoute: () => root,
542+
path: "settings",
543+
validateSearch: validateSettingsRouteSearch,
544+
search: { middlewares: [retainSettingsScope] },
545+
});
546+
const threads = createRoute({
547+
getParentRoute: () => settings,
548+
path: "threads",
549+
component: () => (
550+
<SettingsScopeProvider search={settings.useSearch()} onChange={() => {}}>
551+
<SettingsScopeNotice target="all" targetId="fallback-model">
552+
Choose all environments to edit the fallback model.
553+
</SettingsScopeNotice>
554+
</SettingsScopeProvider>
555+
),
556+
});
557+
const query = new URLSearchParams({
558+
project: projectKey(),
559+
machine: primaryId,
560+
checkout: "primary:/work/primary",
561+
});
562+
const router = createRouter({
563+
routeTree: root.addChildren([settings.addChildren([threads])]),
564+
history: createMemoryHistory({ initialEntries: [`/settings/threads?${query}#fallback-model`] }),
565+
});
566+
await router.load();
567+
// This route needs the real scope-retention middleware used by settings search.
568+
await using _screen = await render(
569+
<RegistryContext.Provider value={appAtomRegistry}>
570+
<RouterProvider router={router} />
571+
</RegistryContext.Provider>,
572+
{ router: false },
573+
);
574+
await userEvent.click(page.getByRole("button", { name: "Open all environments" }));
575+
await vi.waitFor(() => expect(router.state.location.search).toEqual({}));
576+
expect(router.state.location.hash).toBe("fallback-model");
577+
});
578+
536579
describe("project settings scope", () => {
537580
const environmentMenu = () => page.getByRole("button", { name: /^Environment scope:/ });
538581
const primaryOption = () => page.getByRole("menuitemradio", { name: /^primary/ });

‎apps/web/src/components/settings/SettingsScopeNotice.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,16 @@ export function SettingsScopeNotice({
129129
)}
130130
onClick={() => {
131131
if (targetId)
132-
void navigate({ to: pathname, search: () => choice.search, hash: targetId });
132+
void navigate({
133+
to: pathname,
134+
search: () => ({
135+
project: undefined,
136+
machine: undefined,
137+
checkout: undefined,
138+
...choice.search,
139+
}),
140+
hash: targetId,
141+
});
133142
else selectScope(choice.search);
134143
}}
135144
>

‎apps/web/src/components/settings/settingsSearch.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ describe("searchSettings", () => {
6464
expect(searchSettings("sharing", ITEMS).map((item) => item.id)).toEqual(["network-access"]);
6565
expect(searchSettings("claude", ITEMS).map((item) => item.id)).toEqual(["providers"]);
6666
expect(searchSettings("long lines", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
67+
for (const query of ["fallback", "fallback agent", "fallback model"]) {
68+
expect(searchSettings(query)[0]).toMatchObject({
69+
id: "fallback-model",
70+
to: "/settings/threads",
71+
scope: "environment-defaults",
72+
});
73+
}
6774
});
6875

6976
it("hides the Secrets page from nav and search while the secrets feature is disabled", () => {
@@ -205,6 +212,11 @@ describe("settings search targets", () => {
205212
expect(isSettingsSearchScopeAvailable(updates.scope, "environment")).toBe(true);
206213
expect(isSettingsSearchScopeAvailable(updates.scope, "all")).toBe(true);
207214
expect(isSettingsSearchScopeAvailable(updates.scope, "project")).toBe(false);
215+
const fallback = getSettingsSearchTargetScope("fallback-model")!;
216+
expect(fallback.scope).toBe("environment-defaults");
217+
expect(isSettingsSearchScopeAvailable(fallback.scope, "environment")).toBe(true);
218+
expect(isSettingsSearchScopeAvailable(fallback.scope, "all")).toBe(true);
219+
expect(isSettingsSearchScopeAvailable(fallback.scope, "project")).toBe(false);
208220
const streaming = getSettingsSearchTargetScope("response-streaming")!;
209221
expect(streaming.scope).toBe("project-defaults");
210222
expect(isSettingsSearchScopeAvailable(streaming.scope, "project")).toBe(true);

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ export const SETTINGS_SEARCH_ITEMS = [
276276
scope: "project-defaults",
277277
searchTerms: ["new thread project provider reasoning effort"],
278278
},
279+
{
280+
id: "fallback-model",
281+
title: "Fallback model",
282+
to: "/settings/threads",
283+
scope: "environment-defaults",
284+
searchTerms: ["fallback agent provider out of usage new threads"],
285+
environmentOnly: true,
286+
},
279287
{
280288
id: "default-permissions",
281289
title: "Permissions",

0 commit comments

Comments
 (0)