Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(app): add search functionality to settings menu (#7081)

Eric Hayes17f97b2d4a85
diff --git a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
index 1fbaca8559..f902155093 100644
--- a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
+++ b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
@@ -42,7 +42,9 @@ afterEach(() => {
const groups: SettingsTabGroup[] = [
{
label: 'Account',
- items: [{ tab: 'Account', label: 'Account', icon: () => <svg /> }],
+ items: [
+ { tab: 'Account', label: 'Account', icon: () => <svg />, keywords: [] },
+ ],
},
];
diff --git a/apps/web/src/features/settings/Settings.tsx b/apps/web/src/features/settings/Settings.tsx
index 8c399188b2..dc3823575a 100644
--- a/apps/web/src/features/settings/Settings.tsx
+++ b/apps/web/src/features/settings/Settings.tsx
@@ -25,9 +25,11 @@ import { activeTabId, setActiveTabId } from '@core/signal/settingsTab';
import ArrowsIn from '@phosphor/arrows-in.svg';
import ArrowsOut from '@phosphor/arrows-out.svg';
import CaretLeftIcon from '@phosphor/caret-left.svg';
+import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
import SignOutIcon from '@phosphor/sign-out.svg';
-import { Button, cn, Layer, SideNav } from '@ui';
+import { Button, cn, Input, Layer, SideNav } from '@ui';
import {
+ createMemo,
createRenderEffect,
createSignal,
For,
@@ -37,6 +39,7 @@ import {
untrack,
} from 'solid-js';
import { SettingsTabContent } from './SettingsTabContent';
+import { filterSettingsTabGroups } from './settingsSearch';
/** Where the settings panel is mounted, which determines its header chrome. */
export type SettingsVariant = 'split' | 'fullscreen';
@@ -100,13 +103,29 @@ export function SettingsPanel(props: SettingsPanelProps) {
selectTab,
} = useSettingsState();
const splitNavigate = useSplitNavigate();
- const { groups, flatTabs } = useSettingsTabs();
+ const { searchGroups, flatTabs } = useSettingsTabs();
const logout = useLogout();
const variant = () => props.variant ?? 'split';
const activeNavigationTab = () =>
activeTabId() === 'Harness' ? 'Agents' : activeTabId();
+ const [searchQuery, setSearchQuery] = createSignal('');
+
+ const filteredGroups = createMemo(() =>
+ filterSettingsTabGroups(searchGroups(), searchQuery())
+ );
+
+ // Runtimes is a search-only row. While it is on screen, highlight that row
+ // for the Harness tab; otherwise the standing Agents row stands in for it.
+ const showsHarnessResult = () =>
+ filteredGroups().some((group) =>
+ group.items.some((item) => item.tab === 'Harness')
+ );
+ const isItemActive = (tab: SettingsTab) =>
+ activeTabId() === tab ||
+ (tab === 'Agents' && activeTabId() === 'Harness' && !showsHarnessResult());
+
// Responsive state, driven by the panel's own width (see breakpoints above).
const [panelWidth, setPanelWidth] = createSignal(Number.POSITIVE_INFINITY);
const compact = () => !isTouchDevice() && panelWidth() < COMPACT_WIDTH;
@@ -333,24 +352,44 @@ export function SettingsPanel(props: SettingsPanelProps) {
{moveToSplitButton()}
</div>
</Show>
- <For each={groups()}>
- {(group) => (
- <SideNav.Group label={group.label}>
- <For each={group.items}>
- {(item) => (
- <SideNav.Item
- icon={item.icon}
- active={activeNavigationTab() === item.tab}
- onSelect={() => handleTabChange(item.tab)}
- class="text-xs py-1.5"
- >
- {item.label}
- </SideNav.Item>
- )}
- </For>
- </SideNav.Group>
- )}
- </For>
+ <div class="relative">
+ <MagnifyingGlassIcon class="absolute left-2 top-1/2 -translate-y-1/2 size-4 text-ink-muted pointer-events-none" />
+ <Input
+ type="text"
+ placeholder="Search settings..."
+ value={searchQuery()}
+ onInput={(e) => setSearchQuery(e.currentTarget.value)}
+ size="sm"
+ class="pl-8"
+ />
+ </div>
+ <Show
+ when={filteredGroups().length > 0}
+ fallback={
+ <div class="text-xs text-ink-muted text-center py-4">
+ No settings found
+ </div>
+ }
+ >
+ <For each={filteredGroups()}>
+ {(group) => (
+ <SideNav.Group label={group.label}>
+ <For each={group.items}>
+ {(item) => (
+ <SideNav.Item
+ icon={item.icon}
+ active={isItemActive(item.tab)}
+ onSelect={() => selectRoutedTab(item.tab)}
+ class="text-xs py-1.5"
+ >
+ {item.label}
+ </SideNav.Item>
+ )}
+ </For>
+ </SideNav.Group>
+ )}
+ </For>
+ </Show>
<div class="mt-auto border-t border-edge-muted pt-2">
<button
type="button"
diff --git a/apps/web/src/features/settings/settingsSearch.test.ts b/apps/web/src/features/settings/settingsSearch.test.ts
new file mode 100644
index 0000000000..7cb80c652c
--- /dev/null
+++ b/apps/web/src/features/settings/settingsSearch.test.ts
@@ -0,0 +1,36 @@
+import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';
+import { describe, expect, it } from 'vitest';
+import { filterSettingsTabGroups } from './settingsSearch';
+
+function tabsFor(query: string) {
+ return filterSettingsTabGroups(SETTINGS_TAB_GROUPS, query).flatMap((group) =>
+ group.items.map((item) => item.tab)
+ );
+}
+
+describe('filterSettingsTabGroups', function () {
+ it('hides search-only destinations when the query is empty', function () {
+ expect(tabsFor('')).not.toContain('Harness');
+ expect(tabsFor(' ')).not.toContain('Harness');
+ expect(tabsFor('')).toContain('Agents');
+ });
+
+ it('sends cursor to runtimes instead of Macro API keys', function () {
+ const tabs = tabsFor('cursor');
+ expect(tabs).toContain('Harness');
+ expect(tabs).not.toContain('API Keys');
+ });
+
+ it('fuzzy-matches a missing letter in a keyword', function () {
+ expect(tabsFor('curso')).toContain('Harness');
+ expect(tabsFor('curso')).not.toContain('API Keys');
+ });
+
+ it('matches keywords declared on the tab', function () {
+ expect(tabsFor('hotkey')).toEqual(['Shortcuts']);
+ });
+
+ it('returns no groups when nothing matches', function () {
+ expect(tabsFor('xyz123')).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/settings/settingsSearch.ts b/apps/web/src/features/settings/settingsSearch.ts
new file mode 100644
index 0000000000..50da86e758
--- /dev/null
+++ b/apps/web/src/features/settings/settingsSearch.ts
@@ -0,0 +1,37 @@
+import type {
+ SettingsTabGroup,
+ SettingsTabItem,
+} from '@core/constant/settingsTabsConfig';
+import { fuzzyFilter } from '@core/util/fuzzy';
+
+/** Label plus keywords, lowercased for the shared uFuzzy index. */
+export function settingsTabSearchText(item: SettingsTabItem): string {
+ return [item.label, ...item.keywords].join(' ').toLowerCase();
+}
+
+/**
+ * Filters settings groups by a fuzzy query against each tab's label and
+ * keywords. An empty query returns the standing nav and hides search-only
+ * destinations such as Runtimes.
+ */
+export function filterSettingsTabGroups(
+ groups: readonly SettingsTabGroup[],
+ query: string
+): SettingsTabGroup[] {
+ const trimmed = query.trim().toLowerCase();
+ if (!trimmed) {
+ return groups
+ .map((group) => ({
+ label: group.label,
+ items: group.items.filter((item) => !item.searchOnly),
+ }))
+ .filter((group) => group.items.length > 0);
+ }
+
+ return groups
+ .map((group) => ({
+ label: group.label,
+ items: fuzzyFilter(trimmed, group.items, settingsTabSearchText),
+ }))
+ .filter((group) => group.items.length > 0);
+}
diff --git a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
index 2d19b1af6e..0d6adcb728 100644
--- a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
+++ b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
@@ -5,6 +5,7 @@ import BuildingsIcon from '@phosphor/buildings.svg';
import CpuIcon from '@phosphor/cpu.svg';
import CreditCardIcon from '@phosphor/credit-card.svg';
import DeviceMobileIcon from '@phosphor/device-mobile-speaker.svg';
+import HardDrivesIcon from '@phosphor/hard-drives.svg';
import KeyIcon from '@phosphor/key.svg';
import KeyboardIcon from '@phosphor/keyboard.svg';
import PlugIcon from '@phosphor/plug.svg';
@@ -34,6 +35,13 @@ export type SettingsTabItem = {
tab: SettingsTab;
label: string;
icon: Component<{ class?: string; triggerAnimation?: boolean }>;
+ /**
+ * Extra search terms for this tab. The label is always searched too.
+ * Required on every nav item so the terms stay next to the tab they find.
+ */
+ keywords: readonly string[];
+ /** Findable from search, but not a standing row in the settings nav. */
+ searchOnly?: boolean;
};
export type SettingsTabGroup = {
@@ -48,39 +56,114 @@ export type SettingsTabGroup = {
* order (see `flatTabs` in {@link useSettingsTabs}).
*
* Presentation-free and hook-free: gating lives in {@link useSettingsTabAvailable}.
+ * Search keywords live on each item so the nav and the settings search share
+ * one definition.
*/
export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
{
label: 'General',
items: [
- { tab: 'Account', label: 'Account', icon: UserIconPhosphor },
- { tab: 'API Keys', label: 'API Keys', icon: KeyIcon },
- { tab: 'Notifications', label: 'Notifications', icon: BellIcon },
- { tab: 'Billing', label: 'Billing', icon: CreditCardIcon },
- { tab: 'Appearance', label: 'Appearance', icon: SwatchesIcon },
- { tab: 'Agents', label: 'Agents', icon: AgentIcon },
- { tab: 'Mobile App', label: 'Mobile App', icon: DeviceMobileIcon },
- { tab: 'Shortcuts', label: 'Shortcuts', icon: KeyboardIcon },
+ {
+ tab: 'Account',
+ label: 'Account',
+ icon: UserIconPhosphor,
+ keywords: ['profile', 'user', 'email', 'name'],
+ },
+ {
+ tab: 'API Keys',
+ label: 'API Keys',
+ icon: KeyIcon,
+ keywords: ['api', 'key', 'token', 'authentication'],
+ },
+ {
+ tab: 'Notifications',
+ label: 'Notifications',
+ icon: BellIcon,
+ keywords: ['alerts', 'email', 'sound'],
+ },
+ {
+ tab: 'Billing',
+ label: 'Billing',
+ icon: CreditCardIcon,
+ keywords: ['payment', 'subscription', 'invoice', 'plan'],
+ },
+ {
+ tab: 'Appearance',
+ label: 'Appearance',
+ icon: SwatchesIcon,
+ keywords: ['theme', 'dark', 'light', 'color'],
+ },
+ {
+ tab: 'Agents',
+ label: 'Agents',
+ icon: AgentIcon,
+ keywords: ['ai', 'assistant', 'bot'],
+ },
+ {
+ tab: 'Harness',
+ label: 'Runtimes',
+ icon: HardDrivesIcon,
+ keywords: ['cursor', 'harness', 'runtime', 'credential', 'api key'],
+ searchOnly: true,
+ },
+ {
+ tab: 'Mobile App',
+ label: 'Mobile App',
+ icon: DeviceMobileIcon,
+ keywords: ['phone', 'ios', 'android'],
+ },
+ {
+ tab: 'Shortcuts',
+ label: 'Shortcuts',
+ icon: KeyboardIcon,
+ keywords: ['keyboard', 'hotkey', 'keybinding'],
+ },
],
},
{
label: 'Workspace',
items: [
- { tab: 'Team', label: 'Team', icon: UsersThreeIcon },
- { tab: 'Tags', label: 'Tags', icon: TagIcon },
- { tab: 'CRM', label: 'CRM', icon: BuildingsIcon },
+ {
+ tab: 'Team',
+ label: 'Team',
+ icon: UsersThreeIcon,
+ keywords: ['members', 'users', 'workspace'],
+ },
+ {
+ tab: 'Tags',
+ label: 'Tags',
+ icon: TagIcon,
+ keywords: ['label', 'category'],
+ },
+ {
+ tab: 'CRM',
+ label: 'CRM',
+ icon: BuildingsIcon,
+ keywords: ['contacts', 'customers', 'deals'],
+ },
{
tab: 'Connected',
label: 'Integrations',
icon: CpuIcon,
+ keywords: ['integrations', 'apps', 'connections'],
+ },
+ {
+ tab: 'Agent',
+ label: 'MCP server',
+ icon: PlugIcon,
+ keywords: ['mcp', 'server', 'protocol'],
+ },
+ {
+ tab: 'Bots',
+ label: 'Bots',
+ icon: BotIcon,
+ keywords: ['automation', 'bot'],
},
- { tab: 'Agent', label: 'MCP server', icon: PlugIcon },
- { tab: 'Bots', label: 'Bots', icon: BotIcon },
],
},
{
label: 'Admin',
- items: [{ tab: 'Admin', label: 'Debug', icon: BugIcon }],
+ items: [{ tab: 'Admin', label: 'Debug', icon: BugIcon, keywords: [] }],
},
];
@@ -202,16 +285,25 @@ export const useSettingsTabAvailable = () => {
export const useSettingsTabs = () => {
const isAvailable = useSettingsTabAvailable();
- const groups = createMemo<SettingsTabGroup[]>(() =>
+ const searchGroups = createMemo<SettingsTabGroup[]>(() =>
SETTINGS_TAB_GROUPS.map((group) => ({
label: group.label,
items: group.items.filter((item) => isAvailable(item.tab)),
})).filter((group) => group.items.length > 0)
);
+ const groups = createMemo<SettingsTabGroup[]>(() =>
+ searchGroups()
+ .map((group) => ({
+ ...group,
+ items: group.items.filter((item) => !item.searchOnly),
+ }))
+ .filter((group) => group.items.length > 0)
+ );
+
const flatTabs = createMemo<SettingsTabItem[]>(() =>
groups().flatMap((group) => group.items)
);
- return { groups, flatTabs, isAvailable };
+ return { groups, searchGroups, flatTabs, isAvailable };
};