mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 23:30:20 +00:00
fix(slack): land #29032 /agentstatus alias from @maloqab
Land contributor PR #29032 by @maloqab with Slack native alias docs, integration tests, and changelog entry. Co-authored-by: maloqab <mitebaloqab@gmail.com>
This commit is contained in:
@@ -109,6 +109,17 @@ describe("commands registry", () => {
|
||||
expect(findCommandByNativeName("tts", "discord")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("renames status to agentstatus for slack", () => {
|
||||
const native = listNativeCommandSpecsForConfig(
|
||||
{ commands: { native: true } },
|
||||
{ provider: "slack" },
|
||||
);
|
||||
expect(native.find((spec) => spec.name === "agentstatus")).toBeTruthy();
|
||||
expect(native.find((spec) => spec.name === "status")).toBeFalsy();
|
||||
expect(findCommandByNativeName("agentstatus", "slack")?.key).toBe("status");
|
||||
expect(findCommandByNativeName("status", "slack")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps discord native command specs within slash-command limits", () => {
|
||||
const native = listNativeCommandSpecsForConfig(
|
||||
{ commands: { native: true } },
|
||||
|
||||
@@ -123,6 +123,11 @@ const NATIVE_NAME_OVERRIDES: Record<string, Record<string, string>> = {
|
||||
discord: {
|
||||
tts: "voice",
|
||||
},
|
||||
slack: {
|
||||
// Slack reserves /status — registering it returns "invalid name"
|
||||
// and invalidates the entire slash_commands manifest array.
|
||||
status: "agentstatus",
|
||||
},
|
||||
};
|
||||
|
||||
function resolveNativeName(command: ChatCommandDefinition, provider?: string): string | undefined {
|
||||
|
||||
@@ -8,6 +8,7 @@ vi.mock("../../auto-reply/commands-registry.js", () => {
|
||||
const reportExternalCommand = { key: "reportexternal", nativeName: "reportexternal" };
|
||||
const reportLongCommand = { key: "reportlong", nativeName: "reportlong" };
|
||||
const unsafeConfirmCommand = { key: "unsafeconfirm", nativeName: "unsafeconfirm" };
|
||||
const statusAliasCommand = { key: "status", nativeName: "status" };
|
||||
const periodArg = { name: "period", description: "period" };
|
||||
const baseReportPeriodChoices = [
|
||||
{ value: "day", label: "day" },
|
||||
@@ -73,6 +74,9 @@ vi.mock("../../auto-reply/commands-registry.js", () => {
|
||||
if (normalized === "unsafeconfirm") {
|
||||
return unsafeConfirmCommand;
|
||||
}
|
||||
if (normalized === "agentstatus") {
|
||||
return statusAliasCommand;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
listNativeCommandSpecsForConfig: () => [
|
||||
@@ -112,6 +116,12 @@ vi.mock("../../auto-reply/commands-registry.js", () => {
|
||||
acceptsArgs: true,
|
||||
args: [],
|
||||
},
|
||||
{
|
||||
name: "agentstatus",
|
||||
description: "Status",
|
||||
acceptsArgs: false,
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
parseCommandArgs: () => ({ values: {} }),
|
||||
resolveCommandArgMenu: (params: {
|
||||
@@ -394,6 +404,7 @@ describe("Slack native command argument menus", () => {
|
||||
let reportExternalHandler: (args: unknown) => Promise<void>;
|
||||
let reportLongHandler: (args: unknown) => Promise<void>;
|
||||
let unsafeConfirmHandler: (args: unknown) => Promise<void>;
|
||||
let agentStatusHandler: (args: unknown) => Promise<void>;
|
||||
let argMenuHandler: (args: unknown) => Promise<void>;
|
||||
let argMenuOptionsHandler: (args: unknown) => Promise<void>;
|
||||
|
||||
@@ -406,6 +417,7 @@ describe("Slack native command argument menus", () => {
|
||||
reportExternalHandler = requireHandler(harness.commands, "/reportexternal", "/reportexternal");
|
||||
reportLongHandler = requireHandler(harness.commands, "/reportlong", "/reportlong");
|
||||
unsafeConfirmHandler = requireHandler(harness.commands, "/unsafeconfirm", "/unsafeconfirm");
|
||||
agentStatusHandler = requireHandler(harness.commands, "/agentstatus", "/agentstatus");
|
||||
argMenuHandler = requireHandler(harness.actions, "openclaw_cmdarg", "arg-menu action");
|
||||
argMenuOptionsHandler = requireHandler(harness.options, "openclaw_cmdarg", "arg-menu options");
|
||||
});
|
||||
@@ -474,6 +486,11 @@ describe("Slack native command argument menus", () => {
|
||||
expect(call.ctx?.Body).toBe("/usage tokens");
|
||||
});
|
||||
|
||||
it("maps /agentstatus to /status when dispatching", async () => {
|
||||
await runCommandHandler(agentStatusHandler);
|
||||
expectSingleDispatchedSlashBody("/status");
|
||||
});
|
||||
|
||||
it("dispatches the command when a static_select option is chosen", async () => {
|
||||
await runArgMenuAction(argMenuHandler, {
|
||||
action: {
|
||||
|
||||
Reference in New Issue
Block a user