From f8386668ea137116e0f4605f4a3a6e5048f345fd Mon Sep 17 00:00:00 2001 From: Marc J Saint-jour <82672745+Junebugg1214@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:41:24 -0400 Subject: [PATCH] fix: decouple command cache version tracking --- src/auto-reply/commands-registry.test.ts | 80 +++++++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/src/auto-reply/commands-registry.test.ts b/src/auto-reply/commands-registry.test.ts index 326211560ee..400cccd32ad 100644 --- a/src/auto-reply/commands-registry.test.ts +++ b/src/auto-reply/commands-registry.test.ts @@ -1,6 +1,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; +import { getNativeCommandSurfaces } from "./commands-registry.data.js"; import { buildCommandText, buildCommandTextFromArgs, @@ -198,15 +199,76 @@ describe("commands registry", () => { ]); }); - it("registers fast mode as a first-class options command", () => { - const fast = listChatCommands().find((command) => command.key === "fast"); - expect(fast).toMatchObject({ - nativeName: "fast", - textAliases: ["/fast"], - category: "options", - }); - const modeArg = fast?.args?.find((arg) => arg.name === "mode"); - expect(modeArg?.choices).toEqual(["status", "on", "off"]); + it("invalidates cached command lists after plugin registry updates", () => { + const before = listChatCommands(); + expect(before.find((command) => command.key === "dock:msteams")).toBeFalsy(); + + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "test-plugin", + source: "test", + plugin: { + id: "msteams", + meta: { + id: "msteams", + label: "Microsoft Teams", + selectionLabel: "Microsoft Teams", + docsPath: "/channels/msteams", + blurb: "test stub.", + }, + capabilities: { + chatTypes: ["direct"], + nativeCommands: true, + }, + config: { + listAccountIds: () => ["default"], + resolveAccount: () => ({}), + }, + }, + }, + ]), + ); + + const after = listChatCommands(); + expect(after.find((command) => command.key === "dock:msteams")).toBeTruthy(); + }); + + it("does not let native-surface cache refresh mask stale chat command cache", () => { + const before = listChatCommands(); + expect(before.find((command) => command.key === "dock:msteams")).toBeFalsy(); + + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "test-plugin", + source: "test", + plugin: { + id: "msteams", + meta: { + id: "msteams", + label: "Microsoft Teams", + selectionLabel: "Microsoft Teams", + docsPath: "/channels/msteams", + blurb: "test stub.", + }, + capabilities: { + chatTypes: ["direct"], + nativeCommands: true, + }, + config: { + listAccountIds: () => ["default"], + resolveAccount: () => ({}), + }, + }, + }, + ]), + ); + + expect(getNativeCommandSurfaces().has("msteams")).toBe(true); + + const after = listChatCommands(); + expect(after.find((command) => command.key === "dock:msteams")).toBeTruthy(); }); it("detects known text commands", () => {