fix: reopen configured search provider setup

This commit is contained in:
Tak Hoffman
2026-03-15 14:58:11 -05:00
parent ead2968bd6
commit ab26781b13
2 changed files with 89 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ vi.mock("./onboarding/plugin-install.js", () => ({
reloadOnboardingPluginRegistry,
}));
import { setupSearch } from "./onboard-search.js";
import { configureSearchProviderSelection, setupSearch } from "./onboard-search.js";
const runtime: RuntimeEnv = {
log: vi.fn(),
@@ -552,6 +552,93 @@ describe("setupSearch", () => {
);
});
it("reopens config when selecting an already configured provider in configure flow", async () => {
loadOpenClawPlugins.mockReturnValue({
searchProviders: [
{
pluginId: "tavily-search",
provider: {
id: "tavily",
name: "Tavily Search",
description: "Search the web using Tavily.",
setup: {
install: {
npmSpec: "@openclaw/tavily-search",
},
},
search: async () => ({ content: "ok" }),
},
},
],
plugins: [
{
id: "tavily-search",
name: "Tavily Search",
description: "Search the web using Tavily.",
origin: "bundled",
source: "/tmp/bundled/tavily-search",
configJsonSchema: {
type: "object",
required: ["apiKey"],
properties: {
apiKey: { type: "string", minLength: 1 },
},
},
configUiHints: {
apiKey: {
label: "Tavily API key",
sensitive: true,
placeholder: "tvly-...",
},
},
},
],
typedHooks: [],
});
const cfg: OpenClawConfig = {
tools: {
web: {
search: {
provider: "tavily",
enabled: true,
},
},
},
plugins: {
entries: {
"tavily-search": {
config: {
apiKey: "tvly-old",
},
},
},
},
};
const { prompter } = createPrompter({ textValue: "tvly-new" });
const result = await configureSearchProviderSelection(
cfg,
"tavily",
prompter,
"configure-provider",
);
expect((prompter.text as ReturnType<typeof vi.fn>).mock.calls).toEqual(
expect.arrayContaining([
[
expect.objectContaining({
message: "Tavily API key",
}),
],
]),
);
expect(result.plugins?.entries?.["tavily-search"]?.config).toEqual({
apiKey: "tvly-new",
});
expect(result.tools?.web?.search?.provider).toBe("tavily");
});
it("sets provider and key for perplexity", async () => {
const cfg: OpenClawConfig = {};
const { prompter } = createPrompter({

View File

@@ -1017,7 +1017,7 @@ export async function configureSearchProviderSelection(
});
return nextConfig;
}
if (selectedEntry.configured) {
if (selectedEntry.configured && intent === "switch-active") {
const result = preserveSearchProviderIntent(config, next, intent, selectedEntry.value);
await runAfterSearchProviderHooks({
hookRunner,