Skip to content

Commit 4d42938

Browse files
committed
fix(feishu): preserve commands in select fallback cards
1 parent 25a16dd commit 4d42938

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
@@ -1336,40 +1336,49 @@ describe("feishuPlugin actions", () => {
13361336
]);
13371337
});
13381338

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

1342-
await feishuPlugin.actions?.handleAction?.({
1343-
action: "send",
1344-
params: {
1345-
to: "chat:oc_group_1",
1346-
presentation: {
1347-
blocks: [
1348-
{
1349-
type: "select",
1350-
placeholder: "Pick one",
1351-
options: [{ label: "Option A", value: "a" }],
1352-
},
1353-
],
1344+
await feishuPlugin.actions?.handleAction?.({
1345+
action,
1346+
params: {
1347+
to: "chat:oc_group_1",
1348+
...(action === "thread-reply" ? { messageId: "om_root" } : {}),
1349+
presentation: {
1350+
blocks: [
1351+
{
1352+
type: "select",
1353+
placeholder: "Pick <one> & continue",
1354+
options: [
1355+
{ label: "Status <one>", action: { type: "command", command: "/status" } },
1356+
{ label: "Callback", action: { type: "callback", value: "/opaque-callback" } },
1357+
{ label: "Legacy", value: "/opaque-legacy" },
1358+
],
1359+
},
1360+
],
1361+
},
13541362
},
1355-
},
1356-
cfg,
1357-
accountId: undefined,
1358-
toolContext: {},
1359-
} as never);
1363+
cfg,
1364+
accountId: undefined,
1365+
toolContext: {},
1366+
} as never);
13601367

1361-
const sendCardArgs = requireRecord(
1362-
mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
1363-
"send card args",
1364-
);
1365-
const card = requireRecord(sendCardArgs.card, "card");
1366-
expect(requireRecord(card.body, "card body").elements).toEqual([
1367-
{
1368-
tag: "markdown",
1369-
content: "Pick one:\n- Option A",
1370-
},
1371-
]);
1372-
});
1368+
const sendCardArgs = requireRecord(
1369+
mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
1370+
"send card args",
1371+
);
1372+
const card = requireRecord(sendCardArgs.card, "card");
1373+
expect(requireRecord(card.body, "card body").elements).toEqual([
1374+
{
1375+
tag: "markdown",
1376+
content:
1377+
"Pick &lt;one&gt; &amp; continue:\n- Status &lt;one&gt;: `/status`\n- Callback\n- Legacy",
1378+
},
1379+
]);
1380+
},
1381+
);
13731382

13741383
it.each(
13751384
[

‎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)