mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
Configure: make model picker allowlist searchable
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -14,6 +14,7 @@ export type WizardMultiSelectParams<T = string> = {
|
||||
message: string;
|
||||
options: Array<WizardSelectOption<T>>;
|
||||
initialValues?: T[];
|
||||
searchable?: boolean;
|
||||
};
|
||||
|
||||
export type WizardTextParams = {
|
||||
|
||||
Reference in New Issue
Block a user