fix(wizard): handle undefined setup prompt text

Co-authored-by: mm1ord <101250822+mm1ord@users.noreply.github.com>

Co-authored-by: Nikil Viswanathan <1175050+nikilster@users.noreply.github.com>

Co-authored-by: tobemorelucky <205934056+tobemorelucky@users.noreply.github.com>

Co-authored-by: dagangtj <65108318+dagangtj@users.noreply.github.com>

Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
clawsweeper
2026-06-04 10:45:56 +00:00
parent da974c68a1
commit a9b777210b
2 changed files with 13 additions and 5 deletions

View File

@@ -75,6 +75,17 @@ describe("createClackPrompter", () => {
expect(result).toBe("");
});
it("preserves string clack text results without trimming", async () => {
vi.mocked(text).mockResolvedValueOnce(" Alice ");
const prompter = createClackPrompter();
const result = await prompter.text({
message: "Name",
});
expect(result).toBe(" Alice ");
});
it("normalizes non-string clack password results to empty strings", async () => {
vi.mocked(password).mockResolvedValueOnce({ cancelled: true } as never);
const prompter = createClackPrompter();

View File

@@ -13,10 +13,7 @@ import {
spinner,
text,
} from "@clack/prompts";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "@openclaw/normalization-core/string-coerce";
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
import { stripAnsi } from "../../packages/terminal-core/src/ansi.js";
import { note as emitNote } from "../../packages/terminal-core/src/note.js";
import {
@@ -54,7 +51,7 @@ function buildOptionSearchText<T>(option: Option<T>): string {
}
function normalizeTextPromptResult(value: unknown): string {
return normalizeOptionalString(value) ?? "";
return typeof value === "string" ? value : "";
}
export function tokenizedOptionFilter<T>(search: string, option: Option<T>): boolean {