fix(regression): auto-enable channel setup discovery

This commit is contained in:
Tak Hoffman
2026-03-27 23:38:28 -05:00
parent 84af16e9c7
commit 37ab1513e0
2 changed files with 58 additions and 2 deletions

View File

@@ -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"]));
});
});

View File

@@ -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<ChannelChoice> {
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[]),