Skip to content

Commit 4bcf0a5

Browse files
committed
fix(feishu): omit command guidance when URL overrides fallback command text
1 parent 7b46a71 commit 4bcf0a5

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

extensions/feishu/src/outbound.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,37 @@ describe("feishuOutbound.sendPayload native cards", () => {
834834
);
835835
expectFeishuResult(result, "reply_msg");
836836
});
837+
838+
it("omits command guidance when all command buttons have URLs overriding the fallback text", async () => {
839+
const result = await feishuOutbound.sendPayload?.({
840+
cfg: emptyConfig,
841+
to: "comment:docx:doxcn123:7623358762119646411",
842+
text: "Review this",
843+
accountId: "main",
844+
payload: {
845+
text: "Review this",
846+
interactive: {
847+
blocks: [
848+
{
849+
type: "buttons",
850+
buttons: [
851+
{
852+
label: "Open URL",
853+
url: "https://example.com/action",
854+
action: { type: "command", command: "/approve req_1" },
855+
},
856+
],
857+
},
858+
],
859+
},
860+
},
861+
});
862+
863+
expect(commentThreadParams()?.content).toBe(
864+
"Review this\n\n- Open URL: https://example.com/action",
865+
);
866+
expectFeishuResult(result, "reply_msg");
867+
});
837868
});
838869

839870
describe("feishuOutbound comment-thread routing", () => {

extensions/feishu/src/outbound.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,19 @@ export const feishuOutbound: ChannelOutboundAdapter = {
518518
text: ctx.payload.text,
519519
presentation: normalizedPresentation,
520520
});
521-
const hasCommandAction =
521+
const hasRenderedCommandAction =
522522
normalizedPresentation?.blocks.some(
523523
(block) =>
524524
block.type === "buttons" &&
525-
block.buttons.some((button) => button.action?.type === "command"),
525+
block.buttons.some(
526+
(button) =>
527+
button.action?.type === "command" &&
528+
!button.url &&
529+
!button.webApp?.url &&
530+
!button.web_app?.url,
531+
),
526532
) ?? false;
527-
const text = hasCommandAction
533+
const text = hasRenderedCommandAction
528534
? `${presentationFallbackText}\n\n> Interactive buttons are unavailable in Feishu document comments. You can type the command shown above manually.`
529535
: presentationFallbackText;
530536

0 commit comments

Comments
 (0)