Skip to content

Commit 932a214

Browse files
committed
fix(web): retain canonical titles in settings search
1 parent f60df1f commit 932a214

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as Schema from "effect/Schema";
1212

1313
import {
1414
filterAvailableSettingsSearchItems,
15+
formatSettingsSearchTitle,
1516
getSettingsSearchTargetScope,
1617
getThreadAutoSettlementSearchAvailability,
1718
isSettingsSearchScopeAvailable,
@@ -78,6 +79,21 @@ describe("searchSettings", () => {
7879
try {
7980
for (const enabled of [false, true]) {
8081
setMergeRequestTerms(enabled);
82+
const availableItems = SETTINGS_SEARCH_ITEMS.map((item) => ({
83+
...item,
84+
title: formatSettingsSearchTitle(item),
85+
}));
86+
for (const query of [
87+
"keep threads with a pr",
88+
...(enabled ? ["keep threads with an mr"] : []),
89+
]) {
90+
expect(searchSettings(query, availableItems)).toContainEqual(
91+
expect.objectContaining({
92+
id: "keep-threads-with-pull-requests",
93+
title: enabled ? "Keep threads with an MR" : "Keep threads with a PR",
94+
}),
95+
);
96+
}
8197
for (const query of ["pull requests", ...(enabled ? ["merge requests"] : [])]) {
8298
expect(
8399
searchSettings(query).map((item) => item.id),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,9 @@ export const SETTINGS_SEARCH_ITEMS = [
13321332

13331333
export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
13341334

1335-
const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1335+
const SEARCH_ITEMS_BY_ID: ReadonlyMap<string, SettingsSearchItem> = new Map(
1336+
SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const),
1337+
);
13361338

13371339
const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
13381340
"/settings/diagnostics": "environment",
@@ -1531,6 +1533,7 @@ export function searchSettings(
15311533
const fields = [
15321534
title,
15331535
normalizeSearchText(originalItem.title),
1536+
normalizeSearchText(SEARCH_ITEMS_BY_ID.get(item.id)?.title ?? originalItem.title),
15341537
normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
15351538
normalizeSearchText(formatChangeRequestText(SETTINGS_SECTION_LABELS[item.to], terms)),
15361539
...(item.searchTerms ?? []).flatMap((term) => [

0 commit comments

Comments
 (0)