From 0b301e9af4fc7366704cd8d91c3e5711f364d467 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 26 Apr 2026 10:27:19 +0100 Subject: [PATCH] fix: avoid eager channel setup loading --- src/commands/onboard-channels.e2e.test.ts | 1 + src/flows/channel-setup.ts | 43 +++++++++-------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/commands/onboard-channels.e2e.test.ts b/src/commands/onboard-channels.e2e.test.ts index fa27b03c1ea..753dca3adbd 100644 --- a/src/commands/onboard-channels.e2e.test.ts +++ b/src/commands/onboard-channels.e2e.test.ts @@ -496,6 +496,7 @@ describe("setupChannels", () => { ({ setupChannels } = await import("./onboard-channels.js")); setMinimalOnboardingRegistryForTests(); catalogMocks.listChannelPluginCatalogEntries.mockReset(); + catalogMocks.listChannelPluginCatalogEntries.mockReturnValue([]); manifestRegistryMocks.loadPluginManifestRegistry.mockReset(); manifestRegistryMocks.loadPluginManifestRegistry.mockReturnValue({ plugins: [], diff --git a/src/flows/channel-setup.ts b/src/flows/channel-setup.ts index 65a36d51e8f..b3d80f484f3 100644 --- a/src/flows/channel-setup.ts +++ b/src/flows/channel-setup.ts @@ -1,10 +1,7 @@ import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { getBundledChannelSetupPlugin } from "../channels/plugins/bundled.js"; import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { - getChannelSetupPlugin, - listActiveChannelSetupPlugins, - listChannelSetupPlugins, -} from "../channels/plugins/setup-registry.js"; +import { listActiveChannelSetupPlugins } from "../channels/plugins/setup-registry.js"; import type { ChannelSetupPlugin, ChannelSetupWizardAdapter, @@ -113,7 +110,6 @@ export async function setupChannels( ): Promise { let next = cfg; const deferStatusUntilSelection = options?.deferStatusUntilSelection === true; - const includeRegistryBeforeSelection = !deferStatusUntilSelection; const forceAllowFromChannels = new Set(options?.forceAllowFromChannels ?? []); const accountOverrides: Partial> = { ...options?.accountIds, @@ -131,17 +127,10 @@ export async function setupChannels( return plugin; }; const getVisibleChannelPlugin = (channel: ChannelChoice): ChannelSetupPlugin | undefined => - scopedPluginsById.get(channel) ?? - activePluginsById.get(channel) ?? - (deferStatusUntilSelection ? undefined : getChannelSetupPlugin(channel)); - const listVisibleInstalledPlugins = (params?: { - includeRegistry?: boolean; - }): ChannelSetupPlugin[] => { - const includeRegistry = params?.includeRegistry ?? includeRegistryBeforeSelection; + scopedPluginsById.get(channel) ?? activePluginsById.get(channel); + const listVisibleInstalledPlugins = (): ChannelSetupPlugin[] => { const merged = new Map(); - const registryPlugins = includeRegistry - ? listChannelSetupPlugins() - : listActiveChannelSetupPlugins().map(rememberActivePlugin); + const registryPlugins = listActiveChannelSetupPlugins().map(rememberActivePlugin); for (const plugin of registryPlugins) { if (shouldShowChannelInSetup(plugin.meta)) { merged.set(plugin.id, plugin); @@ -154,10 +143,10 @@ export async function setupChannels( } return Array.from(merged.values()); }; - const resolveVisibleChannelEntries = (params?: { includeRegistry?: boolean }) => + const resolveVisibleChannelEntries = () => resolveChannelSetupEntries({ cfg: next, - installedPlugins: listVisibleInstalledPlugins(params), + installedPlugins: listVisibleInstalledPlugins(), workspaceDir: resolveWorkspaceDir(), }); const loadScopedChannelPlugin = async ( @@ -189,6 +178,11 @@ export async function setupChannels( rememberScopedPlugin(plugin); return plugin; } + const bundledPlugin = getBundledChannelSetupPlugin(channel); + if (bundledPlugin) { + rememberScopedPlugin(bundledPlugin); + return bundledPlugin; + } return undefined; }; const getVisibleSetupFlowAdapter = (channel: ChannelChoice) => { @@ -200,6 +194,7 @@ export async function setupChannels( }; const preloadConfiguredExternalPlugins = async () => { // Keep setup memory bounded by snapshot-loading only configured external plugins. + listVisibleInstalledPlugins(); const workspaceDir = resolveWorkspaceDir(); const preloadTasks: Promise[] = []; // Security: keep trusted workspace overrides eligible during setup while @@ -246,9 +241,7 @@ export async function setupChannels( return cfg; } - const primerChannels = resolveVisibleChannelEntries({ - includeRegistry: includeRegistryBeforeSelection, - }).entries.map((entry) => ({ + const primerChannels = resolveVisibleChannelEntries().entries.map((entry) => ({ id: entry.id, label: entry.meta.label, blurb: entry.meta.blurb, @@ -314,9 +307,7 @@ export async function setupChannels( }; const getChannelEntries = () => { - const resolved = resolveVisibleChannelEntries({ - includeRegistry: includeRegistryBeforeSelection, - }); + const resolved = resolveVisibleChannelEntries(); return { entries: resolved.entries, catalogById: resolved.installableCatalogById, @@ -657,9 +648,7 @@ export async function setupChannels( const selectedLines = resolveChannelSelectionNoteLines({ cfg: next, - installedPlugins: listVisibleInstalledPlugins({ - includeRegistry: includeRegistryBeforeSelection, - }), + installedPlugins: listVisibleInstalledPlugins(), selection, }); if (selectedLines.length > 0) {