From 9abd7ceda23bdf1ebba2524ea06817dc361e676a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 15 Jan 2026 10:25:29 +0000 Subject: [PATCH] test: cover dynamic command arg menus --- src/auto-reply/commands-registry.args.test.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/auto-reply/commands-registry.args.test.ts b/src/auto-reply/commands-registry.args.test.ts index 91075a1bd..0d37e0aae 100644 --- a/src/auto-reply/commands-registry.args.test.ts +++ b/src/auto-reply/commands-registry.args.test.ts @@ -94,4 +94,63 @@ describe("commands registry args", () => { }); expect(menu).toBeNull(); }); + + it("resolves function-based choices with a default provider/model context", () => { + let seen: { provider: string; model: string; commandKey: string; argName: string } | null = + null; + + const command: ChatCommandDefinition = { + key: "think", + description: "think", + textAliases: [], + scope: "both", + argsMenu: "auto", + argsParsing: "positional", + args: [ + { + name: "level", + description: "level", + type: "string", + choices: ({ provider, model, command, arg }) => { + seen = { provider, model, commandKey: command.key, argName: arg.name }; + return ["low", "high"]; + }, + }, + ], + }; + + const menu = resolveCommandArgMenu({ command, args: undefined, cfg: {} as never }); + expect(menu?.arg.name).toBe("level"); + expect(menu?.choices).toEqual(["low", "high"]); + expect(seen?.commandKey).toBe("think"); + expect(seen?.argName).toBe("level"); + expect(seen?.provider).toBeTruthy(); + expect(seen?.model).toBeTruthy(); + }); + + it("does not show menus when args were provided as raw text only", () => { + const command: ChatCommandDefinition = { + key: "cost", + description: "cost", + textAliases: [], + scope: "both", + argsMenu: "auto", + argsParsing: "none", + args: [ + { + name: "mode", + description: "on or off", + type: "string", + choices: ["on", "off"], + }, + ], + }; + + const menu = resolveCommandArgMenu({ + command, + args: { raw: "on" }, + cfg: {} as never, + }); + expect(menu).toBeNull(); + }); });