mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
wizard: support searchable select, restore hint in search haystack
This commit is contained in:
committed by
Peter Steinberger
parent
7752e3b30f
commit
9fd0f7cd34
@@ -30,6 +30,7 @@ export async function promptAuthChoiceGrouped(params: {
|
||||
const providerSelection = (await params.prompter.select({
|
||||
message: "Model/auth provider",
|
||||
options: providerOptions,
|
||||
searchable: true,
|
||||
})) as string;
|
||||
|
||||
if (providerSelection === "skip") {
|
||||
|
||||
@@ -598,6 +598,7 @@ export async function setupChannels(
|
||||
},
|
||||
],
|
||||
initialValue: quickstartDefault,
|
||||
searchable: true,
|
||||
});
|
||||
if (choice !== "__skip__") {
|
||||
await handleChannelChoice(choice);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
autocomplete,
|
||||
autocompleteMultiselect,
|
||||
cancel,
|
||||
confirm,
|
||||
@@ -62,17 +63,31 @@ export function createClackPrompter(): WizardPrompter {
|
||||
note: async (message, title) => {
|
||||
emitNote(message, title);
|
||||
},
|
||||
select: async (params) =>
|
||||
guardCancel(
|
||||
select: async (params) => {
|
||||
const options = params.options.map((opt) => {
|
||||
const base = { value: opt.value, label: opt.label };
|
||||
return opt.hint === undefined ? base : { ...base, hint: stylePromptHint(opt.hint) };
|
||||
}) as Option<(typeof params.options)[number]["value"]>[];
|
||||
|
||||
if (params.searchable) {
|
||||
return guardCancel(
|
||||
await autocomplete({
|
||||
message: stylePromptMessage(params.message),
|
||||
options,
|
||||
initialValue: params.initialValue,
|
||||
filter: tokenizedOptionFilter,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return guardCancel(
|
||||
await select({
|
||||
message: stylePromptMessage(params.message),
|
||||
options: params.options.map((opt) => {
|
||||
const base = { value: opt.value, label: opt.label };
|
||||
return opt.hint === undefined ? base : { ...base, hint: stylePromptHint(opt.hint) };
|
||||
}) as Option<(typeof params.options)[number]["value"]>[],
|
||||
options,
|
||||
initialValue: params.initialValue,
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
multiselect: async (params) => {
|
||||
const options = params.options.map((opt) => {
|
||||
const base = { value: opt.value, label: opt.label };
|
||||
@@ -132,7 +147,11 @@ export function createClackPrompter(): WizardPrompter {
|
||||
},
|
||||
stop: (message) => {
|
||||
osc.done();
|
||||
spin.stop(message);
|
||||
if (message === undefined) {
|
||||
spin.clear();
|
||||
} else {
|
||||
spin.stop(message);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ export type WizardSelectParams<T = string> = {
|
||||
message: string;
|
||||
options: Array<WizardSelectOption<T>>;
|
||||
initialValue?: T;
|
||||
searchable?: boolean;
|
||||
};
|
||||
|
||||
export type WizardMultiSelectParams<T = string> = {
|
||||
|
||||
Reference in New Issue
Block a user