Skip to content

The agent that grows with you

feat(desktop): drop the Tools & Keys in-page search — ⌘K already finds credentials (#89192)

brooklyn!2d579af86991
diff --git a/apps/desktop/src/app/settings/keys-settings.test.tsx b/apps/desktop/src/app/settings/keys-settings.test.tsx
index e806eb382af..483be4eb33b 100644
--- a/apps/desktop/src/app/settings/keys-settings.test.tsx
+++ b/apps/desktop/src/app/settings/keys-settings.test.tsx
@@ -71,50 +71,28 @@ function DeepLinkButton({ target }: { target: string }) {
)
}
-describe('KeysSettings scoped command search', () => {
- it('curates tool results by label, description, env key, URL, and tool name', async () => {
+describe('KeysSettings', () => {
+ it('lists tools and excludes settings / channel-managed credentials', async () => {
getEnvVars.mockResolvedValue({
- BRAVE_SEARCH_API_KEY: envVar('tool', {
- description: 'Search the web with Brave.',
- url: 'https://brave.com/search/api/'
- }),
- FIRECRAWL_API_KEY: envVar('tool', {
- description: 'Crawl and extract websites.',
- tools: ['browser_navigate']
- }),
- GATEWAY_PROXY: envVar('setting', { description: 'Gateway reverse proxy.' })
+ BRAVE_SEARCH_API_KEY: envVar('tool', { description: 'Search the web with Brave.' }),
+ FIRECRAWL_API_KEY: envVar('tool', { description: 'Crawl and extract websites.' }),
+ GATEWAY_PROXY: envVar('setting', { description: 'Gateway reverse proxy.' }),
+ TELEGRAM_BOT_TOKEN: envVar('messaging', {
+ channel_managed: true,
+ description: 'Telegram bot token.'
+ })
})
await renderKeysSettings('tools')
- const search = await screen.findByRole('combobox', { name: 'Search tools…' })
expect(screen.getByText('BRAVE SEARCH')).toBeTruthy()
expect(screen.getByText('FIRECRAWL')).toBeTruthy()
expect(screen.queryByText('GATEWAY PROXY')).toBeNull()
- expect(screen.queryByRole('option')).toBeNull()
- expect(search.getAttribute('aria-expanded')).toBe('false')
-
- fireEvent.change(search, { target: { value: 'crawl and extract' } })
- const firecrawlResult = await screen.findByRole('option', { name: /FIRECRAWL/ })
- expect(firecrawlResult.getAttribute('data-selected')).toBe('true')
- expect(screen.queryByRole('option', { name: /BRAVE SEARCH/ })).toBeNull()
-
- fireEvent.change(search, { target: { value: 'brave_search_api' } })
- expect(await screen.findByRole('option', { name: /BRAVE SEARCH/ })).toBeTruthy()
- expect(screen.queryByRole('option', { name: /FIRECRAWL/ })).toBeNull()
-
- fireEvent.change(search, { target: { value: 'brave.com' } })
- expect(await screen.findByRole('option', { name: /BRAVE SEARCH/ })).toBeTruthy()
-
- fireEvent.change(search, { target: { value: 'browser_navigate' } })
- expect(await screen.findByRole('option', { name: /FIRECRAWL/ })).toBeTruthy()
- expect(screen.queryByRole('option', { name: /BRAVE SEARCH/ })).toBeNull()
-
- fireEvent.change(search, { target: { value: 'does-not-exist' } })
- expect(await screen.findByText('No entries match your search.')).toBeTruthy()
+ expect(screen.queryByText('TELEGRAM BOT')).toBeNull()
+ expect(screen.queryByRole('combobox')).toBeNull()
})
- it('scopes settings results and excludes channel-managed credentials', async () => {
+ it('lists settings rows and excludes tools / channel-managed credentials', async () => {
getEnvVars.mockResolvedValue({
API_SERVER_TOKEN: envVar('setting', { description: 'Protect the local API server.' }),
GATEWAY_PROXY: envVar('messaging', { description: 'Gateway reverse proxy address.' }),
@@ -127,100 +105,34 @@ describe('KeysSettings scoped command search', () => {
await renderKeysSettings('settings')
- const search = await screen.findByRole('combobox', { name: 'Search settings…' })
expect(screen.getByText('API SERVER')).toBeTruthy()
expect(screen.getByText('GATEWAY PROXY')).toBeTruthy()
expect(screen.queryByText('TELEGRAM BOT')).toBeNull()
expect(screen.queryByText('BRAVE SEARCH')).toBeNull()
-
- fireEvent.change(search, { target: { value: 'reverse proxy' } })
- expect(await screen.findByRole('option', { name: /GATEWAY PROXY/ })).toBeTruthy()
- expect(screen.queryByRole('option', { name: /API SERVER/ })).toBeNull()
})
- it('selects a command result, then expands and highlights its credential card', async () => {
- getEnvVars.mockResolvedValue({
- BRAVE_SEARCH_API_KEY: envVar('tool', { description: 'Search the web with Brave.' }),
- FIRECRAWL_API_KEY: envVar('tool', {
- description: 'Crawl and extract websites.',
- tools: ['browser_navigate']
- })
- })
-
- await renderKeysSettings('tools', '/settings?tab=keys&kview=tools')
-
- const search = await screen.findByRole('combobox', { name: 'Search tools…' })
- fireEvent.change(search, { target: { value: 'browser_navigate' } })
- await screen.findByRole('option', { name: /FIRECRAWL/ })
- fireEvent.keyDown(search, { key: 'Enter' })
-
- await waitFor(() => expect((search as HTMLInputElement).value).toBe(''))
- await waitFor(() => {
- const target = globalThis.document.getElementById('credential-key-FIRECRAWL_API_KEY')
- expect(target?.classList).toContain('setting-field-highlight')
- })
- expect(screen.getByText('Crawl and extract websites.')).toBeTruthy()
- })
-
- it('dismisses outside and reopens on focus while Escape clears the query', async () => {
- getEnvVars.mockResolvedValue({
- BRAVE_SEARCH_API_KEY: envVar('tool', { description: 'Search the web with Brave.' })
- })
-
- await renderKeysSettings('tools')
-
- const search = await screen.findByRole('combobox', { name: 'Search tools…' })
- fireEvent.change(search, { target: { value: 'brave' } })
- expect(await screen.findByRole('option', { name: /BRAVE SEARCH/ })).toBeTruthy()
- expect(search.getAttribute('aria-expanded')).toBe('true')
-
- fireEvent.pointerDown(globalThis.document.body)
- await waitFor(() => expect(search.getAttribute('aria-expanded')).toBe('false'))
- expect((search as HTMLInputElement).value).toBe('brave')
-
- fireEvent.focus(search)
- await waitFor(() => expect(search.getAttribute('aria-expanded')).toBe('true'))
- fireEvent.keyDown(search, { key: 'Escape' })
- expect((search as HTMLInputElement).value).toBe('')
- expect(search.getAttribute('aria-expanded')).toBe('false')
- })
-
- it('clears the scoped query when a deep link opens a key in the active view', async () => {
+ it('expands and highlights a deep-linked credential card', async () => {
getEnvVars.mockResolvedValue({
BRAVE_SEARCH_API_KEY: envVar('tool', { description: 'Search the web with Brave.' }),
FIRECRAWL_API_KEY: envVar('tool', { description: 'Crawl and extract websites.' })
})
+
const { KeysSettings } = await import('./keys-settings')
render(
<MemoryRouter initialEntries={['/settings?tab=keys']}>
<KeysSettings view="tools" />
- <DeepLinkButton target="BRAVE_SEARCH_API_KEY" />
+ <DeepLinkButton target="FIRECRAWL_API_KEY" />
</MemoryRouter>
)
- const search = await screen.findByRole('combobox', { name: 'Search tools…' })
- fireEvent.change(search, { target: { value: 'firecrawl' } })
- expect(await screen.findByRole('option', { name: /FIRECRAWL/ })).toBeTruthy()
-
+ expect(await screen.findByText('BRAVE SEARCH')).toBeTruthy()
fireEvent.click(screen.getByRole('button', { name: 'Open key' }))
- await waitFor(() => expect((search as HTMLInputElement).value).toBe(''))
- expect(await screen.findByText('Search the web with Brave.')).toBeTruthy()
- })
-
- it('does not clear a query for a deep link owned by the other sub-view', async () => {
- getEnvVars.mockResolvedValue({
- BRAVE_SEARCH_API_KEY: envVar('tool', { description: 'Search the web with Brave.' }),
- GATEWAY_PROXY: envVar('setting', { description: 'Gateway reverse proxy address.' })
+ await waitFor(() => {
+ const target = globalThis.document.getElementById('credential-key-FIRECRAWL_API_KEY')
+ expect(target?.classList).toContain('setting-field-highlight')
})
-
- await renderKeysSettings('settings', '/settings?tab=keys&kview=settings&key=BRAVE_SEARCH_API_KEY')
-
- const search = await screen.findByRole('combobox', { name: 'Search settings…' })
- fireEvent.change(search, { target: { value: 'reverse proxy' } })
-
- expect((search as HTMLInputElement).value).toBe('reverse proxy')
- expect(await screen.findByRole('option', { name: /GATEWAY PROXY/ })).toBeTruthy()
+ expect(screen.getByText('Crawl and extract websites.')).toBeTruthy()
})
})
diff --git a/apps/desktop/src/app/settings/keys-settings.tsx b/apps/desktop/src/app/settings/keys-settings.tsx
index d92dba33aab..aeb24b49be5 100644
--- a/apps/desktop/src/app/settings/keys-settings.tsx
+++ b/apps/desktop/src/app/settings/keys-settings.tsx
@@ -1,8 +1,6 @@
import { useStore } from '@nanostores/react'
import { useCallback, useEffect, useMemo, useState } from 'react'
-import { useSearchParams } from 'react-router'
-import { ScopedCommandSearch, type ScopedCommandSearchItem } from '@/components/ui/scoped-command-search'
import { useI18n } from '@/i18n'
import { $settingsScopeOverride } from '@/store/settings-scope'
@@ -40,13 +38,10 @@ export function KeysSettings({ view }: KeysSettingsProps) {
// env store instead of the active one (null → active, the default path).
const scopeProfile = useStore($settingsScopeOverride)
const { rowProps, vars } = useEnvCredentials(scopeProfile)
- const [, setSearchParams] = useSearchParams()
const [openKey, setOpenKey] = useState<null | string>(null)
- const [query, setQuery] = useState('')
useEffect(() => {
setOpenKey(null)
- setQuery('')
}, [scopeProfile, view])
const entries = useMemo(() => {
@@ -61,51 +56,18 @@ export function KeysSettings({ view }: KeysSettingsProps) {
.sort(([a], [b]) => a.localeCompare(b))
}, [vars, view])
- const searchItems = useMemo<ScopedCommandSearchItem[]>(
- () =>
- entries.map(([key, info]) => ({
- description: info.description?.trim() || key,
- id: key,
- keywords: [
- key,
- asText(info.description),
- asText(info.url),
- ...(Array.isArray(info.tools) ? info.tools.map(asText) : [])
- ].filter(Boolean),
- label: credentialRowLabel(key, info)
- })),
- [entries]
- )
-
const renderableKeys = useMemo(() => new Set(entries.map(([key]) => key)), [entries])
const resolveDeepLink = useCallback((key: string) => {
- setQuery('')
setOpenKey(key)
}, [])
const deepLinkReady = useCallback((key: string) => renderableKeys.has(key), [renderableKeys])
- const selectSearchResult = useCallback(
- (item: ScopedCommandSearchItem) => {
- setQuery('')
- setSearchParams(
- previous => {
- const next = new URLSearchParams(previous)
- next.set('key', item.id)
-
- return next
- },
- { replace: true }
- )
- },
- [setSearchParams]
- )
-
- // Deep link from Capabilities env-var rows (?tab=keys&key=<ENV_KEY>): scroll
- // the credential card into view, flash it, and expand it. Only consume keys
- // rendered by this sub-view so a stale Tools/Settings pairing cannot keep
- // clearing the user's search while the target remains impossible to mount.
+ // Deep link from ⌘K / Capabilities env-var rows (?tab=keys&key=<ENV_KEY>):
+ // scroll the credential card into view, flash it, and expand it. Only
+ // consume keys rendered by this sub-view so a stale Tools/Settings pairing
+ // cannot keep trying to mount a target this pane never shows.
useDeepLinkHighlight({
elementId: credentialElementId,
onResolve: resolveDeepLink,
@@ -114,48 +76,33 @@ export function KeysSettings({ view }: KeysSettingsProps) {
})
if (!vars) {
- return <SettingsSkeleton search sections={[{ rows: 5 }]} />
+ return <SettingsSkeleton sections={[{ rows: 5 }]} />
}
- const searchLabel = view === 'tools' ? t.settings.keys.searchTools : t.settings.keys.searchSettings
-
return (
<SettingsContent>
<SettingsProfileScope className="mb-5" />
{entries.length > 0 ? (
- <>
- <div className="pb-3">
- <ScopedCommandSearch
- emptyMessage={t.settings.keys.noMatch}
- items={searchItems}
- onSelect={selectSearchResult}
- onValueChange={setQuery}
- placeholder={searchLabel}
- value={query}
- />
- </div>
-
- <div className="grid gap-2">
- {entries.map(([key, info]) => {
- const label = credentialRowLabel(key, info)
-
- return (
- <div className="scroll-mt-6 rounded-[6px]" id={`credential-key-${key}`} key={key}>
- <CredentialKeyCard
- expanded={openKey === key}
- info={info}
- label={label}
- onExpand={() => setOpenKey(key)}
- onToggle={() => setOpenKey(prev => (prev === key ? null : key))}
- placeholder={credentialPlaceholder(key, info, label)}
- rowProps={rowProps}
- varKey={key}
- />
- </div>
- )
- })}
- </div>
- </>
+ <div className="grid gap-2">
+ {entries.map(([key, info]) => {
+ const label = credentialRowLabel(key, info)
+
+ return (
+ <div className="scroll-mt-6 rounded-[6px]" id={credentialElementId(key)} key={key}>
+ <CredentialKeyCard
+ expanded={openKey === key}
+ info={info}
+ label={label}
+ onExpand={() => setOpenKey(key)}
+ onToggle={() => setOpenKey(prev => (prev === key ? null : key))}
+ placeholder={credentialPlaceholder(key, info, label)}
+ rowProps={rowProps}
+ varKey={key}
+ />
+ </div>
+ )
+ })}
+ </div>
) : (
<div className="rounded-lg border border-dashed border-(--ui-stroke-tertiary) px-4 py-8 text-center text-[length:var(--conversation-caption-font-size)] text-muted-foreground">
{t.settings.keys.empty}
diff --git a/apps/desktop/src/components/ui/scoped-command-search.tsx b/apps/desktop/src/components/ui/scoped-command-search.tsx
deleted file mode 100644
index a1ebd69076a..00000000000
--- a/apps/desktop/src/components/ui/scoped-command-search.tsx
+++ /dev/null
@@ -1,156 +0,0 @@
-import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react'
-
-import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command'
-import { ChevronRight } from '@/lib/icons'
-
-export interface ScopedCommandSearchItem {
- description?: string
- id: string
- keywords?: string[]
- label: string
-}
-
-/**
- * Embeddable cmdk search whose caller owns the catalog and destination.
- * Passing only the current pane's items keeps results scoped without teaching
- * this component about settings, credentials, or routes.
- */
-export function ScopedCommandSearch<T extends ScopedCommandSearchItem>({
- busy = false,
- emptyMessage,
- items,
- itemClassName = 'grid-cols-[minmax(0,1fr)_auto]',
- listClassName = 'max-h-64',
- listHeader,
- onSelect,
- onValueChange,
- placeholder,
- popoverClassName = 'inset-x-0',
- renderItem,
- resultSummary,
- shouldFilter = true,
- value
-}: ScopedCommandSearchProps<T>) {
- const inputRef = useRef<HTMLInputElement>(null)
- const rootRef = useRef<HTMLDivElement>(null)
- const [dismissed, setDismissed] = useState(false)
- const open = Boolean(value.trim()) && !dismissed
-
- useLayoutEffect(() => {
- inputRef.current?.setAttribute('aria-expanded', String(open))
- }, [open])
-
- useEffect(() => {
- if (!open) {
- return
- }
-
- const dismissOutside = (event: PointerEvent) => {
- if (!rootRef.current?.contains(event.target as Node)) {
- setDismissed(true)
- }
- }
-
- globalThis.document.addEventListener('pointerdown', dismissOutside)
-
- return () => globalThis.document.removeEventListener('pointerdown', dismissOutside)
- }, [open])
-
- const updateValue = (next: string) => {
- setDismissed(false)
- onValueChange(next)
- }
-
- return (
- <Command
- className="relative h-auto overflow-visible rounded-none bg-transparent"
- label={placeholder}
- loop
- ref={rootRef}
- shouldFilter={shouldFilter}
- >
- <CommandInput
- aria-expanded={open}
- aria-label={placeholder}
- className="text-xs"
- onBlur={() => {
- globalThis.requestAnimationFrame(() => {
- if (!rootRef.current?.contains(globalThis.document.activeElement)) {
- setDismissed(true)
- }
- })
- }}
- onFocus={() => setDismissed(false)}
- onKeyDown={event => {
- if (event.key === 'Escape' && open) {
- event.preventDefault()
- event.stopPropagation()
- updateValue('')
- }
- }}
- onValueChange={updateValue}
- placeholder={placeholder}
- ref={inputRef}
- value={value}
- />
-
- <div
- className={`absolute top-full z-30 mt-1 rounded-[6px] border border-border bg-popover shadow-nous ${popoverClassName}`}
- hidden={!open}
- >
- {resultSummary && (
- <p aria-live="polite" className="sr-only" role="status">
- {resultSummary}
- </p>
- )}
- {listHeader}
- <CommandList aria-busy={busy} className={`dt-portal-scrollbar p-1 ${listClassName}`}>
- {emptyMessage && <CommandEmpty>{emptyMessage}</CommandEmpty>}
- <CommandGroup className="p-0">
- {open &&
- items.map(item => (
- <CommandItem
- className={`group grid gap-3 px-3 py-2.5 ${itemClassName}`}
- key={item.id}
- keywords={item.keywords}
- onSelect={() => onSelect(item)}
- value={`${item.label}\u0001${item.id}`}
- >
- {renderItem ? (
- renderItem(item)
- ) : (
- <>
- <span className="min-w-0">
- <span className="block truncate font-medium">{item.label}</span>
- <span className="mt-0.5 block truncate text-xs text-muted-foreground">
- {item.description || item.id}
- </span>
- </span>
- <ChevronRight className="size-4 self-center text-muted-foreground opacity-0 transition-opacity group-data-[selected=true]:opacity-100" />
- </>
- )}
- </CommandItem>
- ))}
- </CommandGroup>
- </CommandList>
- </div>
- </Command>
- )
-}
-
-interface ScopedCommandSearchProps<T extends ScopedCommandSearchItem> {
- busy?: boolean
- emptyMessage: ReactNode
- itemClassName?: string
- items: T[]
- listClassName?: string
- listHeader?: ReactNode
- onSelect: (item: T) => void
- onValueChange: (value: string) => void
- placeholder: string
- popoverClassName?: string
- renderItem?: (item: T) => ReactNode
- resultSummary?: string
- shouldFilter?: boolean
- value: string
-}
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index e09354fff8a..5b9c56a8c19 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -866,10 +866,7 @@ export const en: Translations = {
keys: {
loading: 'Loading API keys and credentials...',
failedLoad: 'API keys failed to load',
- empty: 'Nothing configured in this category yet.',
- searchTools: 'Search tools…',
- searchSettings: 'Search settings…',
- noMatch: 'No entries match your search.'
+ empty: 'Nothing configured in this category yet.'
},
search: {
placeholder: 'Search all settings…',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index de0138fc4d5..0d55b750677 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -852,10 +852,7 @@ export const ja = defineLocale({
keys: {
loading: 'API キーと認証情報を読み込み中...',
failedLoad: 'API キーの読み込みに失敗しました',
- empty: 'このカテゴリーにはまだ設定がありません。',
- searchTools: 'ツールを検索...',
- searchSettings: '設定を検索...',
- noMatch: '検索に一致する項目はありません。'
+ empty: 'このカテゴリーにはまだ設定がありません。'
},
search: {
placeholder: 'すべての設定を検索...',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 212319a4aea..678e0f88e7c 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -737,9 +737,6 @@ export interface Translations {
loading: string
failedLoad: string
empty: string
- searchTools: string
- searchSettings: string
- noMatch: string
}
search: {
placeholder: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 5c8b8787a35..490fc298418 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -827,10 +827,7 @@ export const zhHant = defineLocale({
keys: {
loading: '正在載入 API 金鑰和憑證...',
failedLoad: 'API 金鑰載入失敗',
- empty: '此類別尚未有任何設定。',
- searchTools: '搜尋工具...',
- searchSettings: '搜尋設定...',
- noMatch: '沒有符合搜尋條件的項目。'
+ empty: '此類別尚未有任何設定。'
},
search: {
placeholder: '搜尋所有設定...',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index f51b2d681e1..dd3b63af90c 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -1064,10 +1064,7 @@ export const zh: Translations = {
keys: {
loading: '正在加载 API 密钥和凭据...',
failedLoad: 'API 密钥加载失败',
- empty: '此类别暂时没有配置项。',
- searchTools: '搜索工具...',
- searchSettings: '搜索设置...',
- noMatch: '没有与搜索匹配的条目。'
+ empty: '此类别暂时没有配置项。'
},
search: {
placeholder: '搜索所有设置...',