Skip to content

Commit 42112dd

Browse files
authored
fix(feishu): preserve commands in select fallback cards (#130515)
1 parent 4a40d55 commit 42112dd

3 files changed

Lines changed: 45 additions & 37 deletions

File tree

‎docs/plugins/message-presentation.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ keeping opaque callback data private:
558558
`webApp` / `web_app`** inputs render the URL text alongside the button label,
559559
since the URL is user-facing. Hosted-widget-only actions render label-only on
560560
channels without a native widget launch.
561-
- **Select options** render as label-only. The underlying option value is not
562-
exposed in fallback text.
561+
- **Select options** follow the same rule: typed commands include the command
562+
text; opaque callback actions and legacy values remain label-only.
563563

564564
Channel adapters that add manual-command guidance in their fallback UI (e.g.
565565
Feishu document-comment instructions) must derive the command-present check

‎extensions/feishu/src/channel.test.ts‎

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,40 +1565,49 @@ describe("feishuPlugin actions", () => {
15651565
]);
15661566
});
15671567

1568-
it("renders presentation select labels into the card fallback", async () => {
1569-
sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_card", chatId: "oc_group_1" });
1568+
it.each(["send", "thread-reply"] as const)(
1569+
"preserves select commands in the %s card fallback without exposing callback values",
1570+
async (action) => {
1571+
sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_card", chatId: "oc_group_1" });
15701572

1571-
await feishuPlugin.actions?.handleAction?.({
1572-
action: "send",
1573-
params: {
1574-
to: "chat:oc_group_1",
1575-
presentation: {
1576-
blocks: [
1577-
{
1578-
type: "select",
1579-
placeholder: "Pick one",
1580-
options: [{ label: "Option A", value: "a" }],
1581-
},
1582-
],
1573+
await feishuPlugin.actions?.handleAction?.({
1574+
action,
1575+
params: {
1576+
to: "chat:oc_group_1",
1577+
...(action === "thread-reply" ? { messageId: "om_root" } : {}),
1578+
presentation: {
1579+
blocks: [
1580+
{
1581+
type: "select",
1582+
placeholder: "Pick <one> & continue",
1583+
options: [
1584+
{ label: "Status <one>", action: { type: "command", command: "/status" } },
1585+
{ label: "Callback", action: { type: "callback", value: "/opaque-callback" } },
1586+
{ label: "Legacy", value: "/opaque-legacy" },
1587+
],
1588+
},
1589+
],
1590+
},
15831591
},
1584-
},
1585-
cfg,
1586-
accountId: undefined,
1587-
toolContext: {},
1588-
} as never);
1592+
cfg,
1593+
accountId: undefined,
1594+
toolContext: {},
1595+
} as never);
15891596

1590-
const sendCardArgs = requireRecord(
1591-
mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
1592-
"send card args",
1593-
);
1594-
const card = requireRecord(sendCardArgs.card, "card");
1595-
expect(requireRecord(card.body, "card body").elements).toEqual([
1596-
{
1597-
tag: "markdown",
1598-
content: "Pick one:\n- Option A",
1599-
},
1600-
]);
1601-
});
1597+
const sendCardArgs = requireRecord(
1598+
mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
1599+
"send card args",
1600+
);
1601+
const card = requireRecord(sendCardArgs.card, "card");
1602+
expect(requireRecord(card.body, "card body").elements).toEqual([
1603+
{
1604+
tag: "markdown",
1605+
content:
1606+
"Pick &lt;one&gt; &amp; continue:\n- Status &lt;one&gt;: `/status`\n- Callback\n- Legacy",
1607+
},
1608+
]);
1609+
},
1610+
);
16021611

16031612
it.each(
16041613
[

‎extensions/feishu/src/presentation-card.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,12 @@ function buildFeishuCardElementsForBlock(
229229
},
230230
];
231231
}
232-
const labels = block.options.map((option) => `- ${option.label}`).join("\n");
233232
return [
234233
{
235234
tag: "markdown",
236-
content: `${escapeFeishuCardMarkdownText(
237-
block.placeholder?.trim() || "Options",
238-
)}:\n${escapeFeishuCardMarkdownText(labels)}`,
235+
content: escapeFeishuCardMarkdownText(
236+
renderMessagePresentationFallbackText({ presentation: { blocks: [block] } }),
237+
),
239238
},
240239
];
241240
}

0 commit comments

Comments
 (0)