wizard: support searchable select, restore hint in search haystack

This commit is contained in:
Patrick Erichsen
2026-04-20 19:42:41 -07:00
committed by Peter Steinberger
parent 7752e3b30f
commit 9fd0f7cd34
4 changed files with 30 additions and 8 deletions

View File

@@ -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") {

View File

@@ -598,6 +598,7 @@ export async function setupChannels(
},
],
initialValue: quickstartDefault,
searchable: true,
});
if (choice !== "__skip__") {
await handleChannelChoice(choice);

View File

@@ -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);
}
},
};
},

View File

@@ -8,6 +8,7 @@ export type WizardSelectParams<T = string> = {
message: string;
options: Array<WizardSelectOption<T>>;
initialValue?: T;
searchable?: boolean;
};
export type WizardMultiSelectParams<T = string> = {