mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 08:07:49 +00:00
Select gains an optional search box that filters its options; the agent model pickers use it, so long model lists can be filtered instead of scrolled. Keyboard navigation and type-ahead work on the filtered list, and the popup keeps its width while filtering. Co-authored-by: dimassfeb-09 <62858781+dimassfeb-09@users.noreply.github.com>
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
/**
|
|
* Model, mode, approvals and thinking-effort dropdowns for a composer's bottom row.
|
|
* Modes and approvals use icons; levels are plain text.
|
|
*/
|
|
import type { AgentConfigOption } from "@/bindings";
|
|
import { useTx } from "@/platform/i18n";
|
|
import { Select } from "@/ui";
|
|
import { mainOptions, modeIcon } from "./composerModel";
|
|
import styles from "./Composer.module.css";
|
|
|
|
export function ConfigPickers({
|
|
config,
|
|
values,
|
|
onChange,
|
|
}: {
|
|
config: readonly AgentConfigOption[];
|
|
/** Chosen values that override `current`, by option id. */
|
|
values?: Record<string, string>;
|
|
onChange: (option: string, value: string) => void;
|
|
}) {
|
|
const tx = useTx();
|
|
return (
|
|
<>
|
|
{mainOptions(config).map((o) => {
|
|
const isMode = o.category === "mode";
|
|
const value = values?.[o.id] ?? o.current ?? null;
|
|
return (
|
|
<Select
|
|
key={o.id}
|
|
variant="ghost"
|
|
aria-label={o.name}
|
|
value={value}
|
|
placeholder={tx(o.name)}
|
|
options={o.values.map((v) => ({
|
|
value: v.value,
|
|
label: v.name,
|
|
icon:
|
|
o.category === "approval"
|
|
? v.value === "bypass"
|
|
? "unlock"
|
|
: "lock"
|
|
: isMode
|
|
? modeIcon(v.value)
|
|
: undefined,
|
|
detail: v.description ?? undefined,
|
|
}))}
|
|
searchable={o.category === "model"}
|
|
onChange={(v) => onChange(o.id, v)}
|
|
// Effort and other levels say what they are: "Effort Medium".
|
|
renderValue={
|
|
o.category === "thought_level"
|
|
? (current) => (
|
|
<span className={styles.pickerValue}>
|
|
<span className={styles.pickerName}>{o.name}</span>
|
|
{current?.label ?? tx("Default")}
|
|
</span>
|
|
)
|
|
: undefined
|
|
}
|
|
/>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|