Configure: make model picker allowlist searchable

This commit is contained in:
Benjamin Jesuiter
2026-02-17 08:36:43 +01:00
parent 900b97e3c7
commit 01fcac0726
4 changed files with 12 additions and 5 deletions

View File

@@ -142,8 +142,10 @@ describe("promptModelAllowlist", () => {
await promptModelAllowlist({ config, prompter });
const options = multiselect.mock.calls[0]?.[0]?.options ?? [];
const call = multiselect.mock.calls[0]?.[0];
const options = call?.options ?? [];
expectRouterModelFiltering(options as Array<{ value: string }>);
expect(call?.searchable).toBe(true);
});
it("filters to allowed keys when provided", async () => {

View File

@@ -424,6 +424,7 @@ export async function promptModelAllowlist(params: {
message: params.message ?? "Models in /model picker (multi-select)",
options,
initialValues: initialKeys.length > 0 ? initialKeys : undefined,
searchable: true,
});
const selected = normalizeModelKeys(selection.map((value) => String(value)));
if (selected.length > 0) {

View File

@@ -1,4 +1,5 @@
import {
autocompleteMultiselect,
cancel,
confirm,
intro,
@@ -47,9 +48,10 @@ export function createClackPrompter(): WizardPrompter {
initialValue: params.initialValue,
}),
),
multiselect: async (params) =>
guardCancel(
await multiselect({
multiselect: async (params) => {
const prompt = params.searchable ? autocompleteMultiselect : multiselect;
return guardCancel(
await prompt({
message: stylePromptMessage(params.message),
options: params.options.map((opt) => {
const base = { value: opt.value, label: opt.label };
@@ -57,7 +59,8 @@ export function createClackPrompter(): WizardPrompter {
}) as Option<(typeof params.options)[number]["value"]>[],
initialValues: params.initialValues,
}),
),
);
},
text: async (params) => {
const validate = params.validate;
return guardCancel(

View File

@@ -14,6 +14,7 @@ export type WizardMultiSelectParams<T = string> = {
message: string;
options: Array<WizardSelectOption<T>>;
initialValues?: T[];
searchable?: boolean;
};
export type WizardTextParams = {