From 4354c9081b9431b4d4e8d9315b370b926eb5a120 Mon Sep 17 00:00:00 2001 From: Marc J Saint-jour <82672745+Junebugg1214@users.noreply.github.com> Date: Thu, 12 Mar 2026 20:32:58 -0400 Subject: [PATCH] fix: invalidate command cache on plugin registry updates --- src/auto-reply/commands-registry.data.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/auto-reply/commands-registry.data.ts b/src/auto-reply/commands-registry.data.ts index 1ac1538611a..bf22dc0f26c 100644 --- a/src/auto-reply/commands-registry.data.ts +++ b/src/auto-reply/commands-registry.data.ts @@ -1,4 +1,5 @@ import { listChannelDocks } from "../channels/dock.js"; +import { getActivePluginRegistryVersion } from "../plugins/runtime.js"; import { COMMAND_ARG_FORMATTERS } from "./commands-args.js"; import type { ChatCommandDefinition, @@ -124,6 +125,7 @@ function assertCommandRegistry(commands: ChatCommandDefinition[]): void { let cachedCommands: ChatCommandDefinition[] | null = null; let cachedNativeCommandSurfaces: Set | null = null; +let cachedPluginRegistryVersion: number | null = null; function buildChatCommands(): ChatCommandDefinition[] { const commands: ChatCommandDefinition[] = [ @@ -756,17 +758,20 @@ function buildChatCommands(): ChatCommandDefinition[] { } export function getChatCommands(): ChatCommandDefinition[] { - if (cachedCommands) { + const registryVersion = getActivePluginRegistryVersion(); + if (cachedCommands && cachedPluginRegistryVersion === registryVersion) { return cachedCommands; } const commands = buildChatCommands(); cachedCommands = commands; cachedNativeCommandSurfaces = null; + cachedPluginRegistryVersion = registryVersion; return commands; } export function getNativeCommandSurfaces(): Set { - if (cachedNativeCommandSurfaces) { + const registryVersion = getActivePluginRegistryVersion(); + if (cachedNativeCommandSurfaces && cachedPluginRegistryVersion === registryVersion) { return cachedNativeCommandSurfaces; } cachedNativeCommandSurfaces = new Set( @@ -774,5 +779,6 @@ export function getNativeCommandSurfaces(): Set { .filter((dock) => dock.capabilities.nativeCommands) .map((dock) => dock.id), ); + cachedPluginRegistryVersion = registryVersion; return cachedNativeCommandSurfaces; }