The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): replace native datalist suggestions with the menu combobox
brooklyn!1def81aa18cb
diff --git a/apps/desktop/src/app/settings/chat-font-setting.tsx b/apps/desktop/src/app/settings/chat-font-setting.tsxindex c71a6c393c7..880eb73a608 100644--- a/apps/desktop/src/app/settings/chat-font-setting.tsx+++ b/apps/desktop/src/app/settings/chat-font-setting.tsx@@ -1,17 +1,22 @@import { useEffect, useRef, useState } from 'react'import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'import { saveHermesConfig } from '@/hermes'import { useI18n } from '@/i18n'import { notifyError } from '@/store/notifications'-import { CHAT_FONT_SUGGESTIONS, normalizeChatFontFamily, setChatFontFamilyFromConfig } from '@/themes/chat-font'+import {+ CHAT_FONT_SUGGESTIONS,+ normalizeChatFontFamily,+ resolveChatFontFamily,+ setChatFontFamilyFromConfig+} from '@/themes/chat-font'import type { HermesConfigRecord } from '@/types/hermes'import { setHermesConfigCache, useHermesConfigRecord } from '../hooks/use-config-record'import { useOnProfileSwitch } from '../hooks/use-on-profile-switch'import { useProfileSwitchLatch } from '../hooks/use-profile-switch-latch'+import { ComboboxInput } from './combobox-input'import { getNested, setNested } from './helpers'import { ListRow } from './primitives'@@ -122,24 +127,22 @@ export function ChatFontSetting() {below={<div className="mt-3 space-y-2"><div className="flex items-center gap-3">- <Input+ <ComboboxInputaria-label={copy.chatFontTitle}className="flex-1"disabled={draft === null}- list="hermes-chat-font-families"- onChange={event => update(event.target.value)}+ onChange={update}+ options={CHAT_FONT_SUGGESTIONS}placeholder={copy.chatFontPlaceholder}+ renderOption={font => (+ <span style={{ fontFamily: resolveChatFontFamily(font, 'var(--dt-font-sans)') }}>{font}</span>+ )}value={value}/><Button disabled={!value || draft === null} onClick={() => update('')} size="inline" variant="text">{copy.chatFontReset}</Button></div>- <datalist id="hermes-chat-font-families">- {CHAT_FONT_SUGGESTIONS.map(font => (- <option key={font} value={font} />- ))}- </datalist>{/* Inherits --dt-font-sans, so it IS the live result, not a simulation. */}<divaria-label={copy.chatFontPreview}diff --git a/apps/desktop/src/app/settings/combobox-input.tsx b/apps/desktop/src/app/settings/combobox-input.tsxindex 984766764b4..e545e0e5318 100644--- a/apps/desktop/src/app/settings/combobox-input.tsx+++ b/apps/desktop/src/app/settings/combobox-input.tsx@@ -1,114 +1,163 @@-import { useRef, useState } from 'react'+import { type ReactNode, useId, useRef, useState } from 'react'import { Codicon } from '@/components/ui/codicon'-import { Command, CommandGroup, CommandItem, CommandList } from '@/components/ui/command'+import { Command, CommandItem, CommandItemCheck, CommandList } from '@/components/ui/command'import { Input } from '@/components/ui/input'import { Popover, PopoverAnchor, PopoverContent } from '@/components/ui/popover'import { useI18n } from '@/i18n'import { isSubmitEnter } from '@/lib/ime'import { cn } from '@/lib/utils'+// cmdk highlights its first row whenever nothing is selected, which would make+// Enter swap free text for that row. A value no row carries keeps the list+// unhighlighted until the user actually arrows or points into it.+const IDLE = '\u0000idle'+/**- * Free-input combobox for open-world fields (voice/model names): a plain- * Input the user can type anything into, plus a dropdown listing ALL known- * options.- *- * Replaces the old `<Input list="…">` + `<datalist>` rendering for- * FREE_INPUT_KEYS: native datalists filter by the field's current value, so a- * field already holding a valid option (e.g. `gpt-4o-mini-tts`) suggested- * only that one entry — users couldn't discover the other models/voices at- * all (and on some platforms datalists barely render). Suggestions filter by- * substring while typing, but an exact-match value shows the full list so an- * already-configured field still exposes every alternative.+ * Free-input combobox for open-world fields (voice/model/font names): a plain+ * Input the user can type anything into, plus the app's menu listing ALL known+ * options. This is the only suggestion list — never `<Input list>` ++ * `<datalist>`: Chromium paints that as its own grey OS popup, out of step with+ * every other menu, and it filters by the field's current value, so a field+ * already holding a valid option (e.g. `gpt-4o-mini-tts`) suggested only that+ * one entry. Suggestions filter by substring while typing, but an exact-match+ * value shows the full list so an already-configured field still exposes+ * every alternative.*/export function ComboboxInput({- value,+ 'aria-label': ariaLabel,+ className,+ disabled,onChange,- options,optionLabels,+ options,placeholder,- className+ renderOption,+ value}: {- value: string+ 'aria-label'?: string+ className?: string+ disabled?: booleanonChange: (value: string) => void- options: string[]optionLabels?: Record<string, string>+ options: readonly string[]placeholder?: string- className?: string+ /** Custom row content, e.g. a font name set in its own face. */+ renderOption?: (option: string) => ReactNode+ value: string}) {const { t } = useI18n()const [open, setOpen] = useState(false)+ const [active, setActive] = useState(IDLE)+ const anchorRef = useRef<HTMLDivElement>(null)const inputRef = useRef<HTMLInputElement>(null)+ const commandRef = useRef<HTMLDivElement>(null)+ const listId = useId()const query = value.trim().toLowerCase()const isExact = options.some(option => option.toLowerCase() === query)const visible = query && !isExact ? options.filter(option => option.toLowerCase().includes(query)) : options+ // An empty menu is just a floating border; stay closed until something matches.+ const expanded = open && !disabled && visible.length > 0++ const openList = (next: boolean) => {+ setOpen(next)+ setActive(IDLE)+ }++ // Focus stays in the Input, outside cmdk's root, so hand it the keys it+ // navigates with.+ const forwardKey = (key: string) =>+ commandRef.current?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: true, key }))return (- <Popover onOpenChange={setOpen} open={open}>+ <Popover onOpenChange={openList} open={expanded}><PopoverAnchor asChild>- <div className={cn('relative', className)}>+ <div className={cn('relative', className)} ref={anchorRef}><Input+ aria-autocomplete="list"+ aria-controls={expanded ? listId : undefined}+ aria-expanded={expanded}+ aria-label={ariaLabel}className="w-full pr-7"+ disabled={disabled}onChange={e => {onChange(e.target.value)-- if (!open) {- setOpen(true)- }+ openList(true)}}- onFocus={() => setOpen(true)}+ onFocus={() => openList(true)}onKeyDown={e => {+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {+ e.preventDefault()++ if (expanded) {+ forwardKey(e.key)+ } else {+ openList(true)+ }++ return+ }++ if (isSubmitEnter(e) && expanded && active !== IDLE) {+ e.preventDefault()+ forwardKey('Enter')++ return+ }+if (e.key === 'Escape' || e.key === 'Tab' || isSubmitEnter(e)) {- setOpen(false)+ openList(false)}}}placeholder={placeholder}ref={inputRef}+ role="combobox"value={value}/><buttonaria-label={t.settings.config.showOptions}- className="absolute inset-y-0 right-1.5 flex items-center text-muted-foreground"+ className="absolute inset-y-0 right-1.5 flex items-center text-(--ui-text-tertiary) disabled:opacity-50"+ disabled={disabled}onClick={() => {- setOpen(current => !current)+ openList(!expanded)inputRef.current?.focus()}}tabIndex={-1}type="button">- <Codicon name={open ? 'chevron-up' : 'chevron-down'} size="1rem" />+ <Codicon name={expanded ? 'chevron-up' : 'chevron-down'} size="1rem" /></button></div></PopoverAnchor><PopoverContentalign="start"- className="min-w-(--radix-popover-trigger-width) p-0"+ className="min-w-(--radix-popover-trigger-width)"+ // The field and its chevron own open/close; a press there isn't "outside".+ onInteractOutside={e => {+ if (anchorRef.current?.contains(e.target as Node)) {+ e.preventDefault()+ }+ }}onOpenAutoFocus={e => e.preventDefault()}+ variant="menu">- <Command shouldFilter={false}>- <CommandList>- {visible.length > 0 && (- <CommandGroup>- {visible.map(option => (- <CommandItem- key={option}- onSelect={() => {- onChange(option)- setOpen(false)- }}- value={option}- >- <Codicon- className={cn('mr-2 size-4', option === value ? 'opacity-100' : 'opacity-0')}- name="check"- />- <span className="truncate">{optionLabels?.[option] ?? option}</span>- </CommandItem>- ))}- </CommandGroup>- )}+ <Command onValueChange={setActive} ref={commandRef} shouldFilter={false} value={active} variant="menu">+ <CommandList id={listId}>+ {visible.map(option => (+ <CommandItem+ key={option}+ onSelect={() => {+ onChange(option)+ openList(false)+ }}+ value={option}+ >+ <span className="min-w-0 truncate">{renderOption?.(option) ?? optionLabels?.[option] ?? option}</span>+ <CommandItemCheck checked={option === value} />+ </CommandItem>+ ))}</CommandList></Command></PopoverContent>diff --git a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx b/apps/desktop/src/app/settings/custom-endpoints-settings.tsxindex f58fedd2936..0db5835eb59 100644--- a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx+++ b/apps/desktop/src/app/settings/custom-endpoints-settings.tsx@@ -26,6 +26,7 @@ import type {CustomEndpointUpdate} from '@/types/hermes'+import { ComboboxInput } from './combobox-input'import { EmptyState, Pill, SectionHeading, SettingsContent, SettingsSkeleton } from './primitives'import { SettingsProfileScope } from './profile-scope'@@ -452,17 +453,12 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C<div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_12rem]"><label className="grid gap-1.5 text-xs text-muted-foreground">{ce.fields.defaultModel}- <Input- list="custom-endpoint-models"- onChange={event => setForm(current => ({ ...current, model: event.target.value }))}+ <ComboboxInput+ onChange={model => setForm(current => ({ ...current, model }))}+ options={allModelOptions}placeholder="gpt-5.4"value={form.model}/>- <datalist id="custom-endpoint-models">- {allModelOptions.map(model => (- <option key={model} value={model} />- ))}- </datalist></label><label className="grid gap-1.5 text-xs text-muted-foreground">{ce.fields.context}diff --git a/apps/desktop/src/app/settings/terminal-font-setting.tsx b/apps/desktop/src/app/settings/terminal-font-setting.tsxindex fc1f593ffe7..e502de6fe1c 100644--- a/apps/desktop/src/app/settings/terminal-font-setting.tsx+++ b/apps/desktop/src/app/settings/terminal-font-setting.tsx@@ -7,7 +7,6 @@ import {TERMINAL_FONT_SUGGESTIONS} from '@/app/right-sidebar/terminal/terminal-font'import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'import { saveHermesConfig } from '@/hermes'import { useI18n } from '@/i18n'import { notifyError } from '@/store/notifications'@@ -17,6 +16,7 @@ import { setHermesConfigCache, useHermesConfigRecord } from '../hooks/use-configimport { useOnProfileSwitch } from '../hooks/use-on-profile-switch'import { useProfileSwitchLatch } from '../hooks/use-profile-switch-latch'+import { ComboboxInput } from './combobox-input'import { getNested, setNested } from './helpers'import { ListRow } from './primitives'@@ -134,24 +134,20 @@ export function TerminalFontSetting() {below={<div className="mt-3 space-y-2"><div className="flex items-center gap-3">- <Input+ <ComboboxInputaria-label={copy.terminalFontTitle}className="flex-1"disabled={draft === null}- list="hermes-terminal-font-families"- onChange={event => update(event.target.value)}+ onChange={update}+ options={TERMINAL_FONT_SUGGESTIONS}placeholder={copy.terminalFontPlaceholder}+ renderOption={font => <span style={{ fontFamily: resolveTerminalFontFamily(font) }}>{font}</span>}value={value}/><Button disabled={!value || draft === null} onClick={() => update('')} size="inline" variant="text">{copy.terminalFontReset}</Button></div>- <datalist id="hermes-terminal-font-families">- {TERMINAL_FONT_SUGGESTIONS.map(font => (- <option key={font} value={font} />- ))}- </datalist><divaria-label={copy.terminalFontPreview}className="overflow-hidden px-1 py-2 text-sm text-(--ui-text-secondary)"