Unified · Split
| @@ -8,6 +8,7 @@ import { · 7 unmodified lines | ||
| 8 | 8 | enumerateCommandPaletteItems, |
| 9 | 9 | filterPinnedBrowseEntries, |
| 10 | 10 | filterCommandPaletteGroups, |
| 11 | + normalizeSearchText, | |
| 11 | 12 | reduceCommandPaletteUiState, |
| 12 | 13 | type CommandPaletteGroup, |
| 13 | 14 | } from "./CommandPalette.logic"; |
| @@ -272,6 +273,75 @@ describe("buildThreadActionItems", () => { · 258 unmodified lines | ||
| 272 | 273 | expect(groups[0]?.items.map((item) => item.value)).toEqual(["thread:project-context-only"]); |
| 273 | 274 | }); |
| 274 | 275 | |
| 276 | + it("ranks an order-independent setting title match above a split context match", () => { | |
| 277 | + const settingsSearchItems = [ | |
| 278 | + { | |
| 279 | + kind: "action" as const, | |
| 280 | + value: "setting:context-match", | |
| 281 | + searchTerms: ["Pairing settings", "remote backend"], | |
| 282 | + title: "Context match", | |
| 283 | + icon: null, | |
| 284 | + run: async () => undefined, | |
| 285 | + }, | |
| 286 | + { | |
| 287 | + kind: "action" as const, | |
| 288 | + value: "setting:remote-pairing", | |
| 289 | + searchTerms: ["Remote pairing", "connections"], | |
| 290 | + title: "Remote pairing", | |
| 291 | + icon: null, | |
| 292 | + run: async () => undefined, | |
| 293 | + }, | |
| 294 | + ]; | |
| 295 | + | |
| 296 | + const groups = filterCommandPaletteGroups({ | |
| 297 | + activeGroups: [], | |
| 298 | + query: "pairing remote", | |
| 299 | + isInSubmenu: false, | |
| 300 | + projectSearchItems: [], | |
| 301 | + settingsSearchItems, | |
| 302 | + threadSearchItems: [], | |
| 303 | + }); | |
| 304 | + | |
| 305 | + expect(groups).toHaveLength(1); | |
| 306 | + expect(groups[0]?.value).toBe("settings-search"); | |
| 307 | + expect(groups[0]?.items.map((item) => item.value)).toEqual([ | |
| 308 | + "setting:remote-pairing", | |
| 309 | + "setting:context-match", | |
| 310 | + ]); | |
| 311 | + }); | |
| 312 | + | |
| 313 | + it("keeps accent-insensitive setting results", () => { | |
| 314 | + const groups = filterCommandPaletteGroups({ | |
| 315 | + activeGroups: [], | |
| 316 | + query: "thè\u{1ab0}mes", | |
| 317 | + isInSubmenu: false, | |
| 318 | + projectSearchItems: [], | |
| 319 | + settingsSearchItems: [ | |
| 320 | + { | |
| 321 | + kind: "action", | |
| 322 | + value: "setting:theme", | |
| 323 | + searchTerms: ["Themes", "Appearance"], | |
| 324 | + title: "Themes", | |
| 325 | + icon: null, | |
| 326 | + run: async () => undefined, | |
| 327 | + }, | |
| 328 | + ], | |
| 329 | + threadSearchItems: [], | |
| 330 | + }); | |
| 331 | + | |
| 332 | + expect(groups[0]?.items.map((item) => item.value)).toEqual(["setting:theme"]); | |
| 333 | + }); | |
| 334 | + | |
| 335 | + it("normalizes case independently of the host locale", () => { | |
| 336 | + const localeLowerCase = vi.spyOn(String.prototype, "toLocaleLowerCase").mockReturnValue("gıt"); | |
| 337 | + try { | |
| 338 | + expect(normalizeSearchText("GIT")).toBe("git"); | |
| 339 | + expect(localeLowerCase).not.toHaveBeenCalled(); | |
| 340 | + } finally { | |
| 341 | + localeLowerCase.mockRestore(); | |
| 342 | + } | |
| 343 | + }); | |
| 344 | + | |
| 275 | 345 | it("keeps message excerpts searchable without replacing thread metadata", () => { |
| 276 | 346 | const [item] = buildThreadActionItems({ |
| 277 | 347 | threads: [makeThread({ branch: "feat/search" })], |
| @@ -9,9 +9,12 @@ import * as Arr from "effect/Array"; · 8 unmodified lines | ||
| 9 | 9 | import * as Result from "effect/Result"; |
| 10 | 10 | import { type ReactNode } from "react"; |
| 11 | 11 | import { sortThreads } from "../lib/threadSort"; |
| 12 | +import { normalizeSearchText } from "../lib/utils"; | |
| 12 | 13 | import { formatRelativeTimeLabel } from "../timestampFormat"; |
| 13 | 14 | import { type Project, type SidebarThreadSummary, type Thread } from "../types"; |
| 14 | 15 | |
| 16 | +export { normalizeSearchText } from "../lib/utils"; | |
| 17 | + | |
| 15 | 18 | export const RECENT_THREAD_LIMIT = 12; |
| 16 | 19 | export const ITEM_ICON_CLASS = "size-4 text-icon-muted"; |
| 17 | 20 | export const ADDON_ICON_CLASS = "size-4"; |
| @@ -138,10 +141,6 @@ export function enumerateCommandPaletteItems( · 120 unmodified lines | ||
| 138 | 141 | |
| 139 | 142 | export type CommandPaletteMode = "root" | "root-browse" | "submenu" | "submenu-browse"; |
| 140 | 143 | |
| 141 | −export function normalizeSearchText(value: string): string { | |
| 142 | − return value.trim().toLowerCase().replace(/\s+/g, " "); | |
| 143 | −} | |
| 144 | − | |
| 145 | 144 | export function buildProjectActionItems(input: { |
| 146 | 145 | projects: ReadonlyArray<Project>; |
| 147 | 146 | valuePrefix: string; |
| @@ -255,9 +254,16 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThr · 107 unmodified lines | ||
| 255 | 254 | }); |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | −function rankSearchFieldMatch(field: string, normalizedQuery: string): number { | |
| 257 | +function rankSearchFieldMatch( | |
| 258 | + field: string, | |
| 259 | + normalizedQuery: string, | |
| 260 | + queryTokens: ReadonlyArray<string>, | |
| 261 | +): number { | |
| 259 | 262 | const normalizedField = normalizeSearchText(field); |
| 260 | − if (normalizedField.length === 0 || !normalizedField.includes(normalizedQuery)) { | |
| 263 | + if ( | |
| 264 | + normalizedField.length === 0 || | |
| 265 | + !queryTokens.every((token) => normalizedField.includes(token)) | |
| 266 | + ) { | |
| 261 | 267 | return Number.NEGATIVE_INFINITY; |
| 262 | 268 | } |
| 263 | 269 | if (normalizedField === normalizedQuery) { |
| @@ -266,12 +272,16 @@ function rankSearchFieldMatch(field: string, normalizedQuery: string): number { · 2 unmodified lines | ||
| 266 | 272 | if (normalizedField.startsWith(normalizedQuery)) { |
| 267 | 273 | return 2; |
| 268 | 274 | } |
| 269 | − return 1; | |
| 275 | + if (normalizedField.includes(normalizedQuery)) { | |
| 276 | + return 1; | |
| 277 | + } | |
| 278 | + return 0; | |
| 270 | 279 | } |
| 271 | 280 | |
| 272 | 281 | function rankCommandPaletteItemMatch( |
| 273 | 282 | item: CommandPaletteActionItem | CommandPaletteSubmenuItem, |
| 274 | 283 | normalizedQuery: string, |
| 284 | + queryTokens: ReadonlyArray<string>, | |
| 275 | 285 | ): number { |
| 276 | 286 | const terms = item.searchTerms.filter((term) => term.length > 0); |
| 277 | 287 | if (terms.length === 0) { |
| @@ -279,7 +289,7 @@ function rankCommandPaletteItemMatch( · 1 unmodified line | ||
| 279 | 289 | } |
| 280 | 290 | |
| 281 | 291 | for (const [index, field] of terms.entries()) { |
| 282 | − const fieldRank = rankSearchFieldMatch(field, normalizedQuery); | |
| 292 | + const fieldRank = rankSearchFieldMatch(field, normalizedQuery, queryTokens); | |
| 283 | 293 | if (fieldRank !== Number.NEGATIVE_INFINITY) { |
| 284 | 294 | return 1_000 - index * 100 + fieldRank; |
| 285 | 295 | } |
| @@ -293,6 +303,7 @@ export function filterCommandPaletteGroups(input: { · 7 unmodified lines | ||
| 293 | 303 | query: string; |
| 294 | 304 | isInSubmenu: boolean; |
| 295 | 305 | projectSearchItems: ReadonlyArray<CommandPaletteActionItem>; |
| 306 | + settingsSearchItems?: ReadonlyArray<CommandPaletteActionItem>; | |
| 296 | 307 | threadSearchItems: ReadonlyArray<CommandPaletteActionItem>; |
| 297 | 308 | }): CommandPaletteGroup[] { |
| 298 | 309 | const isActionsFilter = input.query.startsWith(">"); |
| @@ -305,6 +316,7 @@ export function filterCommandPaletteGroups(input: { · 6 unmodified lines | ||
| 305 | 316 | } |
| 306 | 317 | return [...input.activeGroups]; |
| 307 | 318 | } |
| 319 | + const queryTokens = normalizedQuery.split(" "); | |
| 308 | 320 | |
| 309 | 321 | let baseGroups = [...input.activeGroups]; |
| 310 | 322 | if (isActionsFilter) { |
| @@ -322,6 +334,13 @@ export function filterCommandPaletteGroups(input: { · 11 unmodified lines | ||
| 322 | 334 | items: input.projectSearchItems, |
| 323 | 335 | }); |
| 324 | 336 | } |
| 337 | + if (input.settingsSearchItems && input.settingsSearchItems.length > 0) { | |
| 338 | + searchableGroups.push({ | |
| 339 | + value: "settings-search", | |
| 340 | + label: "Settings", | |
| 341 | + items: input.settingsSearchItems, | |
| 342 | + }); | |
| 343 | + } | |
| 325 | 344 | if (input.threadSearchItems.length > 0) { |
| 326 | 345 | searchableGroups.push({ |
| 327 | 346 | value: "threads-search", |
| @@ -334,14 +353,14 @@ export function filterCommandPaletteGroups(input: { · 6 unmodified lines | ||
| 334 | 353 | return searchableGroups.flatMap((group) => { |
| 335 | 354 | const items = Arr.filterMap(group.items, (item, index) => { |
| 336 | 355 | const haystack = normalizeSearchText(item.searchTerms.join(" ")); |
| 337 | − if (!haystack.includes(normalizedQuery)) { | |
| 356 | + if (!queryTokens.every((token) => haystack.includes(token))) { | |
| 338 | 357 | return Result.failVoid; |
| 339 | 358 | } |
| 340 | 359 | |
| 341 | 360 | return Result.succeed({ |
| 342 | 361 | item, |
| 343 | 362 | index, |
| 344 | − rank: rankCommandPaletteItemMatch(item, normalizedQuery), | |
| 363 | + rank: rankCommandPaletteItemMatch(item, normalizedQuery, queryTokens), | |
| 345 | 364 | }); |
| 346 | 365 | }) |
| 347 | 366 | .toSorted((left, right) => right.rank - left.rank || left.index - right.index) |
| @@ -32,7 +32,7 @@ import { · 31 unmodified lines | ||
| 32 | 32 | type SourceControlRepositoryInfo, |
| 33 | 33 | PRIMARY_LOCAL_ENVIRONMENT_ID, |
| 34 | 34 | } from "@t3tools/contracts"; |
| 35 | −import { useNavigate, useParams } from "@tanstack/react-router"; | |
| 35 | +import { useLocation, useNavigate, useParams } from "@tanstack/react-router"; | |
| 36 | 36 | import * as Option from "effect/Option"; |
| 37 | 37 | import { |
| 38 | 38 | ArrowLeftIcon, |
| @@ -104,6 +104,7 @@ import { · 65 unmodified lines | ||
| 104 | 104 | } from "../lib/utils"; |
| 105 | 105 | import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore"; |
| 106 | 106 | import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoutes"; |
| 107 | +import { useAvailableSettingsSearchItems } from "./settings/useAvailableSettingsSearchItems"; | |
| 107 | 108 | import { |
| 108 | 109 | applyWslEnvironmentConfiguration, |
| 109 | 110 | parseWslUncPath, |
| @@ -140,6 +141,7 @@ import { ProjectFavicon } from "./ProjectFavicon"; · 30 unmodified lines | ||
| 140 | 141 | import { ProjectFilePicker } from "./files/ProjectFilePicker"; |
| 141 | 142 | import { ProjectContentSearchDialog } from "./search/ProjectContentSearchDialog"; |
| 142 | 143 | import { toggleThemeEditorForTheme } from "./settings/themeEditorStore"; |
| 144 | +import { searchSettings, SETTINGS_SECTION_LABELS } from "./settings/settingsSearch"; | |
| 143 | 145 | import { |
| 144 | 146 | COMMAND_PALETTE_META_ICON_CLASS, |
| 145 | 147 | CommandPaletteMetaDot, |
| @@ -563,6 +565,7 @@ function OpenCommandPaletteDialog(props: { · 417 unmodified lines | ||
| 563 | 565 | readonly clearOpenIntent: () => void; |
| 564 | 566 | }) { |
| 565 | 567 | const navigate = useNavigate(); |
| 568 | + const pathname = useLocation({ select: (location) => location.pathname }); | |
| 566 | 569 | const { clearOpenIntent, openIntent, openOverlayMode, setOpen } = props; |
| 567 | 570 | const [query, setQuery] = useState(""); |
| 568 | 571 | const deferredQuery = useDeferredValue(query); |
| @@ -585,6 +588,7 @@ function OpenCommandPaletteDialog(props: { · 16 unmodified lines | ||
| 585 | 588 | const { environments } = useEnvironments(); |
| 586 | 589 | const desktopLocalBootstraps = useDesktopLocalBootstraps(); |
| 587 | 590 | const primaryEnvironmentId = usePrimaryEnvironmentId(); |
| 591 | + const availableSettingsSearchItems = useAvailableSettingsSearchItems(); | |
| 588 | 592 | const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread } = |
| 589 | 593 | useHandleNewThread(); |
| 590 | 594 | const projects = useProjects(); |
| @@ -1637,7 +1641,19 @@ function OpenCommandPaletteDialog(props: { · 1046 unmodified lines | ||
| 1637 | 1641 | actionItems.push({ |
| 1638 | 1642 | kind: "action", |
| 1639 | 1643 | value: "action:project-settings", |
| 1640 | − searchTerms: ["project", "settings", "scripts", "model", "grouping", "checkout"], | |
| 1644 | + searchTerms: [ | |
| 1645 | + "project", | |
| 1646 | + "settings", | |
| 1647 | + "name", | |
| 1648 | + "icon", | |
| 1649 | + "scripts", | |
| 1650 | + "model", | |
| 1651 | + "workspace", | |
| 1652 | + "grouping", | |
| 1653 | + "checkout", | |
| 1654 | + "remove", | |
| 1655 | + "t3.json", | |
| 1656 | + ], | |
| 1641 | 1657 | title: "Project settings", |
| 1642 | 1658 | description: contextualProjectGroup.displayName, |
| 1643 | 1659 | icon: <FolderIcon className={ITEM_ICON_CLASS} />, |
| @@ -1651,6 +1667,25 @@ function OpenCommandPaletteDialog(props: { · 7 unmodified lines | ||
| 1651 | 1667 | } |
| 1652 | 1668 | |
| 1653 | 1669 | const rootGroups = buildRootGroups({ actionItems, recentThreadItems }); |
| 1670 | + const settingsSearchItems: CommandPaletteActionItem[] = searchSettings( | |
| 1671 | + deferredQuery, | |
| 1672 | + availableSettingsSearchItems, | |
| 1673 | + ).map((item) => ({ | |
| 1674 | + kind: "action", | |
| 1675 | + value: `setting:${item.id}`, | |
| 1676 | + searchTerms: [item.title, SETTINGS_SECTION_LABELS[item.to], ...(item.searchTerms ?? [])], | |
| 1677 | + title: item.title, | |
| 1678 | + description: `Settings · ${SETTINGS_SECTION_LABELS[item.to]}`, | |
| 1679 | + icon: <SettingsIcon className={ITEM_ICON_CLASS} />, | |
| 1680 | + run: async () => { | |
| 1681 | + await navigate({ | |
| 1682 | + to: item.to, | |
| 1683 | + hash: item.targetId ?? item.id, | |
| 1684 | + replace: pathname === item.to, | |
| 1685 | + hashScrollIntoView: false, | |
| 1686 | + }); | |
| 1687 | + }, | |
| 1688 | + })); | |
| 1654 | 1689 | const sourceSelectionViewValue = |
| 1655 | 1690 | addProjectEnvironmentId === null ? null : `sources:${addProjectEnvironmentId}`; |
| 1656 | 1691 | const activeGroups = |
| @@ -1668,6 +1703,7 @@ function OpenCommandPaletteDialog(props: { · 11 unmodified lines | ||
| 1668 | 1703 | query: deferredQuery, |
| 1669 | 1704 | isInSubmenu: currentView !== null, |
| 1670 | 1705 | projectSearchItems: projectSearchItems, |
| 1706 | + settingsSearchItems, | |
| 1671 | 1707 | threadSearchItems: allThreadItems, |
| 1672 | 1708 | }); |
| 1673 | 1709 | |
| @@ -1670,7 +1670,7 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b · 1669 unmodified lines | ||
| 1670 | 1670 | <> |
| 1671 | 1671 | {window.desktopBridge ? ( |
| 1672 | 1672 | <SettingsRow |
| 1673 | − title="T3 Connect" | |
| 1673 | + title={searchableSetting("t3-connect").title} | |
| 1674 | 1674 | description={ |
| 1675 | 1675 | managedTunnelActive |
| 1676 | 1676 | ? "This environment is available to your other devices through T3 Connect." |
| @@ -1688,7 +1688,7 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b · 11 unmodified lines | ||
| 1688 | 1688 | /> |
| 1689 | 1689 | ) : null} |
| 1690 | 1690 | <SettingsRow |
| 1691 | − title="Publish agent activity" | |
| 1691 | + title={searchableSetting("publish-agent-activity").title} | |
| 1692 | 1692 | description="Send activity from this environment to your mobile clients for push notifications and Live Activities. Works without a T3 Connect tunnel." |
| 1693 | 1693 | control={ |
| 1694 | 1694 | <CloudLinkSwitch |
| @@ -2908,7 +2908,7 @@ export function ConnectionsSettings() { · 1213 unmodified lines | ||
| 2908 | 2908 | |
| 2909 | 2909 | const renderTailscaleRow = () => ( |
| 2910 | 2910 | <SettingsRow |
| 2911 | − title="Tailscale HTTPS" | |
| 2911 | + title={searchableSetting("tailscale-https").title} | |
| 2912 | 2912 | description={ |
| 2913 | 2913 | tailscaleHttpsEndpoint |
| 2914 | 2914 | ? tailscaleHttpsEndpoint.status === "available" |
| @@ -2958,7 +2958,7 @@ export function ConnectionsSettings() { · 43 unmodified lines | ||
| 2958 | 2958 | ); |
| 2959 | 2959 | const renderNetworkAccessRow = () => ( |
| 2960 | 2960 | <SettingsRow |
| 2961 | − title="Network access" | |
| 2961 | + title={searchableSetting("network-access").title} | |
| 2962 | 2962 | description={ |
| 2963 | 2963 | isLocalBackendNetworkAccessible ? ( |
| 2964 | 2964 | <NetworkAccessDescription |
| @@ -2990,7 +2990,7 @@ export function ConnectionsSettings() { · 25 unmodified lines | ||
| 2990 | 2990 | ); |
| 2991 | 2991 | const renderDisabledNetworkAccessRow = () => ( |
| 2992 | 2992 | <SettingsRow |
| 2993 | − title="Network access" | |
| 2993 | + title={searchableSetting("network-access").title} | |
| 2994 | 2994 | description={ |
| 2995 | 2995 | currentAuthPolicy === "remote-reachable" |
| 2996 | 2996 | ? "This backend is already configured for remote access. Network exposure changes must be made where the server is launched." |
| @@ -3022,7 +3022,7 @@ export function ConnectionsSettings() { · 25 unmodified lines | ||
| 3022 | 3022 | <SettingsPageContainer> |
| 3023 | 3023 | {canManageLocalBackend ? ( |
| 3024 | 3024 | <> |
| 3025 | − <SettingsSection title="This environment"> | |
| 3025 | + <SettingsSection {...searchableSetting("connections-environment")}> | |
| 3026 | 3026 | {primaryVersionMismatch || primaryServerUpdateState.status !== "idle" ? ( |
| 3027 | 3027 | <SettingsRow |
| 3028 | 3028 | title={ |
| @@ -3377,7 +3377,7 @@ export function ConnectionsSettings() { · 348 unmodified lines | ||
| 3377 | 3377 | </Dialog> |
| 3378 | 3378 | </> |
| 3379 | 3379 | ) : ( |
| 3380 | − <SettingsSection title="This environment"> | |
| 3380 | + <SettingsSection {...searchableSetting("connections-environment")}> | |
| 3381 | 3381 | <SettingsRow |
| 3382 | 3382 | title="Administrative access" |
| 3383 | 3383 | description="Pairing links and client-session management require the access:write scope for this backend." |
| @@ -31,18 +31,32 @@ const settingsState = vi.hoisted(() => ({ · 30 unmodified lines | ||
| 31 | 31 | updateSettings: vi.fn(), |
| 32 | 32 | })); |
| 33 | 33 | |
| 34 | +const settingsSearchState = vi.hoisted(() => ({ | |
| 35 | + targetId: null as string | null, | |
| 36 | + effects: [] as Array<() => void>, | |
| 37 | +})); | |
| 38 | + | |
| 34 | 39 | vi.mock("react", async (importOriginal) => { |
| 35 | 40 | const actual = await importOriginal<typeof import("react")>(); |
| 36 | 41 | const { reactHookHarness } = await import("../../test/reactHookHarness"); |
| 37 | 42 | return { |
| 38 | 43 | ...actual, |
| 39 | 44 | useCallback: reactHookHarness.useCallback, |
| 45 | + useEffect: (effect: () => void) => settingsSearchState.effects.push(effect), | |
| 40 | 46 | useMemo: reactHookHarness.useMemo, |
| 41 | 47 | useRef: reactHookHarness.useRef, |
| 42 | 48 | useState: reactHookHarness.useState, |
| 43 | 49 | }; |
| 44 | 50 | }); |
| 45 | 51 | |
| 52 | +vi.mock("./settingsLayout", async (importOriginal) => { | |
| 53 | + const actual = await importOriginal<typeof import("./settingsLayout")>(); | |
| 54 | + return { | |
| 55 | + ...actual, | |
| 56 | + useSettingsSearchTargetId: () => settingsSearchState.targetId, | |
| 57 | + }; | |
| 58 | +}); | |
| 59 | + | |
| 46 | 60 | vi.mock("react/compiler-runtime", async () => { |
| 47 | 61 | const { reactHookHarness } = await import("../../test/reactHookHarness"); |
| 48 | 62 | return { c: reactHookHarness.useMemoCache }; |
| @@ -131,6 +145,17 @@ function isAddProviderButton(element: ReactElement<Record<string, unknown>>): bo · 82 unmodified lines | ||
| 131 | 145 | return element.props["aria-label"] === "Add provider"; |
| 132 | 146 | } |
| 133 | 147 | |
| 148 | +function findAdvancedPanel(panel: ReactElement<Record<string, unknown>>) { | |
| 149 | + return visitElements( | |
| 150 | + panel, | |
| 151 | + (element) => element.props.className === "mt-1" && typeof element.props.open === "boolean", | |
| 152 | + ); | |
| 153 | +} | |
| 154 | + | |
| 155 | +function flushEffects(): void { | |
| 156 | + for (const effect of settingsSearchState.effects.splice(0)) effect(); | |
| 157 | +} | |
| 158 | + | |
| 134 | 159 | async function flushPromises(): Promise<void> { |
| 135 | 160 | await Promise.resolve(); |
| 136 | 161 | await Promise.resolve(); |
| @@ -144,6 +169,8 @@ describe("EnvironmentProviderSettings routing", () => { · 7 unmodified lines | ||
| 144 | 169 | settingsState.readEnvironmentIds = []; |
| 145 | 170 | settingsState.updateEnvironmentIds = []; |
| 146 | 171 | settingsState.updateSettings.mockReset(); |
| 172 | + settingsSearchState.targetId = null; | |
| 173 | + settingsSearchState.effects = []; | |
| 147 | 174 | commands.refresh.mockReset().mockResolvedValue({ _tag: "Success" }); |
| 148 | 175 | commands.updateProvider.mockReset().mockResolvedValue({ _tag: "Success" }); |
| 149 | 176 | }); |
| @@ -235,6 +262,17 @@ describe("EnvironmentProviderSettings routing", () => { · 85 unmodified lines | ||
| 235 | 262 | expect(visitElements(panel, isAddProviderButton)).not.toBeNull(); |
| 236 | 263 | }); |
| 237 | 264 | |
| 265 | + it("opens Advanced when search targets the provider health interval", () => { | |
| 266 | + settingsSearchState.targetId = "provider-health-check-interval"; | |
| 267 | + let panel = renderPanel(); | |
| 268 | + | |
| 269 | + expect(findAdvancedPanel(panel)?.props.open).toBe(false); | |
| 270 | + flushEffects(); | |
| 271 | + | |
| 272 | + panel = renderPanel(); | |
| 273 | + expect(findAdvancedPanel(panel)?.props.open).toBe(true); | |
| 274 | + }); | |
| 275 | + | |
| 238 | 276 | it("deletes and resets provider configuration without erasing shared preferences", () => { |
| 239 | 277 | settingsState.value = { |
| 240 | 278 | ...DEFAULT_UNIFIED_SETTINGS, |
| @@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test"; · 3 unmodified lines | ||
| 4 | 4 | import { |
| 5 | 5 | buildProviderEnvironmentOptions, |
| 6 | 6 | classifyProviderEnvironmentAccess, |
| 7 | + isProviderSettingsEnvironmentAvailable, | |
| 7 | 8 | resolvePrimaryOperateAccess, |
| 8 | 9 | resolveRemoteOperateAccess, |
| 9 | 10 | resolveSelectedProviderEnvironmentId, |
| @@ -20,6 +21,27 @@ const environments = [ · 10 unmodified lines | ||
| 20 | 21 | ] as const; |
| 21 | 22 | |
| 22 | 23 | describe("provider environment selection", () => { |
| 24 | + it("requires a connected environment with server config for searchable provider settings", () => { | |
| 25 | + expect( | |
| 26 | + isProviderSettingsEnvironmentAvailable({ | |
| 27 | + connectionPhase: "connected", | |
| 28 | + hasServerConfig: true, | |
| 29 | + }), | |
| 30 | + ).toBe(true); | |
| 31 | + expect( | |
| 32 | + isProviderSettingsEnvironmentAvailable({ | |
| 33 | + connectionPhase: "reconnecting", | |
| 34 | + hasServerConfig: true, | |
| 35 | + }), | |
| 36 | + ).toBe(false); | |
| 37 | + expect( | |
| 38 | + isProviderSettingsEnvironmentAvailable({ | |
| 39 | + connectionPhase: "connected", | |
| 40 | + hasServerConfig: false, | |
| 41 | + }), | |
| 42 | + ).toBe(false); | |
| 43 | + }); | |
| 44 | + | |
| 23 | 45 | it("sorts the primary environment first and the rest by label", () => { |
| 24 | 46 | expect( |
| 25 | 47 | buildProviderEnvironmentOptions(environments, primaryId).map( |
| @@ -10,6 +10,13 @@ export interface ProviderEnvironmentOptionLike { · 9 unmodified lines | ||
| 10 | 10 | readonly label: string; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | +export function isProviderSettingsEnvironmentAvailable(input: { | |
| 14 | + readonly connectionPhase: EnvironmentConnectionPhase; | |
| 15 | + readonly hasServerConfig: boolean; | |
| 16 | +}): boolean { | |
| 17 | + return input.connectionPhase === "connected" && input.hasServerConfig; | |
| 18 | +} | |
| 19 | + | |
| 13 | 20 | export function buildProviderEnvironmentOptions<T extends ProviderEnvironmentOptionLike>( |
| 14 | 21 | environments: ReadonlyArray<T>, |
| 15 | 22 | primaryEnvironmentId: EnvironmentId | null, |
| @@ -33,7 +33,7 @@ import { · 32 unmodified lines | ||
| 33 | 33 | RefreshCwIcon, |
| 34 | 34 | TerminalIcon, |
| 35 | 35 | } from "lucide-react"; |
| 36 | −import { useCallback, useMemo, useRef, useState, type ReactNode } from "react"; | |
| 36 | +import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; | |
| 37 | 37 | |
| 38 | 38 | import { isDesktopLocalConnectionTarget } from "../../connection/desktopLocal"; |
| 39 | 39 | import { isElectron } from "../../env"; |
| @@ -93,10 +93,12 @@ import { · 53 unmodified lines | ||
| 93 | 93 | SettingsRow, |
| 94 | 94 | SettingsSection, |
| 95 | 95 | useRelativeTimeTick, |
| 96 | + useSettingsSearchTargetId, | |
| 96 | 97 | } from "./settingsLayout"; |
| 97 | 98 | import { |
| 98 | 99 | buildProviderEnvironmentOptions, |
| 99 | 100 | classifyProviderEnvironmentAccess, |
| 101 | + isProviderSettingsEnvironmentAvailable, | |
| 100 | 102 | type ProviderEnvironmentAccess, |
| 101 | 103 | type ProviderOperateAccess, |
| 102 | 104 | resolvePrimaryOperateAccess, |
| @@ -189,7 +191,7 @@ function EnvironmentUnavailableRow({ · 86 unmodified lines | ||
| 189 | 191 | // No spinner: this state can persist indefinitely for a wedged device, and a |
| 190 | 192 | // continuously repainting animation would run the whole time. |
| 191 | 193 | return ( |
| 192 | − <SettingsSection title="Providers"> | |
| 194 | + <SettingsSection {...searchableSetting("providers")}> | |
| 193 | 195 | {deviceTabs} |
| 194 | 196 | <SettingsRow title={title} description={description} /> |
| 195 | 197 | </SettingsSection> |
| @@ -197,8 +199,17 @@ function EnvironmentUnavailableRow({ · 1 unmodified line | ||
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | export function ProviderSettingsPanel() { |
| 202 | + return ( | |
| 203 | + <SettingsPageContainer className="gap-8"> | |
| 204 | + <ProviderSettingsPanelContent /> | |
| 205 | + </SettingsPageContainer> | |
| 206 | + ); | |
| 207 | +} | |
| 208 | + | |
| 209 | +function ProviderSettingsPanelContent() { | |
| 200 | 210 | const { environments, isReady } = useEnvironments(); |
| 201 | 211 | const primaryEnvironmentId = usePrimaryEnvironmentId(); |
| 212 | + const searchTargetId = useSettingsSearchTargetId(); | |
| 202 | 213 | const options = useMemo( |
| 203 | 214 | () => buildProviderEnvironmentOptions(environments, primaryEnvironmentId), |
| 204 | 215 | [environments, primaryEnvironmentId], |
| @@ -216,6 +227,27 @@ export function ProviderSettingsPanel() { · 11 unmodified lines | ||
| 216 | 227 | ); |
| 217 | 228 | const selectedEnvironment = |
| 218 | 229 | options.find((environment) => environment.environmentId === effectiveEnvironmentId) ?? null; |
| 230 | + const selectedEnvironmentCanRenderSettings = | |
| 231 | + selectedEnvironment !== null && | |
| 232 | + isProviderSettingsEnvironmentAvailable({ | |
| 233 | + connectionPhase: selectedEnvironment.connection.phase, | |
| 234 | + hasServerConfig: selectedEnvironment.serverConfig !== null, | |
| 235 | + }); | |
| 236 | + const searchableEnvironmentId = options.find((environment) => | |
| 237 | + isProviderSettingsEnvironmentAvailable({ | |
| 238 | + connectionPhase: environment.connection.phase, | |
| 239 | + hasServerConfig: environment.serverConfig !== null, | |
| 240 | + }), | |
| 241 | + )?.environmentId; | |
| 242 | + useEffect(() => { | |
| 243 | + if ( | |
| 244 | + searchTargetId === searchableSetting("provider-health-check-interval").id && | |
| 245 | + !selectedEnvironmentCanRenderSettings && | |
| 246 | + searchableEnvironmentId !== undefined | |
| 247 | + ) { | |
| 248 | + setSelectedEnvironmentId(searchableEnvironmentId); | |
| 249 | + } | |
| 250 | + }, [searchTargetId, searchableEnvironmentId, selectedEnvironmentCanRenderSettings]); | |
| 219 | 251 | const onlyPrimaryDevice = |
| 220 | 252 | options.length === 1 && options[0]?.entry.target._tag === "PrimaryConnectionTarget"; |
| 221 | 253 | const deviceTabs = |
| @@ -266,9 +298,9 @@ export function ProviderSettingsPanel() { · 44 unmodified lines | ||
| 266 | 298 | ) : null; |
| 267 | 299 | |
| 268 | 300 | return ( |
| 269 | − <SettingsPageContainer className="gap-8"> | |
| 301 | + <> | |
| 270 | 302 | {options.length === 0 ? ( |
| 271 | − <SettingsSection title="Providers"> | |
| 303 | + <SettingsSection {...searchableSetting("providers")}> | |
| 272 | 304 | <SettingsRow |
| 273 | 305 | title={isReady ? "No connected devices" : "Loading devices"} |
| 274 | 306 | description={ |
| @@ -287,7 +319,7 @@ export function ProviderSettingsPanel() { · 12 unmodified lines | ||
| 287 | 319 | deviceTabs={deviceTabs} |
| 288 | 320 | /> |
| 289 | 321 | ) : null} |
| 290 | − </SettingsPageContainer> | |
| 322 | + </> | |
| 291 | 323 | ); |
| 292 | 324 | } |
| 293 | 325 | |
| @@ -429,12 +461,19 @@ export function EnvironmentProviderSettings({ · 135 unmodified lines | ||
| 429 | 461 | const [isAddInstanceDialogOpen, setIsAddInstanceDialogOpen] = useState(false); |
| 430 | 462 | const [selectedInstanceId, setSelectedInstanceId] = useState<ProviderInstanceId | null>(null); |
| 431 | 463 | const [advancedOpen, setAdvancedOpen] = useState(false); |
| 464 | + const searchTargetId = useSettingsSearchTargetId(); | |
| 432 | 465 | const [updatingProviderDrivers, setUpdatingProviderDrivers] = useState< |
| 433 | 466 | ReadonlySet<ProviderDriverKind> |
| 434 | 467 | >(() => new Set()); |
| 435 | 468 | const refreshingRef = useRef(false); |
| 436 | 469 | const updatingDriversRef = useRef<Set<ProviderDriverKind>>(new Set()); |
| 437 | 470 | |
| 471 | + useEffect(() => { | |
| 472 | + if (searchTargetId === searchableSetting("provider-health-check-interval").id) { | |
| 473 | + setAdvancedOpen(true); | |
| 474 | + } | |
| 475 | + }, [searchTargetId]); | |
| 476 | + | |
| 438 | 477 | const providerUpdateCandidates = useMemo( |
| 439 | 478 | () => collectProviderUpdateCandidates(serverProviders), |
| 440 | 479 | [serverProviders], |
| @@ -915,9 +954,10 @@ export function EnvironmentProviderSettings({ · 474 unmodified lines | ||
| 915 | 954 | className={readOnly ? "opacity-50 select-none" : undefined} |
| 916 | 955 | > |
| 917 | 956 | <SettingsRow |
| 957 | + id={searchableSetting("provider-health-check-interval").id} | |
| 918 | 958 | title={ |
| 919 | 959 | <span className="inline-flex items-center gap-1.5"> |
| 920 | − Health check interval | |
| 960 | + {searchableSetting("provider-health-check-interval").title} | |
| 921 | 961 | <PolicyTooltip> |
| 922 | 962 | This interval is configured here, then the shared Background activity policy |
| 923 | 963 | decides whether provider probes may run when the timer fires. Custom |
| @@ -790,7 +790,9 @@ function BackgroundActivityAdvancedDialog({ · 789 unmodified lines | ||
| 790 | 790 | |
| 791 | 791 | <div className="flex flex-col gap-3 border-b px-4 py-3 sm:flex-row sm:items-center sm:justify-between"> |
| 792 | 792 | <div className="min-w-0 space-y-1"> |
| 793 | − <div className="text-sm font-medium">Git fetch interval</div> | |
| 793 | + <div className="text-sm font-medium"> | |
| 794 | + {searchableSetting("git-fetch-interval").title} | |
| 795 | + </div> | |
| 794 | 796 | <p className="text-xs leading-relaxed text-muted-foreground"> |
| 795 | 797 | Refresh remote branch status in the background. |
| 796 | 798 | </p> |
| @@ -2009,7 +2011,7 @@ export function GeneralSettingsPanel() { · 1212 unmodified lines | ||
| 2009 | 2011 | /> |
| 2010 | 2012 | {settings.sidebarAutoSettleAfterDays !== null ? ( |
| 2011 | 2013 | <SettingsRow |
| 2012 | − title="Days of inactivity before auto-settle" | |
| 2014 | + title={searchableSetting("days-before-auto-settle").title} | |
| 2013 | 2015 | description="Any new activity un-settles a thread automatically." |
| 2014 | 2016 | control={ |
| 2015 | 2017 | <AutoSettleDaysInput |
| @@ -2142,9 +2144,10 @@ export function GeneralSettingsPanel() { · 126 unmodified lines | ||
| 2142 | 2144 | /> |
| 2143 | 2145 | |
| 2144 | 2146 | <SettingsRow |
| 2147 | + id={searchableSetting("background-activity").id} | |
| 2145 | 2148 | title={ |
| 2146 | 2149 | <span className="inline-flex items-center gap-1.5"> |
| 2147 | − Background activity | |
| 2150 | + {searchableSetting("background-activity").title} | |
| 2148 | 2151 | <PolicyTooltip> |
| 2149 | 2152 | This shared policy gates background work such as Git refreshes and provider health |
| 2150 | 2153 | probes after their individual intervals elapse. |
| @@ -7,8 +7,6 @@ import { · 6 unmodified lines | ||
| 7 | 7 | type ComponentType, |
| 8 | 8 | type KeyboardEvent, |
| 9 | 9 | } from "react"; |
| 10 | −import { useEnvironmentQuery } from "~/state/query"; | |
| 11 | −import { desktopWslStateAtom } from "~/state/desktopWslState"; | |
| 12 | 10 | import { |
| 13 | 11 | ArchiveIcon, |
| 14 | 12 | BlocksIcon, |
| @@ -23,8 +21,6 @@ import { · 8 unmodified lines | ||
| 23 | 21 | } from "lucide-react"; |
| 24 | 22 | import { useLocation, useNavigate } from "@tanstack/react-router"; |
| 25 | 23 | |
| 26 | −import { isElectron } from "~/env"; | |
| 27 | −import { isWslSettingsRowVisible } from "./ConnectionsSettings.logic"; | |
| 28 | 24 | import { Button } from "../ui/button"; |
| 29 | 25 | import { Input } from "../ui/input"; |
| 30 | 26 | import { Kbd } from "../ui/kbd"; |
| @@ -42,11 +38,11 @@ import { SidebarUtilityMenu } from "../sidebar/SidebarChrome"; · 11 unmodified lines | ||
| 42 | 38 | import { scrollToSettingsTarget } from "./settingsLayout"; |
| 43 | 39 | import { |
| 44 | 40 | searchSettings, |
| 45 | − SETTINGS_SEARCH_ITEMS, | |
| 46 | 41 | SETTINGS_SECTION_LABELS, |
| 47 | 42 | type SettingsPath, |
| 48 | 43 | type SettingsSearchItem, |
| 49 | 44 | } from "./settingsSearch"; |
| 45 | +import { useAvailableSettingsSearchItems } from "./useAvailableSettingsSearchItems"; | |
| 50 | 46 | |
| 51 | 47 | const SETTINGS_SECTION_ICONS: Readonly< |
| 52 | 48 | Record<SettingsPath, ComponentType<{ className?: string }>> |
| @@ -83,18 +79,7 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) { · 30 unmodified lines | ||
| 83 | 79 | const searchInputRef = useRef<HTMLInputElement>(null); |
| 84 | 80 | const [query, setQuery] = useState(""); |
| 85 | 81 | const [activeResultIndex, setActiveResultIndex] = useState(0); |
| 86 | − const desktopWsl = useEnvironmentQuery(isElectron ? desktopWslStateAtom : null); | |
| 87 | − const searchableItems = useMemo(() => { | |
| 88 | − const wslState = desktopWsl.data; | |
| 89 | − const rowRenders = isWslSettingsRowVisible({ | |
| 90 | − state: wslState, | |
| 91 | − error: desktopWsl.error, | |
| 92 | − }); | |
| 93 | − if (rowRenders) { | |
| 94 | − return SETTINGS_SEARCH_ITEMS; | |
| 95 | − } | |
| 96 | − return SETTINGS_SEARCH_ITEMS.filter((item) => item.id !== "wsl-backend"); | |
| 97 | − }, [desktopWsl.data, desktopWsl.error]); | |
| 82 | + const searchableItems = useAvailableSettingsSearchItems(); | |
| 98 | 83 | const results = useMemo(() => searchSettings(query, searchableItems), [query, searchableItems]); |
| 99 | 84 | const isSearching = query.trim().length > 0; |
| 100 | 85 | const hasResults = results.length > 0; |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { ChevronDownIcon, GitPullRequestIcon, RefreshCwIcon } from "lucide-react"; |
| 2 | 2 | import * as Duration from "effect/Duration"; |
| 3 | 3 | import * as Option from "effect/Option"; |
| 4 | −import { useState, type ReactNode } from "react"; | |
| 4 | +import { useEffect, useState, type ReactNode } from "react"; | |
| 5 | 5 | import type { |
| 6 | 6 | BackgroundActivitySettings, |
| 7 | 7 | SourceControlProviderKind, |
| @@ -59,7 +59,9 @@ import { · 51 unmodified lines | ||
| 59 | 59 | PolicyTooltip, |
| 60 | 60 | SettingResetButton, |
| 61 | 61 | SettingsPageContainer, |
| 62 | + SettingsSearchTarget, | |
| 62 | 63 | SettingsSection, |
| 64 | + useSettingsSearchTargetId, | |
| 63 | 65 | } from "./settingsLayout"; |
| 64 | 66 | import { searchableSetting } from "./settingsSearch"; |
| 65 | 67 | |
| @@ -267,6 +269,13 @@ function DiscoveryItemRow({ · 201 unmodified lines | ||
| 267 | 269 | const authAccount = auth ? optionLabel(auth.account) : null; |
| 268 | 270 | const [isExpanded, setIsExpanded] = useState(false); |
| 269 | 271 | const hasDetails = children !== undefined; |
| 272 | + const searchTargetId = useSettingsSearchTargetId(); | |
| 273 | + | |
| 274 | + useEffect(() => { | |
| 275 | + if (item.kind === "git" && searchTargetId === searchableSetting("git-fetch-interval").id) { | |
| 276 | + setIsExpanded(true); | |
| 277 | + } | |
| 278 | + }, [item.kind, searchTargetId]); | |
| 270 | 279 | |
| 271 | 280 | return ( |
| 272 | 281 | <div |
| @@ -345,13 +354,14 @@ function GitFetchIntervalSettings() { · 72 unmodified lines | ||
| 345 | 354 | ); |
| 346 | 355 | const canResetFetchInterval = |
| 347 | 356 | automaticGitFetchIntervalSeconds !== defaultAutomaticGitFetchIntervalSeconds; |
| 357 | + const setting = searchableSetting("git-fetch-interval"); | |
| 348 | 358 | |
| 349 | 359 | return ( |
| 350 | − <div className="grid gap-3"> | |
| 360 | + <SettingsSearchTarget id={setting.id} className="grid gap-3"> | |
| 351 | 361 | <div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between"> |
| 352 | 362 | <div className="min-w-0 space-y-1"> |
| 353 | 363 | <div className="flex min-w-0 items-center gap-1"> |
| 354 | − <span className="text-xs font-medium text-foreground">Fetch interval</span> | |
| 364 | + <span className="text-xs font-medium text-foreground">{setting.title}</span> | |
| 355 | 365 | <PolicyTooltip> |
| 356 | 366 | This interval is configured for Git only. The shared Background activity policy still |
| 357 | 367 | decides whether Git refreshes may run when the timer fires. Custom intervals appear as |
| @@ -407,7 +417,7 @@ function GitFetchIntervalSettings() { · 49 unmodified lines | ||
| 407 | 417 | <span className="text-xs text-muted-foreground">seconds</span> |
| 408 | 418 | </div> |
| 409 | 419 | </div> |
| 410 | − </div> | |
| 420 | + </SettingsSearchTarget> | |
| 411 | 421 | ); |
| 412 | 422 | } |
| 413 | 423 | |
| @@ -21,6 +21,7 @@ import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ · 20 unmodified lines | ||
| 21 | 21 | import { Switch } from "../ui/switch"; |
| 22 | 22 | import { Textarea } from "../ui/textarea"; |
| 23 | 23 | import { SettingResetButton, SettingsRow, SettingsSection } from "./settingsLayout"; |
| 24 | +import { searchableSetting } from "./settingsSearch"; | |
| 24 | 25 | |
| 25 | 26 | const MODE_OPTIONS: Record<SourceControlWritingStyleMode, { label: string; description: string }> = |
| 26 | 27 | { |
| @@ -73,7 +74,7 @@ export function SourceControlWritingSettingsSection() { · 46 unmodified lines | ||
| 73 | 74 | return ( |
| 74 | 75 | <SettingsSection title="Text generation"> |
| 75 | 76 | <SettingsRow |
| 76 | − title="Source control writing style" | |
| 77 | + {...searchableSetting("source-control-writing-style")} | |
| 77 | 78 | description={MODE_OPTIONS[style.mode].description} |
| 78 | 79 | resetAction={ |
| 79 | 80 | isSourceControlWritingStyleDirty ? ( |
| @@ -137,7 +138,7 @@ export function SourceControlWritingSettingsSection() { · 57 unmodified lines | ||
| 137 | 138 | </SettingsRow> |
| 138 | 139 | |
| 139 | 140 | <SettingsRow |
| 140 | − title="Follow change request templates" | |
| 141 | + {...searchableSetting("follow-change-request-templates")} | |
| 141 | 142 | description="Structures change request descriptions using the current repository's template when one is available." |
| 142 | 143 | resetAction={ |
| 143 | 144 | style.followChangeRequestTemplates !== defaults.followChangeRequestTemplates ? ( |
| @@ -169,7 +170,7 @@ export function SourceControlWritingSettingsSection() { · 25 unmodified lines | ||
| 169 | 170 | /> |
| 170 | 171 | |
| 171 | 172 | <SettingsRow |
| 172 | − title="Source control writer model" | |
| 173 | + {...searchableSetting("source-control-writer-model")} | |
| 173 | 174 | description="Optional model override for change descriptions, change request titles and descriptions, and branch or bookmark names. Off uses the global text generation model." |
| 174 | 175 | control={ |
| 175 | 176 | <div className="flex flex-wrap items-center justify-end gap-2"> |
| @@ -41,6 +41,7 @@ import { Button } from "../ui/button"; · 40 unmodified lines | ||
| 41 | 41 | import { stackedThreadToast, toastManager } from "../ui/toast"; |
| 42 | 42 | import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "../ui/tooltip"; |
| 43 | 43 | import { ThemeImportDialog } from "./ThemeImportDialog"; |
| 44 | +import { searchableSetting } from "./settingsSearch"; | |
| 44 | 45 | import { useThemeEditorStore } from "./themeEditorStore"; |
| 45 | 46 | import { |
| 46 | 47 | STANDARD_THEME_CARDS, |
| @@ -892,11 +893,13 @@ export function ThemeLibrary({ · 845 unmodified lines | ||
| 892 | 893 | Choose how T3 Code looks. Use a built-in theme or make your own. |
| 893 | 894 | </p> |
| 894 | 895 | <h3 className="px-3 text-sm font-medium tracking-[-0.005em] text-foreground sm:px-4"> |
| 895 | − Color scheme | |
| 896 | + {searchableSetting("color-scheme").title} | |
| 896 | 897 | </h3> |
| 897 | 898 | {renderModeTiles()} |
| 898 | 899 | <div className="flex min-h-8 flex-wrap items-center justify-between gap-3 px-3 pt-2 sm:px-4"> |
| 899 | − <h3 className="text-sm font-medium tracking-[-0.005em] text-foreground">Themes</h3> | |
| 900 | + <h3 className="text-sm font-medium tracking-[-0.005em] text-foreground"> | |
| 901 | + {searchableSetting("theme").title} | |
| 902 | + </h3> | |
| 900 | 903 | <div className="flex flex-wrap items-center justify-end gap-2"> |
| 901 | 904 | <Button |
| 902 | 905 | size="xs" |
| @@ -84,6 +84,18 @@ function useSettingsSearchTarget<T extends HTMLElement>(id: string | undefined) · 83 unmodified lines | ||
| 84 | 84 | return targetRef; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | +export function SettingsSearchTarget({ | |
| 88 | + children, | |
| 89 | + ...targetProps | |
| 90 | +}: ComponentPropsWithoutRef<"div">) { | |
| 91 | + const targetRef = useSettingsSearchTarget<HTMLDivElement>(targetProps.id); | |
| 92 | + return ( | |
| 93 | + <div {...targetProps} ref={targetRef} tabIndex={targetProps.id ? -1 : targetProps.tabIndex}> | |
| 94 | + {children} | |
| 95 | + </div> | |
| 96 | + ); | |
| 97 | +} | |
| 98 | + | |
| 87 | 99 | /** Info affordance explaining how a setting interacts with the shared background policy. */ |
| 88 | 100 | export function PolicyTooltip({ children }: { readonly children: string }) { |
| 89 | 101 | return ( |
| @@ -1,6 +1,7 @@ | ||
| 1 | −import { describe, expect, it } from "vite-plus/test"; | |
| 1 | +import { describe, expect, it, vi } from "vite-plus/test"; | |
| 2 | 2 | |
| 3 | 3 | import { |
| 4 | + filterAvailableSettingsSearchItems, | |
| 4 | 5 | searchableSetting, |
| 5 | 6 | searchSettings, |
| 6 | 7 | SETTINGS_SEARCH_ITEMS, |
| @@ -12,16 +13,19 @@ const ITEMS: ReadonlyArray<SettingsSearchItem> = [ · 5 unmodified lines | ||
| 12 | 13 | id: "word-wrap", |
| 13 | 14 | title: "Word wrap", |
| 14 | 15 | to: "/settings/general", |
| 16 | + searchTerms: ["long lines in code previews"], | |
| 15 | 17 | }, |
| 16 | 18 | { |
| 17 | 19 | id: "network-access", |
| 18 | 20 | title: "Network access", |
| 19 | 21 | to: "/settings/connections", |
| 22 | + searchTerms: ["remote pairing backend"], | |
| 20 | 23 | }, |
| 21 | 24 | { |
| 22 | 25 | id: "providers", |
| 23 | 26 | title: "Providers", |
| 24 | 27 | to: "/settings/providers", |
| 28 | + searchTerms: ["claude codex agents"], | |
| 25 | 29 | }, |
| 26 | 30 | { |
| 27 | 31 | id: "provider-updates", |
| @@ -36,16 +40,25 @@ const ITEMS: ReadonlyArray<SettingsSearchItem> = [ · 8 unmodified lines | ||
| 36 | 40 | ]; |
| 37 | 41 | |
| 38 | 42 | describe("searchSettings", () => { |
| 39 | − it("matches only setting titles", () => { | |
| 43 | + it("matches titles, sections, and remembered setting details", () => { | |
| 40 | 44 | expect(searchSettings("word", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]); |
| 41 | 45 | expect(searchSettings("network", ITEMS).map((item) => item.id)).toEqual(["network-access"]); |
| 42 | − expect(searchSettings("connections", ITEMS)).toEqual([]); | |
| 43 | − expect(searchSettings("claude", ITEMS)).toEqual([]); | |
| 46 | + expect(searchSettings("connections", ITEMS).map((item) => item.id)).toEqual(["network-access"]); | |
| 47 | + expect(searchSettings("claude", ITEMS).map((item) => item.id)).toEqual(["providers"]); | |
| 48 | + expect(searchSettings("long lines", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]); | |
| 44 | 49 | }); |
| 45 | 50 | |
| 46 | 51 | it("matches normalized title substrings", () => { |
| 47 | 52 | expect(searchSettings(" WORD WRAP ", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]); |
| 48 | 53 | expect(searchSettings("glass").map((item) => item.id)).toEqual(["setting-glass-opacity"]); |
| 54 | + expect(searchSettings("thè\u{1ab0}mes")[0]?.id).toBe("theme"); | |
| 55 | + const localeLowerCase = vi.spyOn(String.prototype, "toLocaleLowerCase").mockReturnValue("gıt"); | |
| 56 | + try { | |
| 57 | + expect(searchSettings("GIT")[0]?.id).toBe("git-fetch-interval"); | |
| 58 | + expect(localeLowerCase).not.toHaveBeenCalled(); | |
| 59 | + } finally { | |
| 60 | + localeLowerCase.mockRestore(); | |
| 61 | + } | |
| 49 | 62 | expect(searchSettings("xyzzy")).toEqual([]); |
| 50 | 63 | }); |
| 51 | 64 | |
| @@ -56,6 +69,27 @@ describe("searchSettings", () => { · 4 unmodified lines | ||
| 56 | 69 | ]); |
| 57 | 70 | }); |
| 58 | 71 | |
| 72 | + it("matches query words across fields and ranks the strongest result first", () => { | |
| 73 | + expect(searchSettings("pairing remote", ITEMS).map((item) => item.id)).toEqual([ | |
| 74 | + "network-access", | |
| 75 | + ]); | |
| 76 | + expect( | |
| 77 | + searchSettings("remote pairing") | |
| 78 | + .slice(0, 2) | |
| 79 | + .map((item) => item.id), | |
| 80 | + ).toEqual(["network-access", "connections-environment"]); | |
| 81 | + }); | |
| 82 | + | |
| 83 | + it("finds settings that used to be reachable only through their section", () => { | |
| 84 | + expect(searchSettings("pull request template")[0]?.id).toBe("follow-change-request-templates"); | |
| 85 | + expect(searchSettings("git security keys")[0]?.id).toBe("git-fetch-interval"); | |
| 86 | + expect(searchSettings("push notifications")[0]?.id).toBe("publish-agent-activity"); | |
| 87 | + expect(searchSettings("battery saver")[0]?.id).toBe("background-activity"); | |
| 88 | + expect(searchSettings("binary path")[0]?.id).toBe("providers"); | |
| 89 | + expect(searchSettings("authorized clients")[0]?.id).toBe("connections-environment"); | |
| 90 | + expect(searchSettings("administrative access")[0]?.id).toBe("connections-environment"); | |
| 91 | + }); | |
| 92 | + | |
| 59 | 93 | it("lists thread confirmations in panel order", () => { |
| 60 | 94 | expect(searchSettings("confirmation").map((item) => item.id)).toEqual([ |
| 61 | 95 | "unpin-confirmation", |
| @@ -74,8 +108,17 @@ describe("searchSettings", () => { · 12 unmodified lines | ||
| 74 | 108 | expect(searchSettings("wsl")).toEqual([]); |
| 75 | 109 | }); |
| 76 | 110 | |
| 111 | + it("hides macOS-only settings on other platforms", () => { | |
| 112 | + vi.stubGlobal("navigator", { platform: "Win32" }); | |
| 113 | + try { | |
| 114 | + expect(searchSettings("font smoothing")).toEqual([]); | |
| 115 | + } finally { | |
| 116 | + vi.unstubAllGlobals(); | |
| 117 | + } | |
| 118 | + }); | |
| 119 | + | |
| 77 | 120 | it("registers the WSL backend as a desktop-only setting", () => { |
| 78 | − expect(SETTINGS_SEARCH_ITEMS).toContainEqual({ | |
| 121 | + expect(SETTINGS_SEARCH_ITEMS.find((item) => item.id === "wsl-backend")).toMatchObject({ | |
| 79 | 122 | id: "wsl-backend", |
| 80 | 123 | title: "WSL backend", |
| 81 | 124 | to: "/settings/connections", |
| @@ -84,6 +127,30 @@ describe("searchSettings", () => { · 2 unmodified lines | ||
| 84 | 127 | }); |
| 85 | 128 | }); |
| 86 | 129 | |
| 130 | + it("hides settings whose controls are unavailable", () => { | |
| 131 | + const available = filterAvailableSettingsSearchItems({ | |
| 132 | + hasCloudPublicConfig: false, | |
| 133 | + hasPrimaryEnvironment: false, | |
| 134 | + hasProviderSettingsEnvironment: false, | |
| 135 | + canManageLocalBackend: false, | |
| 136 | + isWslSettingsRowVisible: false, | |
| 137 | + }); | |
| 138 | + | |
| 139 | + const gatedIds = new Set<string>([ | |
| 140 | + "follow-change-request-templates", | |
| 141 | + "git-fetch-interval", | |
| 142 | + "network-access", | |
| 143 | + "publish-agent-activity", | |
| 144 | + "provider-health-check-interval", | |
| 145 | + "source-control-writer-model", | |
| 146 | + "source-control-writing-style", | |
| 147 | + "t3-connect", | |
| 148 | + "tailscale-https", | |
| 149 | + "wsl-backend", | |
| 150 | + ]); | |
| 151 | + expect(available.map((item) => item.id).filter((id) => gatedIds.has(id))).toEqual([]); | |
| 152 | + }); | |
| 153 | + | |
| 87 | 154 | it("keeps catalog result ids unique", () => { |
| 88 | 155 | const ids = SETTINGS_SEARCH_ITEMS.map((item) => item.id); |
| 89 | 156 | expect(new Set(ids).size).toBe(ids.length); |
| @@ -111,10 +178,11 @@ describe("searchSettings", () => { · 21 unmodified lines | ||
| 111 | 178 | }); |
| 112 | 179 | |
| 113 | 180 | it("routes browser recording quality to integrations", () => { |
| 114 | − expect(searchSettings("recording frame rate")[0]).toMatchObject({ | |
| 181 | + const result = searchSettings("recording frame rate")[0]; | |
| 182 | + expect(result).toMatchObject({ | |
| 115 | 183 | id: "browser-recording-frame-rate", |
| 116 | 184 | to: "/settings/integrations", |
| 117 | − targetId: "browser", | |
| 118 | 185 | }); |
| 186 | + expect(result).not.toHaveProperty("targetId"); | |
| 119 | 187 | }); |
| 120 | 188 | }); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { isElectron } from "~/env"; |
| 2 | −import { isWindowsPlatform } from "~/lib/utils"; | |
| 2 | +import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils"; | |
| 3 | 3 | |
| 4 | 4 | export type SettingsPath = |
| 5 | 5 | | "/settings/general" |
| @@ -16,12 +16,28 @@ export interface SettingsSearchItem { · 10 unmodified lines | ||
| 16 | 16 | readonly title: string; |
| 17 | 17 | readonly to: SettingsPath; |
| 18 | 18 | readonly targetId?: string; |
| 19 | + /** Descriptions, option labels, and aliases people may remember instead of the title. */ | |
| 20 | + readonly searchTerms?: ReadonlyArray<string>; | |
| 19 | 21 | // Its row only renders in the desktop app, so a browser result would land on |
| 20 | 22 | // an anchor that isn't there. |
| 21 | 23 | readonly desktopOnly?: boolean; |
| 24 | + readonly macOnly?: boolean; | |
| 22 | 25 | // Its row only renders on Windows desktop, so other desktop platforms must |
| 23 | 26 | // not expose a result that points to a missing anchor. |
| 24 | 27 | readonly windowsOnly?: boolean; |
| 28 | + readonly cloudOnly?: boolean; | |
| 29 | + readonly primaryOnly?: boolean; | |
| 30 | + readonly providerSettingsOnly?: boolean; | |
| 31 | + readonly localBackendManagementOnly?: boolean; | |
| 32 | + readonly wslAvailableOnly?: boolean; | |
| 33 | +} | |
| 34 | + | |
| 35 | +export interface SettingsSearchAvailability { | |
| 36 | + readonly hasCloudPublicConfig: boolean; | |
| 37 | + readonly hasPrimaryEnvironment: boolean; | |
| 38 | + readonly hasProviderSettingsEnvironment: boolean; | |
| 39 | + readonly canManageLocalBackend: boolean; | |
| 40 | + readonly isWslSettingsRowVisible: boolean; | |
| 25 | 41 | } |
| 26 | 42 | |
| 27 | 43 | /** |
| @@ -40,16 +56,16 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = { · 12 unmodified lines | ||
| 40 | 56 | }; |
| 41 | 57 | |
| 42 | 58 | /** |
| 43 | − * Every searchable setting, in result order. This catalog is the single | |
| 44 | − * source of truth for anchor ids and visible titles: panels render both via | |
| 45 | − * `searchableSetting`, so a retitle (or, later, a translation pass) happens | |
| 46 | − * here once instead of separately in the panel and the index. | |
| 59 | + * Searchable settings and stable destinations, in result order. Rows with a | |
| 60 | + * dedicated anchor render their id and title via `searchableSetting`; items | |
| 61 | + * that may not be mounted point at their nearest stable section instead. | |
| 47 | 62 | */ |
| 48 | 63 | export const SETTINGS_SEARCH_ITEMS = [ |
| 49 | 64 | { |
| 50 | 65 | id: "color-scheme", |
| 51 | 66 | title: "Color scheme", |
| 52 | 67 | to: "/settings/appearance", |
| 68 | + searchTerms: ["appearance light dark system mode"], | |
| 53 | 69 | // The scheme tiles sit at the top of the Appearance section. |
| 54 | 70 | targetId: "appearance", |
| 55 | 71 | }, |
| @@ -57,6 +73,7 @@ export const SETTINGS_SEARCH_ITEMS = [ · 1 unmodified line | ||
| 57 | 73 | id: "theme", |
| 58 | 74 | title: "Themes", |
| 59 | 75 | to: "/settings/appearance", |
| 76 | + searchTerms: ["appearance colors palette custom import"], | |
| 60 | 77 | // Theme cards live directly under the scheme tiles; the section is the |
| 61 | 78 | // stable scroll destination for both. |
| 62 | 79 | targetId: "appearance", |
| @@ -66,17 +83,20 @@ export const SETTINGS_SEARCH_ITEMS = [ · 3 unmodified lines | ||
| 66 | 83 | id: "setting-appearance-contrast", |
| 67 | 84 | title: "Contrast", |
| 68 | 85 | to: "/settings/appearance", |
| 86 | + searchTerms: ["colors borders interface"], | |
| 69 | 87 | }, |
| 70 | 88 | { |
| 71 | 89 | // Prefixed because the slider control already owns the `glass-opacity` id. |
| 72 | 90 | id: "setting-glass-opacity", |
| 73 | 91 | title: "Glass opacity", |
| 74 | 92 | to: "/settings/appearance", |
| 93 | + searchTerms: ["transparent transparency solid menus dialogs composer"], | |
| 75 | 94 | }, |
| 76 | 95 | { |
| 77 | 96 | id: "environment-identification", |
| 78 | 97 | title: "Environment identification", |
| 79 | 98 | to: "/settings/appearance", |
| 99 | + searchTerms: ["dev nightly artwork pill label hide none"], | |
| 80 | 100 | // The setting is stage-dependent, so its parent section is the stable destination. |
| 81 | 101 | targetId: "appearance", |
| 82 | 102 | }, |
| @@ -84,204 +104,339 @@ export const SETTINGS_SEARCH_ITEMS = [ · 1 unmodified line | ||
| 84 | 104 | id: "interface-font", |
| 85 | 105 | title: "Interface font", |
| 86 | 106 | to: "/settings/appearance", |
| 107 | + searchTerms: ["typography family size system sans"], | |
| 87 | 108 | }, |
| 88 | 109 | { |
| 89 | 110 | id: "prompt-font", |
| 90 | 111 | title: "Prompt font", |
| 91 | 112 | to: "/settings/appearance", |
| 113 | + searchTerms: ["typography family size composer input"], | |
| 92 | 114 | }, |
| 93 | 115 | { |
| 94 | 116 | id: "code-font", |
| 95 | 117 | title: "Code font", |
| 96 | 118 | to: "/settings/appearance", |
| 119 | + searchTerms: ["typography family size monospace code blocks diffs file previews"], | |
| 97 | 120 | }, |
| 98 | 121 | { |
| 99 | 122 | id: "terminal-font", |
| 100 | 123 | title: "Terminal font", |
| 101 | 124 | to: "/settings/appearance", |
| 125 | + searchTerms: ["typography family size monospace output"], | |
| 102 | 126 | }, |
| 103 | 127 | { |
| 104 | 128 | id: "font-smoothing", |
| 105 | 129 | title: "Font smoothing", |
| 106 | 130 | to: "/settings/appearance", |
| 131 | + searchTerms: ["typography text grayscale anti aliasing macos thin"], | |
| 132 | + macOnly: true, | |
| 107 | 133 | }, |
| 108 | 134 | { |
| 109 | 135 | id: "word-wrap", |
| 110 | 136 | title: "Word wrap", |
| 111 | 137 | to: "/settings/appearance", |
| 138 | + searchTerms: ["long lines code blocks tables diffs file previews"], | |
| 112 | 139 | }, |
| 113 | 140 | { |
| 114 | 141 | id: "project-grouping", |
| 115 | 142 | title: "Project grouping", |
| 116 | 143 | to: "/settings/general", |
| 144 | + searchTerms: ["combine matching repositories environments sidebar"], | |
| 117 | 145 | }, |
| 118 | 146 | { |
| 119 | 147 | id: "auto-settle-inactive-threads", |
| 120 | 148 | title: "Auto-settle inactive threads", |
| 121 | 149 | to: "/settings/general", |
| 150 | + searchTerms: ["sidebar inactivity days no activity automatically"], | |
| 122 | 151 | }, |
| 123 | 152 | { |
| 124 | 153 | id: "auto-settle-merged-threads", |
| 125 | 154 | title: "Auto-settle merged threads", |
| 126 | 155 | to: "/settings/general", |
| 156 | + searchTerms: ["pull request merge closed automatically sidebar"], | |
| 157 | + }, | |
| 158 | + { | |
| 159 | + id: "days-before-auto-settle", | |
| 160 | + title: "Days of inactivity before auto-settle", | |
| 161 | + to: "/settings/general", | |
| 162 | + targetId: "auto-settle-inactive-threads", | |
| 163 | + searchTerms: ["thread timeout activity sidebar"], | |
| 127 | 164 | }, |
| 128 | 165 | { |
| 129 | 166 | id: "time-format", |
| 130 | 167 | title: "Time format", |
| 131 | 168 | to: "/settings/general", |
| 169 | + searchTerms: ["timestamp clock locale system browser os 12 hour 24 hour"], | |
| 132 | 170 | }, |
| 133 | 171 | { |
| 134 | 172 | id: "hide-whitespace-changes", |
| 135 | 173 | title: "Hide whitespace changes", |
| 136 | 174 | to: "/settings/general", |
| 175 | + searchTerms: ["diff ignore spaces edits default"], | |
| 137 | 176 | }, |
| 138 | 177 | { |
| 139 | 178 | id: "skills-in-slash-menu", |
| 140 | 179 | title: "Show skills in slash menu", |
| 141 | 180 | to: "/settings/general", |
| 181 | + searchTerms: ["command menu dollar $ slash /"], | |
| 142 | 182 | }, |
| 143 | 183 | { |
| 144 | 184 | id: "provider-update-checks", |
| 145 | 185 | title: "Provider update checks", |
| 146 | 186 | to: "/settings/general", |
| 187 | + searchTerms: ["installed cli versions newer available codex claude cursor grok opencode"], | |
| 188 | + }, | |
| 189 | + { | |
| 190 | + id: "background-activity", | |
| 191 | + title: "Background activity", | |
| 192 | + to: "/settings/general", | |
| 193 | + searchTerms: [ | |
| 194 | + "balanced performance battery saver advanced git fetch provider health refresh host power monitor idle policy", | |
| 195 | + ], | |
| 147 | 196 | }, |
| 148 | 197 | { |
| 149 | 198 | id: "new-threads", |
| 150 | 199 | title: "New threads", |
| 151 | 200 | to: "/settings/general", |
| 201 | + searchTerms: ["default workspace mode draft local worktree"], | |
| 152 | 202 | }, |
| 153 | 203 | { |
| 154 | 204 | id: "start-from-origin", |
| 155 | 205 | title: "Start from origin", |
| 156 | 206 | to: "/settings/general", |
| 157 | 207 | targetId: "new-threads", |
| 208 | + searchTerms: ["new worktrees latest matching remote branch local"], | |
| 158 | 209 | }, |
| 159 | 210 | { |
| 160 | 211 | id: "add-project-starts-in", |
| 161 | 212 | title: "Add project starts in", |
| 162 | 213 | to: "/settings/general", |
| 214 | + searchTerms: ["base directory folder browser path home"], | |
| 163 | 215 | }, |
| 164 | 216 | { |
| 165 | 217 | id: "unpin-confirmation", |
| 166 | 218 | title: "Unpin confirmation", |
| 167 | 219 | to: "/settings/general", |
| 220 | + searchTerms: ["ask before thread pinned section"], | |
| 168 | 221 | }, |
| 169 | 222 | { |
| 170 | 223 | id: "archive-confirmation", |
| 171 | 224 | title: "Archive confirmation", |
| 172 | 225 | to: "/settings/general", |
| 226 | + searchTerms: ["ask before thread second click inline action"], | |
| 173 | 227 | }, |
| 174 | 228 | { |
| 175 | 229 | id: "delete-confirmation", |
| 176 | 230 | title: "Delete confirmation", |
| 177 | 231 | to: "/settings/general", |
| 232 | + searchTerms: ["ask before thread chat history"], | |
| 178 | 233 | }, |
| 179 | 234 | { |
| 180 | 235 | id: "quit-confirmation", |
| 181 | 236 | title: "Hold to quit", |
| 182 | 237 | to: "/settings/general", |
| 238 | + searchTerms: ["confirmation shortcut desktop app exit"], | |
| 183 | 239 | desktopOnly: true, |
| 184 | 240 | }, |
| 185 | 241 | { |
| 186 | 242 | id: "text-generation-model", |
| 187 | 243 | title: "Text generation model", |
| 188 | 244 | to: "/settings/general", |
| 245 | + searchTerms: ["generated thread titles source control content default provider"], | |
| 189 | 246 | }, |
| 190 | 247 | { |
| 191 | 248 | id: "diagnostics", |
| 192 | 249 | title: "Diagnostics", |
| 193 | 250 | to: "/settings/general", |
| 251 | + searchTerms: ["logs traces processes resource history failures spans cpu memory"], | |
| 194 | 252 | }, |
| 195 | 253 | { |
| 196 | 254 | id: "legacy-plan-mode", |
| 197 | 255 | title: "Plan mode (legacy)", |
| 198 | 256 | to: "/settings/general", |
| 257 | + searchTerms: ["build plan composer old"], | |
| 199 | 258 | }, |
| 200 | 259 | { |
| 201 | 260 | id: "legacy-token-streaming", |
| 202 | 261 | title: "Stream token by token (legacy)", |
| 203 | 262 | to: "/settings/general", |
| 263 | + searchTerms: ["response output old compatibility"], | |
| 204 | 264 | }, |
| 205 | 265 | { |
| 206 | 266 | id: "legacy-sidebar", |
| 207 | 267 | title: "Sidebar (legacy)", |
| 208 | 268 | to: "/settings/general", |
| 269 | + searchTerms: ["project thread tree old flat list"], | |
| 209 | 270 | }, |
| 210 | 271 | { |
| 211 | 272 | id: "keybindings", |
| 212 | 273 | title: "Keybindings", |
| 213 | 274 | to: "/settings/keybindings", |
| 275 | + searchTerms: ["keyboard shortcuts hotkeys commands bindings json"], | |
| 214 | 276 | }, |
| 215 | 277 | { |
| 216 | 278 | id: "providers", |
| 217 | 279 | title: "Providers", |
| 218 | 280 | to: "/settings/providers", |
| 281 | + searchTerms: [ | |
| 282 | + "agents cli codex claude cursor grok opencode instances authentication api key models configuration binary path config directory endpoint arguments environment variables display name accent color custom favorite hidden auto compact", | |
| 283 | + ], | |
| 284 | + }, | |
| 285 | + { | |
| 286 | + id: "provider-health-check-interval", | |
| 287 | + title: "Health check interval", | |
| 288 | + to: "/settings/providers", | |
| 289 | + searchTerms: ["refresh availability versions auth state models background probes seconds off"], | |
| 290 | + providerSettingsOnly: true, | |
| 219 | 291 | }, |
| 220 | 292 | { |
| 221 | 293 | id: "agent-browser-access", |
| 222 | 294 | title: "Agent browser access", |
| 223 | 295 | to: "/settings/integrations", |
| 224 | − targetId: "browser", | |
| 296 | + searchTerms: ["allow open drive preview tools sessions"], | |
| 225 | 297 | }, |
| 226 | 298 | { |
| 227 | 299 | id: "browser-default-viewport", |
| 228 | 300 | title: "Default browser viewport", |
| 229 | 301 | to: "/settings/integrations", |
| 230 | − targetId: "browser", | |
| 302 | + searchTerms: ["preview size width height device desktop mobile rotate"], | |
| 231 | 303 | }, |
| 232 | 304 | { |
| 233 | 305 | id: "browser-default-zoom", |
| 234 | 306 | title: "Default browser zoom", |
| 235 | 307 | to: "/settings/integrations", |
| 236 | − targetId: "browser", | |
| 308 | + searchTerms: ["preview page scale tabs percent"], | |
| 237 | 309 | }, |
| 238 | 310 | { |
| 239 | 311 | id: "browser-default-appearance", |
| 240 | 312 | title: "Default browser appearance", |
| 241 | 313 | to: "/settings/integrations", |
| 242 | − targetId: "browser", | |
| 314 | + searchTerms: ["preview color scheme light dark system os"], | |
| 243 | 315 | }, |
| 244 | 316 | { |
| 245 | 317 | id: "browser-recording-frame-rate", |
| 246 | 318 | title: "Browser recording frame rate", |
| 247 | 319 | to: "/settings/integrations", |
| 248 | − targetId: "browser", | |
| 249 | 320 | }, |
| 250 | 321 | { |
| 251 | 322 | id: "browser-auto-show-floating-preview", |
| 252 | 323 | title: "Auto-show floating preview", |
| 253 | 324 | to: "/settings/integrations", |
| 254 | − targetId: "browser", | |
| 325 | + searchTerms: ["agent opens browser pop into view hide"], | |
| 255 | 326 | }, |
| 256 | 327 | { |
| 257 | 328 | id: "source-control", |
| 258 | 329 | title: "Source control", |
| 259 | 330 | to: "/settings/source-control", |
| 331 | + searchTerms: [ | |
| 332 | + "version control git github gitlab bitbucket azure devops hosting integrations credentials scan server environment", | |
| 333 | + ], | |
| 260 | 334 | }, |
| 261 | 335 | { |
| 262 | − id: "remote-environments", | |
| 263 | − title: "Remote environments", | |
| 336 | + id: "git-fetch-interval", | |
| 337 | + title: "Git fetch interval", | |
| 338 | + to: "/settings/source-control", | |
| 339 | + searchTerms: [ | |
| 340 | + "automatic remote branch refresh background credentials security keys seconds off", | |
| 341 | + ], | |
| 342 | + primaryOnly: true, | |
| 343 | + }, | |
| 344 | + { | |
| 345 | + id: "source-control-writing-style", | |
| 346 | + title: "Source control writing style", | |
| 347 | + to: "/settings/source-control", | |
| 348 | + searchTerms: [ | |
| 349 | + "repository conventions conventional commits custom instructions change descriptions request titles", | |
| 350 | + ], | |
| 351 | + primaryOnly: true, | |
| 352 | + }, | |
| 353 | + { | |
| 354 | + id: "follow-change-request-templates", | |
| 355 | + title: "Follow change request templates", | |
| 356 | + to: "/settings/source-control", | |
| 357 | + searchTerms: ["repository pr pull request description structure"], | |
| 358 | + primaryOnly: true, | |
| 359 | + }, | |
| 360 | + { | |
| 361 | + id: "source-control-writer-model", | |
| 362 | + title: "Source control writer model", | |
| 363 | + to: "/settings/source-control", | |
| 364 | + searchTerms: [ | |
| 365 | + "override generated commit change request pr titles descriptions branch bookmark", | |
| 366 | + ], | |
| 367 | + primaryOnly: true, | |
| 368 | + }, | |
| 369 | + { | |
| 370 | + id: "network-access", | |
| 371 | + title: "Network access", | |
| 264 | 372 | to: "/settings/connections", |
| 373 | + targetId: "connections-environment", | |
| 374 | + searchTerms: ["expose backend remote pairing local machine interfaces host restart"], | |
| 375 | + localBackendManagementOnly: true, | |
| 376 | + }, | |
| 377 | + { | |
| 378 | + id: "tailscale-https", | |
| 379 | + title: "Tailscale HTTPS", | |
| 380 | + to: "/settings/connections", | |
| 381 | + targetId: "connections-environment", | |
| 382 | + searchTerms: ["serve magicdns endpoint remote secure network"], | |
| 383 | + desktopOnly: true, | |
| 384 | + localBackendManagementOnly: true, | |
| 265 | 385 | }, |
| 266 | 386 | { |
| 267 | 387 | id: "wsl-backend", |
| 268 | 388 | title: "WSL backend", |
| 269 | 389 | to: "/settings/connections", |
| 390 | + searchTerms: [ | |
| 391 | + "windows subsystem linux distro second server projects stop windows backend restart", | |
| 392 | + ], | |
| 270 | 393 | desktopOnly: true, |
| 271 | 394 | windowsOnly: true, |
| 395 | + localBackendManagementOnly: true, | |
| 396 | + wslAvailableOnly: true, | |
| 397 | + }, | |
| 398 | + { | |
| 399 | + id: "t3-connect", | |
| 400 | + title: "T3 Connect", | |
| 401 | + to: "/settings/connections", | |
| 402 | + targetId: "connections-environment", | |
| 403 | + searchTerms: ["managed tunnel cloud other devices remote"], | |
| 404 | + desktopOnly: true, | |
| 405 | + cloudOnly: true, | |
| 406 | + }, | |
| 407 | + { | |
| 408 | + id: "publish-agent-activity", | |
| 409 | + title: "Publish agent activity", | |
| 410 | + to: "/settings/connections", | |
| 411 | + targetId: "connections-environment", | |
| 412 | + searchTerms: ["mobile push notifications live activities cloud tunnel"], | |
| 413 | + cloudOnly: true, | |
| 414 | + }, | |
| 415 | + { | |
| 416 | + id: "connections-environment", | |
| 417 | + title: "This environment", | |
| 418 | + to: "/settings/connections", | |
| 419 | + searchTerms: [ | |
| 420 | + "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint", | |
| 421 | + ], | |
| 422 | + }, | |
| 423 | + { | |
| 424 | + id: "remote-environments", | |
| 425 | + title: "Remote environments", | |
| 426 | + to: "/settings/connections", | |
| 427 | + searchTerms: ["add pair backend host code ssh config agent tunnel saved t3 connect"], | |
| 272 | 428 | }, |
| 273 | 429 | { |
| 274 | 430 | id: "archive", |
| 275 | 431 | title: "Archived threads", |
| 276 | 432 | to: "/settings/archived", |
| 433 | + searchTerms: ["restore reopen deleted history projects"], | |
| 277 | 434 | }, |
| 278 | 435 | ] as const satisfies ReadonlyArray<SettingsSearchItem>; |
| 279 | 436 | |
| 280 | 437 | export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"]; |
| 281 | 438 | |
| 282 | −const SEARCH_ITEMS_BY_ID = Object.fromEntries( | |
| 283 | − SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item]), | |
| 284 | −) as Readonly<Record<SettingsSearchItemId, SettingsSearchItem>>; | |
| 439 | +const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const)); | |
| 285 | 440 | |
| 286 | 441 | /** |
| 287 | 442 | * `id` and `title` props for the element a search item anchors to. Panels |
| @@ -292,17 +447,22 @@ export function searchableSetting(id: SettingsSearchItemId): { · 4 unmodified lines | ||
| 292 | 447 | readonly id: string; |
| 293 | 448 | readonly title: string; |
| 294 | 449 | } { |
| 295 | − const { id: anchorId, title } = SEARCH_ITEMS_BY_ID[id]; | |
| 450 | + const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!; | |
| 296 | 451 | return { id: anchorId, title }; |
| 297 | 452 | } |
| 298 | 453 | |
| 299 | −function normalizeSearchText(value: string): string { | |
| 300 | − return value | |
| 301 | − .normalize("NFKD") | |
| 302 | − .replace(/[\u0300-\u036f]/g, "") | |
| 303 | − .toLocaleLowerCase() | |
| 304 | − .replace(/\s+/g, " ") | |
| 305 | − .trim(); | |
| 454 | +export function filterAvailableSettingsSearchItems( | |
| 455 | + availability: SettingsSearchAvailability, | |
| 456 | +): ReadonlyArray<SettingsSearchItem> { | |
| 457 | + const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS; | |
| 458 | + return items.filter( | |
| 459 | + (item) => | |
| 460 | + (!item.cloudOnly || availability.hasCloudPublicConfig) && | |
| 461 | + (!item.primaryOnly || availability.hasPrimaryEnvironment) && | |
| 462 | + (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) && | |
| 463 | + (!item.localBackendManagementOnly || availability.canManageLocalBackend) && | |
| 464 | + (!item.wslAvailableOnly || availability.isWslSettingsRowVisible), | |
| 465 | + ); | |
| 306 | 466 | } |
| 307 | 467 | |
| 308 | 468 | export function searchSettings( |
| @@ -311,12 +471,38 @@ export function searchSettings( · 2 unmodified lines | ||
| 311 | 471 | ): ReadonlyArray<SettingsSearchItem> { |
| 312 | 472 | const normalizedQuery = normalizeSearchText(query); |
| 313 | 473 | if (normalizedQuery.length === 0) return []; |
| 474 | + const queryTokens = normalizedQuery.split(" "); | |
| 475 | + const platform = typeof navigator === "undefined" ? "" : navigator.platform; | |
| 314 | 476 | |
| 315 | − return items.filter( | |
| 316 | − (item) => | |
| 317 | − (isElectron || item.desktopOnly !== true) && | |
| 318 | − (!item.windowsOnly || | |
| 319 | − isWindowsPlatform(typeof navigator === "undefined" ? "" : navigator.platform)) && | |
| 320 | − normalizeSearchText(item.title).includes(normalizedQuery), | |
| 321 | − ); | |
| 477 | + return items | |
| 478 | + .flatMap((item, index) => { | |
| 479 | + if (!isElectron && item.desktopOnly === true) return []; | |
| 480 | + if (item.macOnly && !isMacPlatform(platform)) return []; | |
| 481 | + if (item.windowsOnly && !isWindowsPlatform(platform)) return []; | |
| 482 | + | |
| 483 | + const title = normalizeSearchText(item.title); | |
| 484 | + const fields = [ | |
| 485 | + title, | |
| 486 | + normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]), | |
| 487 | + ...(item.searchTerms ?? []).map(normalizeSearchText), | |
| 488 | + ]; | |
| 489 | + if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return []; | |
| 490 | + | |
| 491 | + const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery)); | |
| 492 | + const rank = | |
| 493 | + title === normalizedQuery | |
| 494 | + ? 5 | |
| 495 | + : title.startsWith(normalizedQuery) | |
| 496 | + ? 4 | |
| 497 | + : title.includes(normalizedQuery) | |
| 498 | + ? 3 | |
| 499 | + : queryTokens.every((token) => title.includes(token)) | |
| 500 | + ? 2 | |
| 501 | + : exactPhraseField >= 0 | |
| 502 | + ? 1 | |
| 503 | + : 0; | |
| 504 | + return [{ item, index, rank }]; | |
| 505 | + }) | |
| 506 | + .toSorted((left, right) => right.rank - left.rank || left.index - right.index) | |
| 507 | + .map(({ item }) => item); | |
| 322 | 508 | } |
| @@ -0,0 +1,44 @@ | ||
| 1 | +import { useMemo } from "react"; | |
| 2 | +import { AuthAccessWriteScope } from "@t3tools/contracts"; | |
| 3 | + | |
| 4 | +import { hasCloudPublicConfig } from "~/cloud/publicConfig"; | |
| 5 | +import { isElectron } from "~/env"; | |
| 6 | +import { desktopWslStateAtom } from "~/state/desktopWslState"; | |
| 7 | +import { useEnvironments, usePrimaryEnvironmentId } from "~/state/environments"; | |
| 8 | +import { useEnvironmentQuery } from "~/state/query"; | |
| 9 | +import { usePrimarySessionState } from "~/environments/primary"; | |
| 10 | +import { isWslSettingsRowVisible } from "./ConnectionsSettings.logic"; | |
| 11 | +import { isProviderSettingsEnvironmentAvailable } from "./ProviderSettingsPanel.logic"; | |
| 12 | +import { filterAvailableSettingsSearchItems } from "./settingsSearch"; | |
| 13 | + | |
| 14 | +export function useAvailableSettingsSearchItems() { | |
| 15 | + const primaryEnvironmentId = usePrimaryEnvironmentId(); | |
| 16 | + const { environments } = useEnvironments(); | |
| 17 | + const primarySessionState = usePrimarySessionState(); | |
| 18 | + const desktopWsl = useEnvironmentQuery(isElectron ? desktopWslStateAtom : null); | |
| 19 | + const canManageLocalBackend = | |
| 20 | + isElectron || | |
| 21 | + ((primarySessionState.data?.authenticated && | |
| 22 | + primarySessionState.data.scopes?.includes(AuthAccessWriteScope)) ?? | |
| 23 | + false); | |
| 24 | + | |
| 25 | + return useMemo( | |
| 26 | + () => | |
| 27 | + filterAvailableSettingsSearchItems({ | |
| 28 | + hasCloudPublicConfig: hasCloudPublicConfig(), | |
| 29 | + hasPrimaryEnvironment: primaryEnvironmentId !== null, | |
| 30 | + hasProviderSettingsEnvironment: environments.some((environment) => | |
| 31 | + isProviderSettingsEnvironmentAvailable({ | |
| 32 | + connectionPhase: environment.connection.phase, | |
| 33 | + hasServerConfig: environment.serverConfig !== null, | |
| 34 | + }), | |
| 35 | + ), | |
| 36 | + canManageLocalBackend, | |
| 37 | + isWslSettingsRowVisible: isWslSettingsRowVisible({ | |
| 38 | + state: desktopWsl.data, | |
| 39 | + error: desktopWsl.error, | |
| 40 | + }), | |
| 41 | + }), | |
| 42 | + [canManageLocalBackend, desktopWsl.data, desktopWsl.error, environments, primaryEnvironmentId], | |
| 43 | + ); | |
| 44 | +} | |
| @@ -20,6 +20,10 @@ export function isLinuxPlatform(platform: string): boolean { · 19 unmodified lines | ||
| 20 | 20 | return /linux/i.test(platform); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | +export function normalizeSearchText(value: string): string { | |
| 24 | + return value.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/\s+/g, " ").trim(); | |
| 25 | +} | |
| 26 | + | |
| 23 | 27 | export function getLocalFileManagerName(platform: string): string { |
| 24 | 28 | if (isMacPlatform(platform)) { |
| 25 | 29 | return "Finder"; |
| @@ -59,10 +59,11 @@ shortcut is `mod+shift+s`, and it does not run while the terminal has focus. · 58 unmodified lines | ||
| 59 | 59 | already pinned. Its default shortcut is `mod+shift+p`, and it does not run while the terminal has |
| 60 | 60 | focus. See [Organizing threads](./thread-sidebar.md) for how pinned threads are ordered. |
| 61 | 61 | |
| 62 | −The command palette searches active thread titles, projects, branches, user messages, and final | |
| 63 | −agent responses across connected environments. Message matches show one labeled excerpt while | |
| 64 | −keeping the thread's project, branch, and machine context visible. Message search begins after two | |
| 65 | −characters and uses SQLite's ASCII case-insensitive matching. | |
| 62 | +The command palette searches settings, active thread titles, projects, branches, user messages, and | |
| 63 | +final agent responses across connected environments. A setting result opens its exact control or | |
| 64 | +section. Message matches show one labeled excerpt while keeping the thread's project, branch, and | |
| 65 | +machine context visible. Message search begins after two characters and uses SQLite's ASCII | |
| 66 | +case-insensitive matching. | |
| 66 | 67 | |
| 67 | 68 | The full command list and the current defaults are shown in **Settings** → **Keybindings**, which |
| 68 | 69 | always matches the build you are running. Use that rather than a copied list. |