The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): correct search panel placeholder text
Steven Enamakel55c7f5e139a4
diff --git a/app/src/components/settings/panels/SearchPanel.tsx b/app/src/components/settings/panels/SearchPanel.tsxindex 6b278e8a48..99bbddd033 100644--- a/app/src/components/settings/panels/SearchPanel.tsx+++ b/app/src/components/settings/panels/SearchPanel.tsx@@ -1,4 +1,5 @@-import { useEffect, useRef, useState } from 'react';+import { ChevronDownIcon } from 'lucide-react';+import { useEffect, useId, useState } from 'react';import { useT } from '../../../lib/i18n/I18nContext';import { useCoreState } from '../../../providers/CoreStateProvider';@@ -6,21 +7,21 @@ import { isLocalSessionToken } from '../../../utils/localSession';import {openhumanGetSearchSettings,openhumanUpdateSearchSettings,- type SearchEngineId,+ type SearchProviderUpdate,type SearchSettings,type SearchSettingsUpdate,} from '../../../utils/tauriCommands/config';import PanelPage from '../../layout/PanelPage';import { Alert, AlertDescription } from '../../ui/Alert';-import Button from '../../ui/Button';+import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger } from '../../ui/Collapsible';import { CenteredLoadingState } from '../../ui/LoadingState';import StatusLine from '../../ui/StatusLine';-import TextArea from '../../ui/TextArea';-import { ToggleGroupItem, ToggleGroupRoot } from '../../ui/ToggleGroup';+import Switch from '../../ui/Switch';import SettingsBackButton from '../components/SettingsBackButton';import { useSettingsNavigation } from '../hooks/useSettingsNavigation';-import SearchPanelEngineList, { type EngineOption } from './SearchPanelEngineList';-import KeyEditor from './SearchPanelKeyEditor';+import SearchPanelAllowedSites from './SearchPanelAllowedSites';+import SearchPanelProviderCard from './SearchPanelProviderCard';+import SearchPanelRoles from './SearchPanelRoles';type Status =| { kind: 'idle' }@@ -29,118 +30,27 @@ type Status =| { kind: 'saved' }| { kind: 'error'; message: string };-/**- * Tri-state web-access mode for the unified fetch + browser allowlist.- * - `all` → `allow_all: true` (the `"*"` wildcard)- * - `custom` → `allow_all: false` + an explicit host list (textarea)- * - `block` → `allow_all: false` + an empty host list (no web access)- *- * `block` and an empty `custom` are indistinguishable once persisted (both are- * `allow_all: false` + `[]`); the distinction only matters locally while- * editing.- */-type AccessMode = 'all' | 'custom' | 'block';--/** Search engines that route directly from this machine with the user's own key. */-type ByokEngine = 'parallel' | 'brave' | 'querit' | 'exa' | 'tavily';--/** Patch field that carries each BYOK engine's key. Empty string clears it. */-const BYOK_KEY_FIELD: Record<ByokEngine, keyof SearchSettingsUpdate> = {- parallel: 'parallel_api_key',- brave: 'brave_api_key',- querit: 'querit_api_key',- exa: 'exa_api_key',- tavily: 'tavily_api_key',-};+const errorMessage = (err: unknown) => (err instanceof Error ? err.message : String(err));/**- * Normalize a user-entered allowed-site entry down to a bare host so it- * matches `url_guard`'s host-based comparison. Strips a leading scheme and any- * path/query/fragment — e.g. `https://reuters.com/markets` → `reuters.com` —- * and trims surrounding whitespace. The `*` allow-all wildcard is preserved.+ * Web search settings. Everything is rendered from the core's+ * `config_get_search_settings` response: the global switch, one card per+ * provider, the per-role provider order, the allowed-websites list and the+ * advanced tool-presentation toggle. Every update returns the full settings+ * object, which replaces local state, so the view never guesses what the core+ * decided (for example which provider now serves a role).*/-const normalizeAllowedHost = (raw: string): string =>- raw- .trim()- .replace(/^[a-z][a-z0-9+.-]*:\/\//i, '')- .replace(/\/.*$/, '')- .trim();-const SearchPanel = ({ embedded = false }: { embedded?: boolean }) => {const { t } = useT();const { navigateBack } = useSettingsNavigation();const { snapshot } = useCoreState();const isLocalSession = isLocalSessionToken(snapshot.sessionToken);+ const enabledId = useId();+ const presentationId = useId();const [settings, setSettings] = useState<SearchSettings | null>(null);const [status, setStatus] = useState<Status>({ kind: 'loading' });- const [parallelKey, setParallelKey] = useState<string>('');- const [braveKey, setBraveKey] = useState<string>('');- const [queritKey, setQueritKey] = useState<string>('');- const [exaKey, setExaKey] = useState<string>('');- const [tavilyKey, setTavilyKey] = useState<string>('');- const [showParallel, setShowParallel] = useState(false);- const [showBrave, setShowBrave] = useState(false);- const [showQuerit, setShowQuerit] = useState(false);- const [showExa, setShowExa] = useState(false);- const [showTavily, setShowTavily] = useState(false);- // Editor text for the allowed-websites host list (one host per line). The- // "*" wildcard is represented by the access mode, not shown here.- const [allowedText, setAllowedText] = useState<string>('');- // Tri-state web-access mode for the unified fetch + browser allowlist.- const [mode, setMode] = useState<AccessMode>('all');- // Sync editor + mode from settings exactly once, so a later settings refresh- // (e.g. after saving an engine change) can't clobber the user's in-progress- // host edits or chosen mode.- const initializedRef = useRef(false);-- const ENGINES: EngineOption[] = [- {- id: 'disabled',- label: t('settings.search.engineDisabledLabel'),- description: t('settings.search.engineDisabledDesc'),- requiresKey: false,- },- {- id: 'managed',- label: t('settings.search.engineManagedLabel'),- description: t('settings.search.engineManagedDesc'),- requiresKey: false,- },- {- id: 'parallel',- label: t('settings.search.engineParallelLabel'),- description: t('settings.search.engineParallelDesc'),- requiresKey: true,- },- {- id: 'brave',- label: t('settings.search.engineBraveLabel'),- description: t('settings.search.engineBraveDesc'),- requiresKey: true,- },- {- id: 'querit',- label: t('settings.search.engineQueritLabel'),- description: t('settings.search.engineQueritDesc'),- requiresKey: true,- },- {- id: 'exa',- label: t('settings.search.engineExaLabel'),- description: t('settings.search.engineExaDesc'),- requiresKey: true,- },- {- id: 'tavily',- label: t('settings.search.engineTavilyLabel'),- description: t('settings.search.engineTavilyDesc'),- requiresKey: true,- },- ];- const visibleEngines = isLocalSession- ? ENGINES.filter(engine => engine.id !== 'managed')- : ENGINES;+ const saving = status.kind === 'saving';useEffect(() => {let cancelled = false;@@ -152,106 +62,32 @@ const SearchPanel = ({ embedded = false }: { embedded?: boolean }) => {}).catch(err => {if (cancelled) return;- setStatus({ kind: 'error', message: err instanceof Error ? err.message : String(err) });+ setStatus({ kind: 'error', message: errorMessage(err) });});return () => {cancelled = true;};}, []);- // Reflect the loaded allowlist into the editor + mode, exactly once.- useEffect(() => {- if (!settings || initializedRef.current) return;- initializedRef.current = true;- const explicit = settings.allowed_domains.filter(d => d !== '*');- setAllowedText(explicit.join('\n'));- setMode(settings.allow_all ? 'all' : explicit.length > 0 ? 'custom' : 'block');- }, [settings]);-- const selectedEngine = (settings?.engine as SearchEngineId | undefined) ?? 'managed';-- const persistEngine = async (next: SearchEngineId) => {- if (!settings || status.kind === 'saving') return;- const previous = settings;- setSettings({ ...settings, engine: next });+ /** Send a patch; on success the returned settings replace local state. */+ const persist = async (update: SearchSettingsUpdate): Promise<boolean> => {+ if (!settings || saving) return false;setStatus({ kind: 'saving' });try {- await openhumanUpdateSearchSettings({ engine: next });- const refreshed = await openhumanGetSearchSettings();- setSettings(refreshed.result);+ const res = await openhumanUpdateSearchSettings(update);+ if (res?.result) setSettings(res.result);setStatus({ kind: 'saved' });+ return true;} catch (err) {- setSettings(previous);- setStatus({ kind: 'error', message: err instanceof Error ? err.message : String(err) });+ setStatus({ kind: 'error', message: errorMessage(err) });+ return false;}};- // Clear the local draft input once its key round-trips to the core.- const clearDraftKey: Record<ByokEngine, () => void> = {- parallel: () => setParallelKey(''),- brave: () => setBraveKey(''),- querit: () => setQueritKey(''),- exa: () => setExaKey(''),- tavily: () => setTavilyKey(''),- };+ const updateProvider = (id: string, patch: SearchProviderUpdate) =>+ persist({ providers: { [id]: patch } });- const persistKey = async (engine: ByokEngine, rawKey: string) => {- if (!settings) return;- setStatus({ kind: 'saving' });- try {- await openhumanUpdateSearchSettings({ [BYOK_KEY_FIELD[engine]]: rawKey });- const refreshed = await openhumanGetSearchSettings();- setSettings(refreshed.result);- clearDraftKey[engine]();- setStatus({ kind: 'saved' });- } catch (err) {- setStatus({ kind: 'error', message: err instanceof Error ? err.message : String(err) });- }- };-- const persistSearchUpdate = async (update: SearchSettingsUpdate) => {- if (!settings || status.kind === 'saving') return;- setStatus({ kind: 'saving' });- try {- await openhumanUpdateSearchSettings(update);- const refreshed = await openhumanGetSearchSettings();- setSettings(refreshed.result);- setStatus({ kind: 'saved' });- } catch (err) {- setStatus({ kind: 'error', message: err instanceof Error ? err.message : String(err) });- }- };-- // Switch web-access mode. "Allow all" / "Block all" persist immediately;- // "Custom" only reveals the host editor (its Save button persists the list),- // and we keep whatever the user has already typed.- const selectMode = (next: AccessMode) => {- if (status.kind === 'saving') return;- setMode(next);- if (next === 'all') {- void persistSearchUpdate({ allow_all: true });- } else if (next === 'block') {- void persistSearchUpdate({ allowed_domains: [], allow_all: false });- }- };-- const persistAllowedDomains = () => {- const domains = allowedText.split('\n').map(normalizeAllowedHost).filter(Boolean);- // Editing the explicit host list implies "not allow-all".- void persistSearchUpdate({ allowed_domains: domains, allow_all: false });- };-- const isConfigured = (engine: SearchEngineId): boolean => {- if (!settings) return false;- if (engine === 'disabled') return true;- if (engine === 'managed') return true;- if (engine === 'parallel') return settings.parallel_configured;- if (engine === 'brave') return settings.brave_configured;- if (engine === 'querit') return settings.querit_configured;- if (engine === 'exa') return settings.exa_configured;- if (engine === 'tavily') return settings.tavily_configured;- return false;- };+ const managedUnavailable = isLocalSession || (settings ? !settings.managed_available : false);return (<PanelPage@@ -265,7 +101,7 @@ const SearchPanel = ({ embedded = false }: { embedded?: boolean }) => {{t('settings.search.description')}</p>- {isLocalSession && (+ {managedUnavailable && (<Alert variant="info"><AlertDescription>{t('settings.search.localManagedUnavailable')}</AlertDescription></Alert>@@ -275,180 +111,98 @@ const SearchPanel = ({ embedded = false }: { embedded?: boolean }) => {{settings && (<>- <SearchPanelEngineList- engines={visibleEngines}- selectedEngine={selectedEngine}- ariaLabel={t('settings.search.engineAria')}- isConfigured={isConfigured}- onSelect={engine => void persistEngine(engine)}- t={t}- />-- {/* BYO API keys */}- <div className="space-y-3">- <KeyEditor- label={t('settings.search.parallelKeyLabel')}- placeholder={- settings.parallel_configured- ? t('settings.search.placeholderStored')- : t('settings.search.placeholderParallel')- }- show={showParallel}- onToggleShow={() => setShowParallel(s => !s)}- value={parallelKey}- onChange={setParallelKey}- onSave={() => void persistKey('parallel', parallelKey)}- onClear={() => void persistKey('parallel', '')}- configured={settings.parallel_configured}- docUrl="https://parallel.ai/"- t={t}- />- <KeyEditor- label={t('settings.search.braveKeyLabel')}- placeholder={- settings.brave_configured- ? t('settings.search.placeholderStored')- : t('settings.search.placeholderBrave')- }- show={showBrave}- onToggleShow={() => setShowBrave(s => !s)}- value={braveKey}- onChange={setBraveKey}- onSave={() => void persistKey('brave', braveKey)}- onClear={() => void persistKey('brave', '')}- configured={settings.brave_configured}- docUrl="https://brave.com/search/api/"- t={t}- />- <KeyEditor- label={t('settings.search.queritKeyLabel')}- placeholder={- settings.querit_configured- ? t('settings.search.placeholderStored')- : t('settings.search.placeholderQuerit')- }- show={showQuerit}- onToggleShow={() => setShowQuerit(s => !s)}- value={queritKey}- onChange={setQueritKey}- onSave={() => void persistKey('querit', queritKey)}- onClear={() => void persistKey('querit', '')}- configured={settings.querit_configured}- docUrl="https://www.querit.ai/en/docs/reference/post"- t={t}- />- <KeyEditor- label={t('settings.search.exaKeyLabel')}- placeholder={- settings.exa_configured- ? t('settings.search.placeholderStored')- : t('settings.search.placeholderExa')- }- show={showExa}- onToggleShow={() => setShowExa(s => !s)}- value={exaKey}- onChange={setExaKey}- onSave={() => void persistKey('exa', exaKey)}- onClear={() => void persistKey('exa', '')}- configured={settings.exa_configured}- docUrl="https://exa.ai"- t={t}- />- <KeyEditor- label={t('settings.search.tavilyKeyLabel')}- placeholder={- settings.tavily_configured- ? t('settings.search.placeholderStored')- : t('settings.search.placeholderTavily')- }- show={showTavily}- onToggleShow={() => setShowTavily(s => !s)}- value={tavilyKey}- onChange={setTavilyKey}- onSave={() => void persistKey('tavily', tavilyKey)}- onClear={() => void persistKey('tavily', '')}- configured={settings.tavily_configured}- docUrl="https://tavily.com"- t={t}+ {/* Search on/off */}+ <div className="flex items-center gap-3 rounded-xl border border-line bg-surface p-3">+ <label htmlFor={enabledId} className="flex-1 min-w-0">+ <span className="block text-sm font-medium text-content">+ {t('settings.search.enabledLabel')}+ </span>+ <span className="block text-xs text-content-muted">+ {t('settings.search.enabledDesc')}+ </span>+ </label>+ <Switch+ id={enabledId}+ data-testid="search-enabled-toggle"+ aria-label={t('settings.search.enabledLabel')}+ checked={settings.enabled}+ disabled={saving}+ onCheckedChange={next => void persist({ enabled: next })}/></div>- {/* Allowed websites — unified host allowlist shared by web_fetch /- curl and (when enabled) the browser tool. Web search is not- gated by this list. */}- <div className="rounded-xl border border-line bg-surface p-3 space-y-2">- {/* Section heading, not a form label — use a <p> so screen- readers don't announce an orphan <label> with no htmlFor. */}- <p className="text-xs font-semibold text-content-secondary">- {t('settings.search.allowedSitesLabel')}- </p>- <ToggleGroupRoot- type="single"- aria-label={t('settings.search.accessModeAria')}- value={mode}- onValueChange={value => {- if (value) selectMode(value as AccessMode);- }}- disabled={status.kind === 'saving'}- className="flex w-full rounded-lg border border-line overflow-hidden gap-0">- {(- [- ['all', 'settings.search.accessAllowAll'],- ['custom', 'settings.search.accessCustom'],- ['block', 'settings.search.accessBlockAll'],- ] as const- ).map(([value, labelKey]) => (- <ToggleGroupItem- key={value}- value={value}- variant="tertiary"- className="flex-1 rounded-none border-0 border-l border-line first:border-l-0 px-3 py-1.5 text-xs data-[state=on]:bg-primary-500 data-[state=on]:text-content-inverted">- {t(labelKey)}- </ToggleGroupItem>- ))}- </ToggleGroupRoot>- <p className="text-[11px] text-content-muted leading-relaxed">- {mode === 'all'- ? t('settings.search.allowedSitesAllOn')- : mode === 'block'- ? t('settings.search.accessBlockAllHint')- : t('settings.search.allowedSitesHint')}- </p>- {mode === 'custom' && (- <>- <TextArea- value={allowedText}- onChange={e => setAllowedText(e.target.value)}- rows={4}- spellCheck={false}- placeholder={t('settings.search.allowedSitesPlaceholder')}- className="font-mono text-xs"- aria-label={t('settings.search.allowedSitesLabel')}+ {/* Providers */}+ <section className="space-y-2" aria-labelledby="search-providers-heading">+ <div>+ <h3+ id="search-providers-heading"+ className="text-xs font-semibold text-content-secondary">+ {t('settings.search.providersTitle')}+ </h3>+ <p className="text-[11px] text-content-muted leading-relaxed">+ {t('settings.search.providersDesc')}+ </p>+ </div>+ {settings.providers.map(provider => (+ <SearchPanelProviderCard+ key={provider.id}+ provider={provider}+ saving={saving}+ onUpdate={patch => updateProvider(provider.id, patch)}+ t={t}+ />+ ))}+ </section>++ <SearchPanelRoles settings={settings} saving={saving} persist={persist} t={t} />++ <SearchPanelAllowedSites settings={settings} saving={saving} persist={persist} t={t} />++ {/* Advanced */}+ <CollapsibleRoot variant="card" data-testid="search-advanced">+ <CollapsibleTrigger size="sm">+ {t('settings.search.advancedTitle')}+ <ChevronDownIcon+ className="size-3.5 transition-transform group-data-[state=open]:rotate-180"+ aria-hidden="true"+ />+ </CollapsibleTrigger>+ <CollapsibleContent size="sm">+ <div className="flex items-center gap-3 pt-1">+ <label htmlFor={presentationId} className="flex-1 min-w-0">+ <span className="block text-xs font-medium text-content">+ {t('settings.search.exposeProviderTools')}+ </span>+ <span className="block text-[11px] text-content-muted leading-relaxed">+ {t('settings.search.exposeProviderToolsDesc')}+ </span>+ </label>+ <Switch+ id={presentationId}+ data-testid="search-presentation-toggle"+ aria-label={t('settings.search.exposeProviderTools')}+ checked={settings.presentation === 'all_tools'}+ disabled={saving}+ onCheckedChange={next =>+ void persist({ presentation: next ? 'all_tools' : 'roles' })+ }/>- <Button- type="button"- variant="primary"- size="xs"- onClick={() => persistAllowedDomains()}- disabled={status.kind === 'saving'}>- {t('settings.search.allowedSitesSave')}- </Button>- </>- )}- </div>-- <StatusLine- saving={status.kind === 'saving'}- savedNote={status.kind === 'saved' ? t('settings.search.statusSaved') : null}- error={- status.kind === 'error'- ? `${t('settings.search.statusError')}: ${status.message}`- : null- }- savingLabel={t('settings.search.statusSaving')}- />+ </div>+ </CollapsibleContent>+ </CollapsibleRoot></>)}++ <StatusLine+ saving={saving}+ savedNote={status.kind === 'saved' ? t('settings.search.statusSaved') : null}+ error={+ status.kind === 'error'+ ? `${t('settings.search.statusError')}: ${status.message}`+ : null+ }+ savingLabel={t('settings.search.statusSaving')}+ /></div></PanelPage>);