Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
Reusable Select component (filtering, grouping, multi-select) (#175)
Bruno37733feacc88
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fa3c1cb..23a9542 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ What changed in each version of Tucano. The format follows [Keep a Changelog](ht### Changed- **Long skill recipes are kept whole.** A recipe over 20,000 characters was refused when written or proposed, cut when linked from Claude Code or Codex, and left out of an imported team. Now 10,000 characters is a recommendation: past it, Tucano says by how much and keeps the whole recipe, up to a million characters.+- **The pick lists look like the rest of the app.** Effort, model, a tool's class, the routine's agent and where it posts, and the other settings pick lists open a menu of the app's own instead of the system's, with the keyboard working as before. The model list has a filter, and on a harness with models from several providers (OpenCode, Pi), they come grouped by provider.### Fixeddiff --git a/src/renderer/src/components/Harness.tsx b/src/renderer/src/components/Harness.tsxindex 239a9fa..b700d24 100644--- a/src/renderer/src/components/Harness.tsx+++ b/src/renderer/src/components/Harness.tsx@@ -3,7 +3,7 @@// providers they have logins for. Here they pick which ones the agents use,// test them, and pick models from what each harness offers.import { L } from '../../../shared/lang'-import { useEffect, useId, useState, type ReactNode } from 'react'+import { useEffect, useId, useMemo, useState, type ReactNode } from 'react'import {ACCOUNT_ENGINES,addAccount,@@ -37,6 +37,7 @@ import {type Settings} from '../store'import { Icon } from './ui'+import { Select } from './Select'// The harnesses agents may run on now: picked (or all, if never picked), ready, and runnable.export const usableEngines = (s: Settings): EngineId[] => ENGINE_IDS.filter((e) => s.engines[e].loggedIn)@@ -90,6 +91,16 @@ export function useEngineModels(engine: EngineId | undefined): { options: ModelOconst OTHER = '__outro__'+// Provider of a model value: "<provider>/<model>" takes the part before "/",+// otherwise "<engine>:<name>" takes the part before ":", else a fallback group.+const providerOf = (value: string): string => {+ const parts = value.split('/')+ if (parts.length > 1) return parts[0]!+ const colon = value.split(':')+ if (colon.length > 1) return colon[0]!+ return L('Outros', 'Others')+}+// A model to run with: the harness, then its model from the list, or another by name.// jev adds TypeSafe's Jev (the router). Engines limits the harnesses offered.export function ModelPicker({ value, onChange, engines, jev }: { value: string; onChange: (v: string) => void; engines?: EngineId[]; jev?: boolean }): ReactNode {@@ -104,6 +115,22 @@ export function ModelPicker({ value, onChange, engines, jev }: { value: string;const other = value !== 'jev' && !!engine && (typing || (!!m?.id && m.engine === engine && !inList && !loading))const name = m && m.engine === engine && !MODELS.some((x) => x.id === value) ? m.id : ''+ // Engine/harness choices for the first pick.+ const engineOptions = useMemo(+ () => [...choices.map((e) => ({ value: e, label: ENGINES[e].label })), ...(jev ? [{ value: 'jev', label: 'TypeSafe · Jev' }] : [])],+ [choices, jev]+ )+ // The models, grouped by provider (part before "/", or before ":") when there's more than one;+ // "Other model…" last either way.+ const modelChoices = useMemo((): { groups?: Record<string, Record<string, string>>; options?: { value: string; label: string }[] } => {+ const label = (o: (typeof options)[number]): string => (o.hint ? `${o.label} · ${o.hint}` : o.label)+ const otherOne = { value: OTHER, label: L('Outro modelo…', 'Other model…') }+ const byProvider: Record<string, Record<string, string>> = {}+ for (const o of options) (byProvider[providerOf(o.value)] ??= {})[o.value] = label(o)+ if (Object.keys(byProvider).length < 2) return { options: [...options.map((o) => ({ value: o.value, label: label(o) })), otherOne] }+ return { groups: { ...byProvider, [otherOne.label]: { [OTHER]: otherOne.label } } }+ }, [options])+// A harness's own card passes just that harness: it's already chosen there, so no select.const fixed = engines?.length === 1 && !jevif (!engine && !jev)@@ -118,55 +145,40 @@ export function ModelPicker({ value, onChange, engines, jev }: { value: string;return (<div className="model-picker">{!fixed && (- <select+ <Selectvalue={value === 'jev' ? 'jev' : engine}- onChange={(e) => {+ onChange={(v) => {setTyping(false)- const v = e.target.value+ const vv = v ?? ''// On a plan, the harness's first model; otherwise the person picks from its list.- const plan = v !== 'jev' && statuses[v as EngineId].route === 'plan' ? MODELS.find((x) => x.engine === v) : undefined- onChange(v === 'jev' ? 'jev' : (plan?.id ?? customModel(v as EngineId, '')))+ const plan = vv !== 'jev' && statuses[vv as EngineId].route === 'plan' ? MODELS.find((x) => x.engine === vv) : undefined+ onChange(vv === 'jev' ? 'jev' : (plan?.id ?? customModel(vv as EngineId, '')))}}- >- {choices.map((e) => (- <option key={e} value={e}>- {ENGINES[e].label}- </option>- ))}- {jev && <option value="jev">TypeSafe · Jev</option>}- </select>+ options={engineOptions}+ />)}{value !== 'jev' && engine && (- <select- className="grow"- value={other ? OTHER : inList ? value : ''}- onChange={(e) => {- const v = e.target.value- if (v === OTHER) {- setTyping(true)- onChange(customModel(engine, name))- } else {+ <>+ <Select+ className="grow"+ value={other ? OTHER : inList ? value : null}+ searchable+ {...modelChoices}+ placeholder={loading ? L('Buscando os modelos…', 'Fetching the models…') : options.length ? L('Escolha um modelo…', 'Pick a model…') : L('Sem lista: use Outro modelo', 'No list: use Other model')}+ onChange={(v) => {+ if (v === OTHER) {+ setTyping(true)+ onChange(customModel(engine, name))+ return+ }setTyping(false)- onChange(v)- }- }}- >- {!inList && !other && (- <option value="" disabled>- {loading ? L('Buscando os modelos…', 'Fetching the models…') : options.length ? L('Escolha um modelo…', 'Pick a model…') : L('Sem lista: use Outro modelo', 'No list: use Other model')}- </option>+ onChange(v ?? '')+ }}+ />+ {other && (+ <input className="model-name grow" autoFocus={typing && !name} value={name} spellCheck={false} placeholder={L('O nome exato do modelo', 'The exact model name')} onChange={(e) => onChange(customModel(engine, e.target.value))} />)}- {options.map((o) => (- <option key={o.value} value={o.value}>- {o.label}- {o.hint ? ` · ${o.hint}` : ''}- </option>- ))}- <option value={OTHER}>{L('Outro modelo…', 'Other model…')}</option>- </select>- )}- {other && engine && (- <input className="model-name grow" autoFocus={typing && !name} value={name} spellCheck={false} placeholder={L('O nome exato do modelo', 'The exact model name')} onChange={(e) => onChange(customModel(engine, e.target.value))} />+ </>)}{error && other && <span className="hint">{L('Não deu pra pegar a lista', 'Couldn’t get the list')}: {error}</span>}</div>@@ -434,13 +446,12 @@ export function AccountsCard(): ReactNode {</div>))}<div className="row row--center accounts__add">- <select value={engine} onChange={(e) => setEngine(e.target.value as AccountEngine)}>- {ACCOUNT_ENGINES.filter((e) => engines[e].installed).map((e) => (- <option key={e} value={e}>- {ENGINES[e].label}- </option>- ))}- </select>+ <Select+ value={engine}+ onChange={(v) => { if (v) void setEngine(v as AccountEngine) }}+ options={ACCOUNT_ENGINES.filter((e) => engines[e].installed).map((e) => ({ value: e, label: ENGINES[e].label }))}+ placeholder={L('Motor', 'Engine')}+ /><input className="grow" placeholder={L('Nome da conta (ex.: Trabalho)', 'Account name (e.g. Work)')} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && void add()} /><button className="btn btn--sm" disabled={!engines[engine].installed} onClick={() => void add()}>{L('Adicionar e entrar', 'Add and sign in')}@@ -465,18 +476,19 @@ export function AccountPicker({ draft, patch }: { draft: Agent; patch: (p: Partiif (!accounts.length || !engine) return nullconst value = accounts.some((a) => a.id === draft.accountId) ? draft.accountId! : ''const chosen = accounts.find((a) => a.id === value)+ const usualLabel = L(`A de sempre do ${ENGINES[engine].label}`, `${ENGINES[engine].label}’s usual one`)return (<label className="field"><span className="field__label">{L('Conta', 'Account')}</span>- <select value={value} onChange={(e) => patch({ accountId: e.target.value || undefined })}>- <option value="">{L(`A de sempre do ${ENGINES[engine].label}`, `${ENGINES[engine].label}’s usual one`)}</option>- {accounts.map((a) => (- <option key={a.id} value={a.id}>- {a.name}- {a.loggedIn ? '' : L(' (falta entrar)', ' (not signed in)')}- </option>- ))}- </select>+ <Select+ value={value || null}+ onChange={(v) => patch({ accountId: v || undefined })}+ options={[+ { value: '', label: usualLabel },+ ...accounts.map((a) => ({ value: a.id, label: a.name + (a.loggedIn ? '' : L(' (falta entrar)', ' (not signed in)')) }))+ ]}+ placeholder={usualLabel}+ />{chosen && !chosen.loggedIn && <span className="hint hint--warn">{L('Essa conta ainda não entrou: o agente não responde até você entrar nela em Configurações › Modelos.', 'This account isn’t signed in yet: the agent won’t reply until you sign in under Settings › Models.')}</span>}</label>)diff --git a/src/renderer/src/components/Modal.tsx b/src/renderer/src/components/Modal.tsxindex ae38f3b..c21d0db 100644--- a/src/renderer/src/components/Modal.tsx+++ b/src/renderer/src/components/Modal.tsx@@ -27,6 +27,8 @@ export function Modal({ title, onClose, children, className, variant = 'dialog',// Captured before the page's own keys, so an Esc here doesn't also close what's behind.const keys = (e: KeyboardEvent): void => {if (openModals[openModals.length - 1] !== me) return+ // Esc with a select's menu open closes just the menu (it's in a portal, outside the card).+ if (e.key === 'Escape' && e.target instanceof Element && e.target.closest('.select__menu')) returnif (e.key === 'Escape') {e.stopImmediatePropagation()e.preventDefault()diff --git a/src/renderer/src/components/Pages.tsx b/src/renderer/src/components/Pages.tsxindex 9f9b32c..93a8002 100644--- a/src/renderer/src/components/Pages.tsx+++ b/src/renderer/src/components/Pages.tsx@@ -81,6 +81,7 @@ import { ProposalCard } from './Tuca'import { confirmDialog } from './Dialogs'import { Modal } from './Modal'import { AgentAvatar, AVATARS, Icon, NumberInput, SleepingToucan, time, tokens, UsageBar } from './ui'+import { Select } from './Select'import { UpdateSettings } from './Update'import { hasServers, ServersCard } from './Servers'import { useWorkspaceList } from './Workspaces'@@ -707,13 +708,12 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d{/* Cursor's models carry the effort in the name (…-high, …-xhigh): no separate pick. */}{engine !== 'cursor' && (<Field label={L('Esforço de raciocínio', 'Reasoning effort')} hint={L('Mais esforço pensa mais e gasta mais do plano.', 'More effort thinks longer and uses more of your plan.')}>- <select value={draft.effort} onChange={(e) => patch({ effort: e.target.value as Agent['effort'] })}>- {EFFORTS.map((ef) => (- <option key={ef.id} value={ef.id}>- {ef.label}- </option>- ))}- </select>+ <Select+ value={draft.effort ?? null}+ onChange={(v) => { if (v) patch({ effort: v as Agent['effort'] }) }}+ options={EFFORTS.map((ef) => ({ value: ef.id, label: ef.label }))}+ placeholder={L('Escolha o esforço', 'Pick an effort')}+ /></Field>)}<Field label={L('Limite mensal (milhões de tokens)', 'Monthly limit (millions of tokens)')} hint={L(`Conferido antes de cada turno. No limite, ${draft.name || 'o agente'} para e avisa.`, `Checked before every turn. At the limit, ${draft.name || 'the agent'} stops and tells you.`)}>@@ -1415,13 +1415,12 @@ function ConnectorDetails({ c, onClose }: { c: Connector; onClose: () => void }){t.name}{t.isNew && <span className="tag tag--warn tools__new">{L('nova', 'new')}</span>}</code>- <select value={t.cls} onChange={(e) => updateTool(c.id, t.name, { cls: e.target.value as ToolClass })}>- {(Object.keys(CLASS_LABEL()) as ToolClass[]).map((k) => (- <option key={k} value={k}>- {CLASS_LABEL()[k]}- </option>- ))}- </select>+ <Select+ value={t.cls ?? null}+ onChange={(v) => { if (v) updateTool(c.id, t.name, { cls: v as ToolClass }) }}+ options={(Object.keys(CLASS_LABEL()) as ToolClass[]).map((k) => ({ value: k, label: CLASS_LABEL()[k] }))}+ placeholder={L('Escolha a classe', 'Pick a class')}+ /><inputtype="checkbox"disabled={t.cls !== 'sensitive'}@@ -1495,11 +1494,16 @@ function AddConnector({ onDone }: { onDone: (id?: string) => void }): ReactNode<input value={url} placeholder="https://mcp.linear.app/mcp" onChange={(e) => setUrl(e.target.value)} /></Field><Field label={L('Autenticação', 'Authentication')}>- <select value={auth} onChange={(e) => setAuth(e.target.value as ConnectorAuth)}>- <option value="oauth">{L('OAuth (abre o navegador pra autorizar)', 'OAuth (opens the browser to authorize)')}</option>- <option value="token">{L('Token (cabeçalho Authorization: Bearer)', 'Token (Authorization: Bearer header)')}</option>- <option value="none">{L('Nenhuma', 'None')}</option>- </select>+ <Select+ value={auth ?? null}+ onChange={(v) => { if (v) setAuth(v as ConnectorAuth) }}+ options={[+ { value: 'oauth', label: L('OAuth (abre o navegador pra autorizar)', 'OAuth (opens the browser to authorize)') },+ { value: 'token', label: L('Token (cabeçalho Authorization: Bearer)', 'Token (Authorization: Bearer header)') },+ { value: 'none', label: L('Nenhuma', 'None') }+ ]}+ placeholder={L('Escolha a autenticação', 'Pick an authentication')}+ /></Field>{auth === 'token' && (<Field label="Token" hint={L('Ou uma referência do 1Password (op://Cofre/Item/campo), lida a cada conexão.', 'Or a 1Password reference (op://Vault/Item/field), read on each connection.')}>@@ -1681,15 +1685,15 @@ function ReserveModel({ draft, patch }: { draft: Agent; patch: (p: Partial<Agent{on && reserve && reserveAccounts.length > 0 && (<label className="field"><span className="field__label">{L('Conta da reserva', 'Reserve account')}</span>- <select value={reserveAccount?.id ?? ''} onChange={(e) => patch({ fallbackAccountId: e.target.value || undefined })}>- <option value="">{L(`A de sempre do ${ENGINES[reserve.engine].label}`, `${ENGINES[reserve.engine].label}’s usual one`)}</option>- {reserveAccounts.map((a) => (- <option key={a.id} value={a.id}>- {a.name}- {a.loggedIn ? '' : L(' (falta entrar)', ' (not signed in)')}- </option>- ))}- </select>+ <Select+ value={reserveAccount?.id ?? null}+ onChange={(v) => patch({ fallbackAccountId: v || undefined })}+ options={[+ { value: '', label: L(`A de sempre do ${ENGINES[reserve.engine].label}`, `${ENGINES[reserve.engine].label}’s usual one`) },+ ...reserveAccounts.map((a) => ({ value: a.id, label: a.name + (a.loggedIn ? '' : L(' (falta entrar)', ' (not signed in)')) }))+ ]}+ placeholder={L(`A de sempre do ${ENGINES[reserve.engine].label}`, `${ENGINES[reserve.engine].label}’s usual one`)}+ />{reserveAccount && !reserveAccount.loggedIn && <span className="hint hint--warn">{L('Essa conta ainda não entrou: a reserva só funciona depois que você entrar nela em Configurações › Modelos.', 'This account isn’t signed in yet: the reserve only works once you sign in under Settings › Models.')}</span>}</label>)}@@ -2232,11 +2236,16 @@ export function SettingsPage(): ReactNode {<ModelSelect value={settings.memoryModel} onChange={(memoryModel) => updateSettings({ memoryModel })} /></Field><Field label={L('O que ele aprende sobre você', 'What it learns about you')} hint={L('Só conta o que você disse, nunca o que um agente supôs.', 'Only what you said counts, never what an agent assumed.')}>- <select value={settings.memoryLearning} onChange={(e) => updateSettings({ memoryLearning: e.target.value as typeof settings.memoryLearning })}>- <option value="approve">{L('Vira sugestão pra você aprovar', 'A suggestion for you to approve')}</option>- <option value="auto">{L('Grava sozinho', 'Saved on its own')}</option>- <option value="off">{L('Nada (só resume)', 'Nothing (just summarizes)')}</option>- </select>+ <Select+ value={settings.memoryLearning ?? null}+ onChange={(v) => { if (v) updateSettings({ memoryLearning: v as typeof settings.memoryLearning }) }}+ options={[+ { value: 'approve', label: L('Vira sugestão pra você aprovar', 'A suggestion for you to approve') },+ { value: 'auto', label: L('Grava sozinho', 'Saved on its own') },+ { value: 'off', label: L('Nada (só resume)', 'Nothing (just summarizes)') }+ ]}+ placeholder={L('Escolha', 'Pick')}+ /></Field></div></Card>@@ -2311,11 +2320,16 @@ export function SettingsPage(): ReactNode {/></Field><Field label={L('Expiração de aprovações', 'Approvals expire after')}>- <select value={settings.approvalTtlHours} onChange={(e) => updateSettings({ approvalTtlHours: Number(e.target.value) })}>- <option value="1">{L('1 hora', '1 hour')}</option>- <option value="24">{L('24 horas', '24 hours')}</option>- <option value="168">{L('7 dias', '7 days')}</option>- </select>+ <Select+ value={settings.approvalTtlHours ? String(settings.approvalTtlHours) : null}+ onChange={(v) => { if (v) updateSettings({ approvalTtlHours: Number(v) }) }}+ options={[+ { value: '1', label: L('1 hora', '1 hour') },+ { value: '24', label: L('24 horas', '24 hours') },+ { value: '168', label: L('7 dias', '7 days') }+ ]}+ placeholder={L('Escolha', 'Pick')}+ /></Field></div></Card>diff --git a/src/renderer/src/components/Routines.tsx b/src/renderer/src/components/Routines.tsxindex aa48bab..c05dcdb 100644--- a/src/renderer/src/components/Routines.tsx+++ b/src/renderer/src/components/Routines.tsx@@ -30,6 +30,7 @@ import { AdminOnly } from './People'import { Card, Field, Sheet, Toggle } from './Pages'import { AgentAvatar, Icon, ownColor, shiftWeek, startOfWeek, weekRange } from './ui'import { Modal } from './Modal'+import { Select } from './Select'const DAYS = (): string[] => (lang() === 'en' ? ['S', 'M', 'T', 'W', 'T', 'F', 'S'] : ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'])const DAY_NAMES = (): string[] => (lang() === 'en' ? ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] : ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'])@@ -748,14 +749,12 @@ function RoutineForm({ draft, onChange, onClose }: { draft: Draft; onChange: (d:<input autoFocus value={draft.name} placeholder={L('Bom dia', 'Good morning')} onChange={(e) => set({ name: e.target.value })} /></Field><Field label={L('Agente', 'Agent')}>- <select value={draft.agentId} onChange={(e) => set({ agentId: e.target.value, conversationId: '' })}>- {agents.map((a) => (- <option key={a.id} value={a.id}>- {a.name}- {a.role ? ` · ${a.role}` : ''}- </option>- ))}- </select>+ <Select+ value={draft.agentId ?? null}+ onChange={(v) => { if (v) set({ agentId: v, conversationId: '' }) }}+ options={agents.map((a) => ({ value: a.id, label: a.name + (a.role ? ` · ${a.role}` : '') }))}+ placeholder={L('Escolha um agente', 'Pick an agent')}+ /></Field></div><Field label={L('O que fazer', 'What to do')} hint={L('Como você escreveria numa mensagem. Ele usa as ferramentas, os conectores e o computador que já tem.', 'As you’d write it in a message. It uses the tools, connectors and computer it already has.')}>@@ -790,25 +789,20 @@ function RoutineForm({ draft, onChange, onClose }: { draft: Draft; onChange: (d:<><div className="grid2"><Field label={L('Conector', 'Connector')}>- <select value={t.connectorId} onChange={(e) => (setPreview(null), set({ trigger: pollTrigger({ connectorId: e.target.value }) }))}>- {connectors.map((c) => (- <option key={c.id} value={c.id}>- {c.name}- </option>- ))}- </select>+ <Select+ value={t.connectorId ?? null}+ onChange={(v) => { if (v) { setPreview(null); set({ trigger: pollTrigger({ connectorId: v }) }) } }}+ options={connectors.map((c) => ({ value: c.id, label: c.name }))}+ placeholder={L('Escolha um conector', 'Pick a connector')}+ /></Field><Field label={L('Ferramenta de leitura', 'Read tool')}>- <select value={t.tool} onChange={(e) => (setPreview(null), set({ trigger: pollTrigger({ tool: e.target.value }) }))}>- {connectors- .find((c) => c.id === t.connectorId)- ?.tools.filter((x) => x.cls === 'read' && x.enabled)- .map((x) => (- <option key={x.name} value={x.name}>- {x.name}- </option>- ))}- </select>+ <Select+ value={t.tool ?? null}+ onChange={(v) => { if (v) { setPreview(null); set({ trigger: pollTrigger({ tool: v }) }) } }}+ options={connectors.find((c) => c.id === t.connectorId)?.tools.filter((x) => x.cls === 'read' && x.enabled).map((x) => ({ value: x.name, label: x.name }))}+ placeholder={L('Escolha uma ferramenta', 'Pick a tool')}+ /></Field></div><div className="grid2">@@ -816,13 +810,12 @@ function RoutineForm({ draft, onChange, onClose }: { draft: Draft; onChange: (d:<textarea rows={2} className="mono" value={argsText} onChange={(e) => (setPreview(null), setArgsText(e.target.value))} /></Field><Field label={L('Olhar a cada', 'Check every')}>- <select value={t.everyMinutes} onChange={(e) => set({ trigger: pollTrigger({ everyMinutes: Number(e.target.value) }) })}>- {POLL_MINUTES.map((m) => (- <option key={m} value={m}>- {m < 60 ? `${m} min` : L('1 hora', '1 hour')}- </option>- ))}- </select>+ <Select+ value={String(t.everyMinutes)}+ onChange={(v) => { if (v) set({ trigger: pollTrigger({ everyMinutes: Number(v) }) }) }}+ options={POLL_MINUTES.map((m) => ({ value: String(m), label: m < 60 ? `${m} min` : L('1 hora', '1 hour') }))}+ placeholder={L('Escolha um intervalo', 'Pick an interval')}+ /></Field></div><div className="row row--center routine-test">@@ -891,14 +884,15 @@ function RoutineForm({ draft, onChange, onClose }: { draft: Draft; onChange: (d:)}{team && !admin && !locked && <AdminOnly>{L('Só um admin cria rotinas do canal.', 'Only an admin creates channel routines.')}</AdminOnly>}<Field label={L('Onde postar', 'Where to post')}>- <select value={target} onChange={(e) => set({ conversationId: e.target.value })}>- {!(team && scope === 'channel') && <option value="">{L(`DM com ${agent?.name ?? 'o agente'}`, `DM with ${agent?.name ?? 'the agent'}`)}</option>}- {channels.map((c) => (- <option key={c.id} value={c.id}>- #{c.name}- </option>- ))}- </select>+ <Select+ value={target ?? null}+ onChange={(v) => set({ conversationId: v ?? '' })}+ options={[+ ...(team && scope === 'channel' ? [] : [{ value: '', label: L(`DM com ${agent?.name ?? 'o agente'}`, `DM with ${agent?.name ?? 'the agent'}`) }]),+ ...channels.map((c) => ({ value: c.id, label: `#${c.name}` }))+ ]}+ placeholder={team && scope === 'channel' ? L('Escolha um canal', 'Pick a channel') : L(`DM com ${agent?.name ?? 'o agente'}`, `DM with ${agent?.name ?? 'the agent'}`)}+ /></Field>{team && scope === 'channel' && (<div className="key-row">diff --git a/src/renderer/src/components/Select.tsx b/src/renderer/src/components/Select.tsxnew file mode 100644index 0000000..3568b08--- /dev/null+++ b/src/renderer/src/components/Select.tsx@@ -0,0 +1,456 @@+// A reusable, shadcn-style select input: optional inline filtering (typing when+// open), single or multi selection (checkbox on the left, accent check mark),+// optional grouping as `{ 'group name': { value: 'label', ... } }`, full keyboard+// control (arrows move focus, enter selects, Esc closes, typeahead on a closed+// trigger jumps to the first match), click-outside/Esc to close, and+// accessibility. The menu renders in a portal at `document.body`, anchored to+// the trigger with fixed coordinates (flips above when there's no room below,+// follows scroll/resize).+//+// Flat options (strings mean value === label):+// <Select options={['a', 'b']} value={v} onChange={setV} />+// <Select options={[{ value: 'x', label: 'Label of x' }]} />+//+// Grouped options:+// <Select groups={{ 'Meu grupo 1': { x: 'Label of x', y: 'Label of y' } }} />+//+// Multi-select:+// <Select multiple options={['a','b']} values={['a']} onValuesChange={setVs} />+//+// With filter box:+// <Select options={bigList} searchable />+import { memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent, type ReactNode } from 'react'+import { createPortal } from 'react-dom'+import { L } from '../../../shared/lang'+import { Icon } from './ui'++const fold = (s: string): string =>+ s.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase()++type SelectOption = { value: string; label: string; hint?: string }++type SelectProps = {+ id?: string+ name?: string+ label?: string+ hint?: string+ // Flat list: strings (value === label) or { value, label } objects.+ options?: (string | SelectOption)[]+ // Grouped options: { 'group name': { value: 'label to show', ... } }.+ groups?: Record<string, Record<string, string>>+ placeholder?: string+ // Single select value.+ value?: string | null+ // Multi select values.+ values?: string[]+ onChange?: (value: string | null) => void+ onValuesChange?: (values: string[]) => void+ multiple?: boolean+ // Show the filter (type-ahead) input when the menu opens.+ searchable?: boolean+ // Show a small secondary hint line under each option's label.+ showHint?: boolean+ disabled?: boolean+ required?: boolean+ // Accessible label override; defaults to `label`.+ 'aria-label'?: string+ // Whether the menu is open (controlled). When omitted the menu is uncontrolled.+ open?: boolean+ onOpenChange?: (open: boolean) => void+ className?: string+ // Empty-state text when nothing matches the filter.+ emptyText?: string+}++type Item = {+ value: string+ label: string+ hint?: string+ group?: string+ groupIndex?: number+ // Folded label, computed once, for filtering and typeahead.+ key: string+}++const normalize = (o: string | SelectOption): SelectOption =>+ typeof o === 'string' ? { value: o, label: o } : o++// "provider:model" reads better as "provider: model" in a group title.+const groupTitle = (s: string): string => s.replace(/:(?=\S)/g, ': ')++const resolveItems = (+ options: SelectProps['options'],+ groups: SelectProps['groups']+): Item[] => {+ const items: Item[] = []+ if (groups) {+ Object.entries(groups).forEach(([groupLabel, inner], gi) => {+ const group = groupTitle(groupLabel)+ for (const [value, label] of Object.entries(inner)) items.push({ value, label, group, groupIndex: gi, key: fold(label) })+ })+ return items+ }+ for (const o of (options ?? []).map(normalize)) items.push({ value: o.value, label: o.label, hint: o.hint, key: fold(o.label) })+ return items+}++// Gap between trigger and menu, and minimum distance from the window edge.+const GAP = 6+const MARGIN = 8+const PREFERRED_HEIGHT = 300+// Below this much room on either side, the menu overlays the trigger instead.+const MIN_HEIGHT = 96++type MenuPosition = { top?: number; bottom?: number; left: number; width: number; maxHeight: number; placement: 'top' | 'bottom' | 'over' }++const samePosition = (a: MenuPosition | null, b: MenuPosition): boolean =>+ !!a && a.top === b.top && a.bottom === b.bottom && a.left === b.left && a.width === b.width && a.maxHeight === b.maxHeight && a.placement === b.placement++type OptionProps = {+ item: Item+ index: number+ domId: string+ active: boolean+ selected: boolean+ multiple: boolean+ showHint: boolean+ onPick: (value: string) => void+ onHover: (index: number) => void+}++// Memoized so moving the highlight re-renders two options, not the whole list.+const SelectOptionRow = memo(function SelectOptionRow({ item, index, domId, active, selected, multiple, showHint, onPick, onHover }: OptionProps): ReactNode {+ return (+ <button+ type="button"+ role="option"+ tabIndex={-1}+ aria-selected={selected}+ id={domId}+ className={`select__option${active ? ' is-active' : ''}${selected ? ' is-selected' : ''}`}+ onClick={(e) => { e.preventDefault(); onPick(item.value) }}+ onMouseMove={() => { if (!active) onHover(index) }}+ >+ {multiple && (+ <span className={`select__check${selected ? ' is-on' : ''}`} aria-hidden>+ {selected && <Icon name="check" size={12} />}+ </span>+ )}+ <span className="select__option__text">+ <span className="select__label">{item.label}</span>+ {showHint && item.hint && <span className="select__hint">{item.hint}</span>}+ </span>+ {!multiple && selected && <span className="select__tick" aria-hidden><Icon name="check" size={13} /></span>}+ </button>+ )+})++export function Select(props: SelectProps): ReactNode {+ const {+ id, name, label, hint, options, groups,+ placeholder = '', value, values, onChange, onValuesChange,+ multiple = false, searchable = false, showHint = false, disabled = false, required = false,+ 'aria-label': ariaLabelProp, open: openProp, onOpenChange,+ className = '', emptyText = L('Nenhuma correspondência', 'No matches')+ } = props+ const [openState, setOpenState] = useState(false)+ const open = openProp ?? openState+ const [query, setQuery] = useState('')+ const [highlight, setHighlight] = useState(0)+ const [position, setPosition] = useState<MenuPosition | null>(null)+ const triggerRef = useRef<HTMLButtonElement>(null)+ const menuRef = useRef<HTMLDivElement>(null)+ const inputRef = useRef<HTMLInputElement>(null)+ const listRef = useRef<HTMLDivElement>(null)+ const [selectedValue, setSelectedValue] = useState<string | null>(value ?? null)+ const [selectedValues, setSelectedValues] = useState<string[]>(values ?? [])++ useEffect(() => { setSelectedValue(value ?? null) }, [value])+ useEffect(() => { setSelectedValues(values ?? []) }, [values])++ // Derived data, recomputed only when the inputs change.+ const items = useMemo(() => resolveItems(options, groups), [options, groups])+ const labels = useMemo(() => new Map(items.map((it) => [it.value, it.label])), [items])+ const q = fold(query.trim())+ const filteredItems = useMemo(() => (q ? items.filter((it) => it.key.includes(q)) : items), [items, q])+ const selectedSet = useMemo(() => new Set(multiple ? selectedValues : selectedValue != null ? [selectedValue] : []), [multiple, selectedValues, selectedValue])+ const matchCount = filteredItems.length+ const last = Math.max(0, matchCount - 1)+ const activeIndex = Math.min(highlight, last)+ const highlightedItem = filteredItems[activeIndex]++ const setOpen = useCallback((next: boolean) => {+ if (openProp === undefined) setOpenState(next)+ onOpenChange?.(next)+ }, [openProp, onOpenChange])+ const close = useCallback(() => setOpen(false), [setOpen])+ const openMenu = useCallback(() => { if (!disabled) setOpen(true) }, [disabled, setOpen])++ // Place the menu next to the trigger, in viewport coordinates, never past the window edges.+ const place = useCallback(() => {+ const trigger = triggerRef.current+ if (!trigger) return+ const r = trigger.getBoundingClientRect()+ const vw = window.innerWidth+ const vh = window.innerHeight+ // The trigger left the screen (scrolled away): close instead of floating a detached menu.+ if (r.bottom < 0 || r.top > vh || r.right < 0 || r.left > vw) { close(); return }+ const below = vh - r.bottom - GAP - MARGIN+ const above = r.top - GAP - MARGIN+ const wanted = Math.min(menuRef.current?.scrollHeight ?? PREFERRED_HEIGHT, PREFERRED_HEIGHT)+ const width = Math.max(0, Math.min(Math.max(r.width, 180), vw - MARGIN * 2))+ const left = Math.round(Math.min(Math.max(MARGIN, r.left), vw - width - MARGIN))+ let next: MenuPosition+ if (below >= wanted || (below >= above && below >= MIN_HEIGHT))+ next = { left, width, top: Math.round(r.bottom + GAP), maxHeight: Math.floor(Math.min(below, PREFERRED_HEIGHT)), placement: 'bottom' }+ else if (above >= MIN_HEIGHT)+ next = { left, width, bottom: Math.round(vh - r.top + GAP), maxHeight: Math.floor(Math.min(above, PREFERRED_HEIGHT)), placement: 'top' }+ else {+ // A very short window: use the whole height, over the trigger.+ const h = Math.max(0, Math.min(vh - MARGIN * 2, PREFERRED_HEIGHT))+ next = { left, width, top: Math.round(Math.max(MARGIN, Math.min(r.top, vh - MARGIN - h))), maxHeight: Math.floor(h), placement: 'over' }+ }+ setPosition((prev) => (samePosition(prev, next) ? prev : next))+ }, [close])++ useLayoutEffect(() => {+ if (!open) { setPosition(null); return }+ place()+ // Coalesce scroll/resize bursts into one measurement per frame.+ let frame = 0+ const schedule = (): void => { if (!frame) frame = requestAnimationFrame(() => { frame = 0; place() }) }+ const onScroll = (e: Event): void => {+ // Scrolling inside the menu itself shouldn't re-place it.+ if (menuRef.current && e.target instanceof Node && menuRef.current.contains(e.target)) return+ schedule()+ }+ window.addEventListener('resize', schedule)+ window.addEventListener('scroll', onScroll, { capture: true, passive: true })+ const ro = new ResizeObserver(schedule)+ if (triggerRef.current) ro.observe(triggerRef.current)+ return () => {+ cancelAnimationFrame(frame)+ window.removeEventListener('resize', schedule)+ window.removeEventListener('scroll', onScroll, { capture: true })+ ro.disconnect()+ }+ }, [open, place])++ // Re-place when the content height changes (filtering).+ useLayoutEffect(() => { if (open) place() }, [open, matchCount, place])++ // On open: reset the filter, highlight the current value, move focus into the menu.+ useEffect(() => {+ if (!open) return+ setQuery('')+ const current = multiple ? selectedValues[0] : selectedValue+ const idx = current != null ? items.findIndex((it) => it.value === current) : -1+ setHighlight(idx === -1 ? 0 : idx)+ const frame = requestAnimationFrame(() => {+ if (searchable) inputRef.current?.focus()+ else listRef.current?.focus({ preventScroll: true })+ })+ return () => cancelAnimationFrame(frame)+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [open, searchable])++ // Keep the highlighted option visible, below the sticky group title.+ useEffect(() => {+ if (!open) return+ const list = listRef.current+ const el = list?.querySelector<HTMLElement>('.select__option.is-active')+ if (!list || !el) return+ const header = groups ? list.querySelector<HTMLElement>('.select__group')?.offsetHeight ?? 0 : 0+ const top = el.offsetTop - header+ const bottom = el.offsetTop + el.offsetHeight+ if (top < list.scrollTop) list.scrollTop = top+ else if (bottom > list.scrollTop + list.clientHeight) list.scrollTop = bottom - list.clientHeight+ }, [open, activeIndex, position, groups])++ // Click outside closes the menu.+ useEffect(() => {+ if (!open) return+ const onDown = (e: Event): void => {+ const t = e.target as Node+ if (triggerRef.current?.contains(t) || menuRef.current?.contains(t)) return+ close()+ }+ document.addEventListener('mousedown', onDown)+ return () => document.removeEventListener('mousedown', onDown)+ }, [open, close])++ // Stable pick handler for the memoized rows; reads the latest state through a ref.+ const latest = useRef({ multiple, selectedValues, onChange, onValuesChange, close })+ latest.current = { multiple, selectedValues, onChange, onValuesChange, close }+ const toggleItem = useCallback((v: string): void => {+ const { multiple: m, selectedValues: cur, onChange: oc, onValuesChange: ovc, close: cl } = latest.current+ if (m) {+ const next = cur.includes(v) ? cur.filter((x) => x !== v) : [...cur, v]+ setSelectedValues(next)+ ovc?.(next)+ } else {+ setSelectedValue(v)+ oc?.(v)+ cl()+ triggerRef.current?.focus()+ }+ }, [])++ const onTriggerKeyDown = (e: KeyboardEvent<HTMLButtonElement>): void => {+ if (open) return+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === ' ' || e.key === 'Enter') { e.preventDefault(); openMenu(); return }+ if (e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {+ e.preventDefault()+ openMenu()+ const ch = fold(e.key)+ const idx = items.findIndex((it) => it.key.startsWith(ch))+ if (idx !== -1) setTimeout(() => setHighlight(idx), 0)+ }+ }++ // Keyboard inside the open menu (filter input or list).+ const onMenuKeyDown = (e: KeyboardEvent<HTMLElement>): void => {+ if (e.key === 'ArrowDown') { e.preventDefault(); setHighlight((h) => Math.min(h + 1, last)); return }+ if (e.key === 'ArrowUp') { e.preventDefault(); setHighlight((h) => Math.max(Math.min(h, last) - 1, 0)); return }+ if (e.key === 'Home') { e.preventDefault(); setHighlight(0); return }+ if (e.key === 'End') { e.preventDefault(); setHighlight(last); return }+ if (e.key === 'PageDown') { e.preventDefault(); setHighlight((h) => Math.min(h + 8, last)); return }+ if (e.key === 'PageUp') { e.preventDefault(); setHighlight((h) => Math.max(Math.min(h, last) - 8, 0)); return }+ if (e.key === 'Enter' || (e.key === ' ' && !searchable)) { e.preventDefault(); if (highlightedItem) toggleItem(highlightedItem.value); return }+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(); triggerRef.current?.focus(); return }+ if (e.key === 'Tab') { close(); return }+ if (!searchable && e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {+ const ch = fold(e.key)+ const idx = filteredItems.findIndex((it) => it.key.startsWith(ch))+ if (idx !== -1) setHighlight(idx)+ }+ }++ // Each select its own ids, so two on a page don't share options, lists or menus.+ const ownId = useId()+ const idBase = id ?? `select${ownId.replace(/:/g, '')}`+ const optionId = (i: number): string => `${idBase}-option-${i}`++ const renderRow = (it: Item, i: number): ReactNode => (+ <SelectOptionRow+ key={`${it.groupIndex ?? 0}-${it.value}`}+ item={it}+ index={i}+ domId={optionId(i)}+ active={i === activeIndex}+ selected={selectedSet.has(it.value)}+ multiple={multiple}+ showHint={showHint}+ onPick={toggleItem}+ onHover={setHighlight}+ />+ )++ // Each group is its own section so its title sticks only while its options scroll by.+ const renderList = (): ReactNode => {+ if (!groups) return filteredItems.map(renderRow)+ const sections: { key: number; title: string; rows: ReactNode[] }[] = []+ filteredItems.forEach((it, i) => {+ let s = sections[sections.length - 1]+ if (!s || s.key !== it.groupIndex) { s = { key: it.groupIndex ?? 0, title: it.group ?? '', rows: [] }; sections.push(s) }+ s.rows.push(renderRow(it, i))+ })+ return sections.map((s) => (+ <div key={s.key} className="select__section" role="group" aria-label={s.title}>+ <div className="select__group" aria-hidden>{s.title}</div>+ {s.rows}+ </div>+ ))+ }++ const display = (): ReactNode => {+ if (multiple) {+ if (selectedValues.length === 0) return <span className="select__placeholder">{placeholder}</span>+ if (selectedValues.length <= 3) return selectedValues.map((v) => <span key={v} className="select__chip">{labels.get(v) ?? v}</span>)+ return <span className="select__chip">{L(`${selectedValues.length} selecionados`, `${selectedValues.length} selected`)}</span>+ }+ // An option whose value is '' ("the usual one") shows as itself, like any other.+ return selectedValue != null && labels.has(selectedValue) ? <span className="select__value">{labels.get(selectedValue)}</span> : selectedValue ? <span className="select__value">{selectedValue}</span> : <span className="select__placeholder">{placeholder}</span>+ }++ const menuId = `${idBase}-menu`+ const listId = `${idBase}-list`+ const accessibleName = ariaLabelProp ?? label ?? undefined+ const menuStyle: CSSProperties = position+ ? { top: position.top, bottom: position.bottom, left: position.left, width: position.width, maxHeight: position.maxHeight }+ : { visibility: 'hidden', top: 0, left: 0 }++ return (+ <div className={`select ${className}`}>+ {label && (+ <label className="field__label" htmlFor={id || undefined}>+ {label}{required && <span className="field__required" aria-hidden> *</span>}+ </label>+ )}+ <button+ ref={triggerRef}+ id={id}+ name={name}+ type="button"+ role="combobox"+ aria-expanded={open}+ aria-haspopup="listbox"+ aria-controls={open ? listId : undefined}+ aria-activedescendant={open && highlightedItem ? optionId(activeIndex) : undefined}+ aria-label={accessibleName}+ aria-required={required}+ aria-disabled={disabled || undefined}+ className={`select__trigger ${open ? 'is-open' : ''} ${disabled ? 'is-disabled' : ''}`}+ disabled={disabled}+ onClick={() => (open ? close() : openMenu())}+ onKeyDown={onTriggerKeyDown}+ >+ <span className="select__trigger__value">{display()}</span>+ <span className="select__caret" aria-hidden><Icon name="caret" size={14} /></span>+ </button>+ {hint && <span className="hint">{hint}</span>}+ {open && createPortal(+ <div+ ref={menuRef}+ id={menuId}+ className="select__menu"+ data-placement={position?.placement ?? 'bottom'}+ style={menuStyle}+ onMouseDown={(e) => { if (e.target !== inputRef.current) e.preventDefault() }}+ onKeyDown={onMenuKeyDown}+ >+ {searchable && (+ <div className="select__search">+ <span className="select__search__icon"><Icon name="search" size={14} /></span>+ <input+ ref={inputRef}+ type="text"+ aria-controls={listId}+ aria-label={L('Filtrar opções', 'Filter options')}+ placeholder={L('Filtrar…', 'Filter…')}+ value={query}+ onChange={(e) => { setQuery(e.target.value); setHighlight(0) }}+ autoComplete="off"+ spellCheck={false}+ />+ </div>+ )}+ <div+ ref={listRef}+ role="listbox"+ id={listId}+ aria-label={accessibleName}+ aria-multiselectable={multiple || undefined}+ className="select__list"+ tabIndex={-1}+ >+ {matchCount === 0+ ? <div className="select__empty" role="status" aria-live="polite">{emptyText}</div>+ : renderList()}+ </div>+ </div>,+ document.body+ )}+ </div>+ )+}diff --git a/src/renderer/src/components/ui.tsx b/src/renderer/src/components/ui.tsxindex 8207f49..df48760 100644--- a/src/renderer/src/components/ui.tsx+++ b/src/renderer/src/components/ui.tsx@@ -32,6 +32,7 @@ const PATHS: Record<string, ReactNode> = {),x: <path d="M6 6l12 12M18 6 6 18" />,chevron: <path d="m9 6 6 6-6 6" />,+ caret: <path d="m6 9 6 6 6-6" />,shield: <path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6l-8-3Z" />,chart: <path d="M4 20V10M10 20V4M16 20v-7M22 20H2" />,plug: <path d="M9 2v6M15 2v6M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v5" />,diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.cssindex 9c8a10f..4edc5f2 100644--- a/src/renderer/src/styles.css+++ b/src/renderer/src/styles.css@@ -8463,3 +8463,110 @@ button.wk-pill.is-on { box-shadow: 0 0 0 1.5px var(--k); background: color-mix(i.device-qr { flex: none; width: 168px; height: 168px; padding: 6px; border-radius: 10px; background: #fff; }.device-qr svg { display: block; width: 100%; height: 100%; }@media (max-width: 560px) { .device-pair { flex-direction: column; align-items: center; } }++/* ---------- reusable select (shadcn-style) ---------- */+.select { position: relative; display: flex; flex-direction: column; width: 100%; min-width: 0; }+.select__trigger {+ position: relative;+ width: 100%;+ display: inline-flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ height: 36px;+ padding: 0 11px;+ border: 1px solid var(--border-strong);+ border-radius: var(--radius);+ background: var(--panel);+ color: var(--text);+ font: inherit;+ font-size: 13.5px;+ text-align: left;+ transition: var(--transition-ui);+ cursor: pointer;+}+.select__trigger:not(:disabled):hover { border-color: var(--border); background: var(--hover); }+.select__trigger:focus-visible {+ outline: none;+ box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft);+ border-color: var(--accent);+}+.select__trigger.is-disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg); }+.select__trigger.is-open { border-color: var(--accent); z-index: 40; }+.select__trigger__value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }+.select__placeholder { color: var(--text-3); }+.select__value { color: var(--text); font-weight: 500; }+.select__chip {+ display: inline-flex; align-items: center; gap: 6px;+ padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);+ font-size: 12px; font-weight: 500; margin-right: 4px; margin-bottom: 2px;+}+.select__caret { flex: none; display: inline-flex; color: var(--text-3); transition: transform var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out); }+.select__trigger:not(:disabled):hover .select__caret { color: var(--text-2, var(--text)); }+.select__trigger.is-open .select__caret { transform: rotate(180deg); color: var(--accent); }+/* Portaled to <body>; Select.tsx sets top/bottom/left/width/max-height from the trigger's rect. */+.select__menu {+ position: fixed;+ display: flex;+ flex-direction: column;+ box-sizing: border-box;+ padding: 4px;+ overflow: hidden;+ border: 1px solid var(--border-strong);+ border-radius: var(--radius);+ background: var(--panel);+ box-shadow: var(--shadow-lg);+ z-index: 1100;+ animation: pop var(--dur-fast) var(--ease-out) backwards;+ outline: none;+}+.select__menu[data-placement='top'] { --pop-y: -4px; }+.select__search {+ display: flex; align-items: center; gap: 8px;+ flex: none;+ margin: -4px -4px 4px; padding: 6px 10px; border-bottom: 1px solid var(--border);+ background: var(--bg);+}+.select__search__icon { color: var(--text-3); flex: none; }+.select__search__icon svg { width: 14px; height: 14px; }+.select__search input,+.select__search input:hover,+.select__search input:focus {+ flex: 1; min-width: 0; height: auto; box-shadow: none; border-radius: 0;+ border: 0; background: transparent; outline: none;+ font: inherit; font-size: 12.5px; color: var(--text);+ padding: 3px 0;+}+.select__list { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; outline: none; }+.select__list:focus { outline: none; }+.select__option {+ width: 100%; display: flex; align-items: center; gap: 8px;+ padding: 7px 8px; border: 0; border-radius: calc(var(--radius) - 3px); background: transparent; color: var(--text);+ font-size: 13px; text-align: left; cursor: pointer; transition: var(--transition-ui);+ user-select: none;+}+.select__option:hover, .select__option.is-active { background: var(--hover); color: var(--text); }+.select__option[aria-selected='true'] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }+.select__option.is-active[aria-selected='true'] { background: var(--accent); color: var(--accent-text); }+.select__check { flex: none; width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--panel); }+.select__check.is-on { background: var(--accent); border-color: var(--accent); }+.select__check svg { color: var(--accent-text); }+.select__tick { flex: none; display: inline-flex; color: currentColor; }+.select__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; font-weight: 500; }+.select__option__text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }+.select__option__text .select__label { font-weight: 500; }+.select__hint { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }+.select__section + .select__section { margin-top: 4px; border-top: 1px solid var(--border); }+/* Group title sticks to the top of the list while its section scrolls by. */+.select__group {+ position: sticky; top: 0; z-index: 1;+ padding: 7px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;+ text-transform: uppercase; color: var(--text-3); background: var(--panel);+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;+}+.select__empty {+ padding: 8px 10px; font-size: 12.5px; color: var(--text-3); text-align: center;+}+.field__required { color: var(--danger); margin-left: 2px; }++diff --git a/test/select-ui.test.tsx b/test/select-ui.test.tsxnew file mode 100644index 0000000..ad3fba5--- /dev/null+++ b/test/select-ui.test.tsx@@ -0,0 +1,41 @@+// The reusable Select: each one its own ids, so two on a page don't share a list or its options.+// (Esc inside a modal needs a browser's capture order, which linkedom doesn't have: checked in the app.)+import { parseHTML } from 'linkedom'+import { act } from 'react'+import type { Root } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it } from 'vitest'++const { window, document } = parseHTML('<!doctype html><html><body><div id="root"></div></body></html>')+Object.assign(globalThis, { window, document, HTMLElement: window.HTMLElement, Element: window.Element, Node: window.Node, IS_REACT_ACT_ENVIRONMENT: true })+// What linkedom doesn't lay out: a size for the trigger, frames and resizes that do nothing.+Object.assign(window, { innerWidth: 1280, innerHeight: 800 })+window.HTMLElement.prototype.getBoundingClientRect = () => ({ top: 100, bottom: 136, left: 100, right: 300, width: 200, height: 36, x: 100, y: 100, toJSON: () => ({}) })+Object.assign(globalThis, {+ requestAnimationFrame: (f: () => void) => setTimeout(f, 0) as unknown as number,+ cancelAnimationFrame: (id: number) => clearTimeout(id),+ ResizeObserver: class {+ observe(): void {}+ disconnect(): void {}+ }+})++const { createRoot } = await import('react-dom/client')+const { Select } = await import('../src/renderer/src/components/Select')++let root: Root+beforeEach(() => {+ root = createRoot(document.getElementById('root')!)+})+afterEach(() => act(() => root.unmount()))++describe('the Select', () => {+ it('gives each select its own ids', async () => {+ await act(async () => root.render(<><Select options={['a', 'b']} value="a" /><Select options={['c', 'd']} value="c" /></>))+ const triggers = [...document.querySelectorAll('.select__trigger')]+ for (const t of triggers) await act(async () => (t as HTMLElement).click())+ const lists = [...document.querySelectorAll('[role=listbox]')].map((l) => l.getAttribute('id'))+ expect(lists).toHaveLength(2)+ expect(new Set(lists).size).toBe(2)+ })++})