From 37ab1513e055ae271b93320a085dd3df04428d07 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:38:28 -0500 Subject: [PATCH] fix(regression): auto-enable channel setup discovery --- src/commands/channel-setup/discovery.test.ts | 51 ++++++++++++++++++++ src/commands/channel-setup/discovery.ts | 9 +++- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/commands/channel-setup/discovery.test.ts diff --git a/src/commands/channel-setup/discovery.test.ts b/src/commands/channel-setup/discovery.test.ts new file mode 100644 index 00000000000..af497b7b262 --- /dev/null +++ b/src/commands/channel-setup/discovery.test.ts @@ -0,0 +1,51 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const loadPluginManifestRegistry = vi.hoisted(() => vi.fn()); +const applyPluginAutoEnable = vi.hoisted(() => vi.fn(({ config }) => ({ config, changes: [] }))); + +vi.mock("../../plugins/manifest-registry.js", () => ({ + loadPluginManifestRegistry: (...args: unknown[]) => loadPluginManifestRegistry(...args), +})); + +vi.mock("../../config/plugin-auto-enable.js", () => ({ + applyPluginAutoEnable: (...args: unknown[]) => applyPluginAutoEnable(...args), +})); + +import { listManifestInstalledChannelIds } from "./discovery.js"; + +describe("listManifestInstalledChannelIds", () => { + beforeEach(() => { + loadPluginManifestRegistry.mockReset(); + applyPluginAutoEnable.mockReset().mockImplementation(({ config }) => ({ config, changes: [] })); + }); + + it("uses the auto-enabled config snapshot for manifest discovery", () => { + const autoEnabledConfig = { + channels: { slack: { enabled: true } }, + plugins: { allow: ["slack"] }, + autoEnabled: true, + }; + applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: ["slack"] }); + loadPluginManifestRegistry.mockReturnValue({ + plugins: [{ id: "slack", channels: ["slack"] }], + diagnostics: [], + }); + + const installedIds = listManifestInstalledChannelIds({ + cfg: {} as never, + workspaceDir: "/tmp/workspace", + env: { OPENCLAW_HOME: "/tmp/home" } as NodeJS.ProcessEnv, + }); + + expect(applyPluginAutoEnable).toHaveBeenCalledWith({ + config: {}, + env: { OPENCLAW_HOME: "/tmp/home" }, + }); + expect(loadPluginManifestRegistry).toHaveBeenCalledWith({ + config: autoEnabledConfig, + workspaceDir: "/tmp/workspace", + env: { OPENCLAW_HOME: "/tmp/home" }, + }); + expect(installedIds).toEqual(new Set(["slack"])); + }); +}); diff --git a/src/commands/channel-setup/discovery.ts b/src/commands/channel-setup/discovery.ts index 8ae5f16f800..ffbb137ebd4 100644 --- a/src/commands/channel-setup/discovery.ts +++ b/src/commands/channel-setup/discovery.ts @@ -6,6 +6,7 @@ import { import type { ChannelMeta, ChannelPlugin } from "../../channels/plugins/types.js"; import { listChatChannels } from "../../channels/registry.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { applyPluginAutoEnable } from "../../config/plugin-auto-enable.js"; import { loadPluginManifestRegistry } from "../../plugins/manifest-registry.js"; import type { ChannelChoice } from "../onboard-types.js"; @@ -31,10 +32,14 @@ export function listManifestInstalledChannelIds(params: { workspaceDir?: string; env?: NodeJS.ProcessEnv; }): Set { - const workspaceDir = resolveWorkspaceDir(params.cfg, params.workspaceDir); + const resolvedConfig = applyPluginAutoEnable({ + config: params.cfg, + env: params.env ?? process.env, + }).config; + const workspaceDir = resolveWorkspaceDir(resolvedConfig, params.workspaceDir); return new Set( loadPluginManifestRegistry({ - config: params.cfg, + config: resolvedConfig, workspaceDir, env: params.env ?? process.env, }).plugins.flatMap((plugin) => plugin.channels as ChannelChoice[]),