fix(slack): cap select option values · openclaw/openclaw@c6c518e
clawsweeper
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,7 @@ import { truncateSlackText } from "./truncate.js";
|
13 | 13 | |
14 | 14 | const SLACK_SECTION_TEXT_MAX = 3000; |
15 | 15 | const SLACK_PLAIN_TEXT_MAX = 75; |
16 | | -const SLACK_OPTION_VALUE_MAX = 75; |
| 16 | +const SLACK_OPTION_VALUE_MAX = 150; |
17 | 17 | const SLACK_BUTTON_VALUE_MAX = 2000; |
18 | 18 | const SLACK_BUTTON_URL_MAX = 3000; |
19 | 19 | const SLACK_STATIC_SELECT_OPTIONS_MAX = 100; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -177,7 +177,7 @@ vi.mock("./slash-commands.runtime.js", () => {
|
177 | 177 | if (params.command?.key === "reportlong") { |
178 | 178 | return resolvePeriodMenu(params, [ |
179 | 179 | ...fullReportPeriodChoices, |
180 | | -{ value: "x".repeat(45), label: "long" }, |
| 180 | +{ value: "x".repeat(100), label: "long" }, |
181 | 181 | ]); |
182 | 182 | } |
183 | 183 | if (params.command?.key === "reportlongbutton") { |
@@ -632,8 +632,17 @@ describe("Slack native command argument menus", () => {
|
632 | 632 | }); |
633 | 633 | |
634 | 634 | it("uses static_select when encoded values fit Slack option limits", async () => { |
635 | | -const firstElement = await getFirstActionElementFromCommand(reportLongHandler); |
| 635 | +const firstElement = (await getFirstActionElementFromCommand(reportLongHandler)) as |
| 636 | +| { |
| 637 | +type?: string; |
| 638 | +options?: Array<{ value?: string }>; |
| 639 | +confirm?: unknown; |
| 640 | +} |
| 641 | +| undefined; |
636 | 642 | expect(firstElement?.type).toBe("static_select"); |
| 643 | +const longOption = firstElement?.options?.find((option) => option.value?.includes("xxx")); |
| 644 | +expect(longOption?.value?.length).toBeGreaterThan(75); |
| 645 | +expect(longOption?.value?.length).toBeLessThanOrEqual(150); |
637 | 646 | expect(firstElement?.confirm).toBeTruthy(); |
638 | 647 | }); |
639 | 648 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -54,7 +54,7 @@ const SLACK_COMMAND_ARG_OVERFLOW_MIN = 3;
|
54 | 54 | const SLACK_COMMAND_ARG_OVERFLOW_MAX = 5; |
55 | 55 | const SLACK_COMMAND_ARG_SELECT_OPTIONS_MAX = 100; |
56 | 56 | const SLACK_COMMAND_ARG_SELECT_OPTION_TEXT_MAX = 75; |
57 | | -const SLACK_COMMAND_ARG_SELECT_OPTION_VALUE_MAX = 75; |
| 57 | +const SLACK_COMMAND_ARG_SELECT_OPTION_VALUE_MAX = 150; |
58 | 58 | const SLACK_COMMAND_ARG_BUTTON_TEXT_MAX = 75; |
59 | 59 | const SLACK_COMMAND_ARG_BUTTON_VALUE_MAX = 2000; |
60 | 60 | const SLACK_COMMAND_ARG_CONFIRM_TEXT_MAX = 300; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -89,8 +89,8 @@ describe("buildSlackInteractiveBlocks", () => {
|
89 | 89 | { |
90 | 90 | type: "select", |
91 | 91 | options: [ |
92 | | -{ label: "Allowed", value: "a".repeat(75) }, |
93 | | -{ label: "Too long", value: "b".repeat(76) }, |
| 92 | +{ label: "Allowed", value: "a".repeat(150) }, |
| 93 | +{ label: "Too long", value: "b".repeat(151) }, |
94 | 94 | ], |
95 | 95 | }, |
96 | 96 | ], |
@@ -101,7 +101,7 @@ describe("buildSlackInteractiveBlocks", () => {
|
101 | 101 | }; |
102 | 102 | |
103 | 103 | expect(selectBlock.elements?.[0]?.options).toHaveLength(1); |
104 | | -expect(selectBlock.elements?.[0]?.options?.[0]?.value).toBe("a".repeat(75)); |
| 104 | +expect(selectBlock.elements?.[0]?.options?.[0]?.value).toBe("a".repeat(150)); |
105 | 105 | }); |
106 | 106 | |
107 | 107 | it("omits Slack select blocks when every option value exceeds Block Kit limits", () => { |
@@ -110,7 +110,7 @@ describe("buildSlackInteractiveBlocks", () => {
|
110 | 110 | blocks: [ |
111 | 111 | { |
112 | 112 | type: "select", |
113 | | -options: [{ label: "Too long", value: "x".repeat(76) }], |
| 113 | +options: [{ label: "Too long", value: "x".repeat(151) }], |
114 | 114 | }, |
115 | 115 | ], |
116 | 116 | }), |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。