Skip to content

Commit 0db864b

Browse files
fix(web):hide-unavailable-WSL-search-result
1 parent 9bb587f commit 0db864b

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
type ComponentType,
88
type KeyboardEvent,
99
} from "react";
10+
import { useEnvironmentQuery } from "~/state/query";
11+
import { desktopWslStateAtom } from "~/state/desktopWslState";
1012
import {
1113
ArchiveIcon,
1214
BlocksIcon,
@@ -21,6 +23,7 @@ import {
2123
} from "lucide-react";
2224
import { useLocation, useNavigate } from "@tanstack/react-router";
2325

26+
import { isElectron } from "~/env";
2427
import { Button } from "../ui/button";
2528
import { Input } from "../ui/input";
2629
import { Kbd } from "../ui/kbd";
@@ -38,6 +41,7 @@ import { SidebarUtilityMenu } from "../sidebar/SidebarChrome";
3841
import { scrollToSettingsTarget } from "./settingsLayout";
3942
import {
4043
searchSettings,
44+
SETTINGS_SEARCH_ITEMS,
4145
SETTINGS_SECTION_LABELS,
4246
type SettingsPath,
4347
type SettingsSearchItem,
@@ -78,7 +82,15 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
7882
const searchInputRef = useRef<HTMLInputElement>(null);
7983
const [query, setQuery] = useState("");
8084
const [activeResultIndex, setActiveResultIndex] = useState(0);
81-
const results = useMemo(() => searchSettings(query), [query]);
85+
const desktopWsl = useEnvironmentQuery(isElectron ? desktopWslStateAtom : null);
86+
const searchableItems = useMemo(() => {
87+
const wslState = desktopWsl.data;
88+
if (wslState?.available || wslState?.enabled || wslState?.wslOnly) {
89+
return SETTINGS_SEARCH_ITEMS;
90+
}
91+
return SETTINGS_SEARCH_ITEMS.filter((item) => item.id !== "wsl-backend");
92+
}, [desktopWsl.data]);
93+
const results = useMemo(() => searchSettings(query, searchableItems), [query, searchableItems]);
8294
const isSearching = query.trim().length > 0;
8395
const hasResults = results.length > 0;
8496

0 commit comments

Comments
 (0)