fix: prevent onboarding TUI auto-delivery (#791) (thanks @roshanasingh4)

This commit is contained in:
Peter Steinberger
2026-01-12 19:38:52 +00:00
parent 298c6eea1f
commit ddd4b55cf6
5 changed files with 79 additions and 6 deletions

View File

@@ -1,5 +1,9 @@
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { DEFAULT_BOOTSTRAP_FILENAME } from "../agents/workspace.js";
import type { RuntimeEnv } from "../runtime.js";
import { runOnboardingWizard } from "./onboarding.js";
import type { WizardPrompter } from "./prompts.js";
@@ -117,4 +121,64 @@ describe("runOnboardingWizard", () => {
expect(healthCommand).not.toHaveBeenCalled();
expect(runTui).not.toHaveBeenCalled();
});
it("launches TUI without auto-delivery when hatching", async () => {
runTui.mockClear();
const workspaceDir = await fs.mkdtemp(
path.join(os.tmpdir(), "clawdbot-onboard-"),
);
await fs.writeFile(
path.join(workspaceDir, DEFAULT_BOOTSTRAP_FILENAME),
"{}",
);
const confirm: WizardPrompter["confirm"] = vi.fn(async (opts) => {
if (opts.message === "Do you want to hatch your bot now?") return true;
return opts.initialValue ?? false;
});
const prompter: WizardPrompter = {
intro: vi.fn(async () => {}),
outro: vi.fn(async () => {}),
note: vi.fn(async () => {}),
select: vi.fn(async () => "quickstart"),
multiselect: vi.fn(async () => []),
text: vi.fn(async () => ""),
confirm,
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
};
const runtime: RuntimeEnv = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn((code: number) => {
throw new Error(`exit:${code}`);
}),
};
await runOnboardingWizard(
{
flow: "quickstart",
mode: "local",
workspace: workspaceDir,
authChoice: "skip",
skipProviders: true,
skipSkills: true,
skipHealth: true,
installDaemon: false,
},
runtime,
prompter,
);
expect(runTui).toHaveBeenCalledWith(
expect.objectContaining({
deliver: false,
message: "Wake up, my friend!",
}),
);
await fs.rm(workspaceDir, { recursive: true, force: true });
});
});