Файли
openidea/src/features/agents/providerOptions.ts
T
DIMAS FEBRIYANTO 986b0ade58 feat(agents): group model picker by provider and improve search (#486)
Agents can report model ids with nested provider paths, which made long rows that lost their provider context. The model picker now shows the short name under a provider heading with the remaining path as detail. Searchable Select matches several tokens across label, detail and hidden keywords, with fuzzy matching, and keeps a heading while one of its items matches.

Select now has an explicit section option, separate from disabled, so a heading can never be selected and a disabled option is not rendered as a heading. Existing section rows in provider options and Find in Files scopes use it. Keyboard navigation skips headings in filtered lists.

Co-authored-by: dimassfeb-09 <[email protected]>
2026-10-31 00:55:29 +08:00

29 рядки
1.3 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/** The New Task page's agent picker. */
import type { AgentProvider } from "@/bindings";
import type { tx as Tx } from "@/platform/i18n";
import type { SelectOption } from "@/ui";
/** Picker entry that opens Settings › Tools › Agents instead of choosing an agent. */
export const ADD_AGENT = "__addAgent__";
/**
* Installed agents first; the rest under a "Not installed" title, with the command they
* need; then More agents…. Registry agents show their version, or the update on offer.
*/
export function providerOptions(
providers: readonly AgentProvider[],
tx: typeof Tx,
icon: (id: string) => string,
): SelectOption[] {
const version = (p: AgentProvider) =>
p.source.kind !== "registry" ? undefined : p.source.update ? tx`${p.source.update} available` : p.source.version;
const installed = providers.filter((p) => p.installed);
const missing = providers.filter((p) => !p.installed);
return [
...installed.map((p) => ({ value: p.id, label: p.name, icon: icon(p.id), detail: version(p) })),
...(missing.length ? [{ value: "__missing__", label: tx("Not installed"), section: true }] : []),
...missing.map((p) => ({ value: p.id, label: p.name, icon: icon(p.id), detail: p.command })),
{ value: ADD_AGENT, label: tx("More agents…") },
];
}