fix(onboarding): move web search hint to end

This commit is contained in:
Peter Steinberger
2026-01-15 07:50:00 +00:00
parent 5cd48bbe7d
commit 0ac5480034
4 changed files with 129 additions and 40 deletions

View File

@@ -347,6 +347,27 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
);
}
const webSearchKey = (nextConfig.tools?.web?.search?.apiKey ?? "").trim();
const webSearchEnv = (process.env.BRAVE_API_KEY ?? "").trim();
const hasWebSearchKey = Boolean(webSearchKey || webSearchEnv);
await prompter.note(
hasWebSearchKey
? [
"Web search is ready.",
webSearchKey
? "Brave API key: stored in config (tools.web.search.apiKey)."
: "Brave API key: provided via BRAVE_API_KEY env var.",
"Docs: https://docs.clawd.bot/tools/web",
].join("\n")
: [
"Recommended: set up a Brave Search API key for web_search.",
"Easiest: clawdbot configure --section web (stores tools.web.search.apiKey).",
"Env alternative: BRAVE_API_KEY (gateway environment).",
"Docs: https://docs.clawd.bot/tools/web",
].join("\n"),
"Web search (optional)",
);
await prompter.outro(
controlUiOpened
? "Onboarding complete. Dashboard opened with your token; keep that tab to control Clawdbot."

View File

@@ -226,4 +226,55 @@ describe("runOnboardingWizard", () => {
await fs.rm(workspaceDir, { recursive: true, force: true });
});
it("shows the web search hint at the end of onboarding", async () => {
const prevBraveKey = process.env.BRAVE_API_KEY;
delete process.env.BRAVE_API_KEY;
try {
const note: WizardPrompter["note"] = vi.fn(async () => {});
const prompter: WizardPrompter = {
intro: vi.fn(async () => {}),
outro: vi.fn(async () => {}),
note,
select: vi.fn(async () => "quickstart"),
multiselect: vi.fn(async () => []),
text: vi.fn(async () => ""),
confirm: vi.fn(async () => false),
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
};
const runtime: RuntimeEnv = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(),
};
await runOnboardingWizard(
{
acceptRisk: true,
flow: "quickstart",
authChoice: "skip",
installDaemon: false,
skipProviders: true,
skipSkills: true,
skipHealth: true,
skipUi: true,
},
runtime,
prompter,
);
const calls = (note as unknown as { mock: { calls: unknown[][] } }).mock.calls;
expect(calls.length).toBeGreaterThan(0);
const lastCall = calls[calls.length - 1];
expect(lastCall?.[1]).toBe("Web search (optional)");
} finally {
if (prevBraveKey === undefined) {
delete process.env.BRAVE_API_KEY;
} else {
process.env.BRAVE_API_KEY = prevBraveKey;
}
}
});
});

View File

@@ -75,15 +75,6 @@ export async function runOnboardingWizard(
) {
printWizardHeader(runtime);
await prompter.intro("Clawdbot onboarding");
await prompter.note(
[
"Recommended: set up a Brave Search API key for web_search.",
"Easiest: clawdbot configure --section web (stores tools.web.search.apiKey).",
"Env alternative: BRAVE_API_KEY (gateway environment).",
"Docs: https://docs.clawd.bot/tools/web",
].join("\n"),
"Web search (optional)",
);
await requireRiskAcknowledgement({ opts, prompter });
const snapshot = await readConfigFileSnapshot();