mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
fix(slack): cap select option values
Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import { truncateSlackText } from "./truncate.js";
|
||||
|
||||
const SLACK_SECTION_TEXT_MAX = 3000;
|
||||
const SLACK_PLAIN_TEXT_MAX = 75;
|
||||
const SLACK_OPTION_VALUE_MAX = 75;
|
||||
const SLACK_OPTION_VALUE_MAX = 150;
|
||||
const SLACK_BUTTON_VALUE_MAX = 2000;
|
||||
const SLACK_BUTTON_URL_MAX = 3000;
|
||||
const SLACK_STATIC_SELECT_OPTIONS_MAX = 100;
|
||||
|
||||
@@ -177,7 +177,7 @@ vi.mock("./slash-commands.runtime.js", () => {
|
||||
if (params.command?.key === "reportlong") {
|
||||
return resolvePeriodMenu(params, [
|
||||
...fullReportPeriodChoices,
|
||||
{ value: "x".repeat(45), label: "long" },
|
||||
{ value: "x".repeat(100), label: "long" },
|
||||
]);
|
||||
}
|
||||
if (params.command?.key === "reportlongbutton") {
|
||||
@@ -632,8 +632,17 @@ describe("Slack native command argument menus", () => {
|
||||
});
|
||||
|
||||
it("uses static_select when encoded values fit Slack option limits", async () => {
|
||||
const firstElement = await getFirstActionElementFromCommand(reportLongHandler);
|
||||
const firstElement = (await getFirstActionElementFromCommand(reportLongHandler)) as
|
||||
| {
|
||||
type?: string;
|
||||
options?: Array<{ value?: string }>;
|
||||
confirm?: unknown;
|
||||
}
|
||||
| undefined;
|
||||
expect(firstElement?.type).toBe("static_select");
|
||||
const longOption = firstElement?.options?.find((option) => option.value?.includes("xxx"));
|
||||
expect(longOption?.value?.length).toBeGreaterThan(75);
|
||||
expect(longOption?.value?.length).toBeLessThanOrEqual(150);
|
||||
expect(firstElement?.confirm).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ const SLACK_COMMAND_ARG_OVERFLOW_MIN = 3;
|
||||
const SLACK_COMMAND_ARG_OVERFLOW_MAX = 5;
|
||||
const SLACK_COMMAND_ARG_SELECT_OPTIONS_MAX = 100;
|
||||
const SLACK_COMMAND_ARG_SELECT_OPTION_TEXT_MAX = 75;
|
||||
const SLACK_COMMAND_ARG_SELECT_OPTION_VALUE_MAX = 75;
|
||||
const SLACK_COMMAND_ARG_SELECT_OPTION_VALUE_MAX = 150;
|
||||
const SLACK_COMMAND_ARG_BUTTON_TEXT_MAX = 75;
|
||||
const SLACK_COMMAND_ARG_BUTTON_VALUE_MAX = 2000;
|
||||
const SLACK_COMMAND_ARG_CONFIRM_TEXT_MAX = 300;
|
||||
|
||||
@@ -89,8 +89,8 @@ describe("buildSlackInteractiveBlocks", () => {
|
||||
{
|
||||
type: "select",
|
||||
options: [
|
||||
{ label: "Allowed", value: "a".repeat(75) },
|
||||
{ label: "Too long", value: "b".repeat(76) },
|
||||
{ label: "Allowed", value: "a".repeat(150) },
|
||||
{ label: "Too long", value: "b".repeat(151) },
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -101,7 +101,7 @@ describe("buildSlackInteractiveBlocks", () => {
|
||||
};
|
||||
|
||||
expect(selectBlock.elements?.[0]?.options).toHaveLength(1);
|
||||
expect(selectBlock.elements?.[0]?.options?.[0]?.value).toBe("a".repeat(75));
|
||||
expect(selectBlock.elements?.[0]?.options?.[0]?.value).toBe("a".repeat(150));
|
||||
});
|
||||
|
||||
it("omits Slack select blocks when every option value exceeds Block Kit limits", () => {
|
||||
@@ -110,7 +110,7 @@ describe("buildSlackInteractiveBlocks", () => {
|
||||
blocks: [
|
||||
{
|
||||
type: "select",
|
||||
options: [{ label: "Too long", value: "x".repeat(76) }],
|
||||
options: [{ label: "Too long", value: "x".repeat(151) }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user