






















@@ -578,6 +578,149 @@ describe("feishuPlugin actions", () => {
578578});
579579});
580580581+it("auto-threads `send` text against the inbound trigger in group_topic sessions", async () => {
582+sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_topic", chatId: "oc_group_1" });
583+584+await feishuPlugin.actions?.handleAction?.({
585+action: "send",
586+params: { to: "chat:oc_group_1", text: "topic reply" },
587+ cfg,
588+accountId: undefined,
589+sessionKey: "feishu:group:oc_group_1:topic:om_inbound",
590+toolContext: { currentMessageId: "om_inbound" },
591+} as never);
592+593+expect(sendMessageFeishuMock).toHaveBeenCalledWith({
594+ cfg,
595+to: "chat:oc_group_1",
596+text: "topic reply",
597+accountId: undefined,
598+replyToMessageId: "om_inbound",
599+replyInThread: true,
600+});
601+});
602+603+it("auto-threads `send` cards against the inbound trigger in group_topic sessions", async () => {
604+sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_topic_card", chatId: "oc_group_1" });
605+606+await feishuPlugin.actions?.handleAction?.({
607+action: "send",
608+params: {
609+to: "chat:oc_group_1",
610+presentation: {
611+title: "Topic update",
612+blocks: [{ type: "text", text: "topic reply" }],
613+},
614+},
615+ cfg,
616+accountId: undefined,
617+sessionKey: "feishu:group:oc_group_1:topic:om_inbound",
618+toolContext: { currentMessageId: "om_inbound" },
619+} as never);
620+621+expect(sendCardFeishuMock).toHaveBeenCalledWith(
622+expect.objectContaining({
623+replyToMessageId: "om_inbound",
624+replyInThread: true,
625+}),
626+);
627+});
628+629+it("auto-threads `send` media against the inbound trigger in group_topic sessions", async () => {
630+feishuOutboundSendMediaMock.mockResolvedValueOnce({
631+channel: "feishu",
632+messageId: "om_topic_media",
633+details: { messageId: "om_topic_media", chatId: "oc_group_1" },
634+});
635+636+await feishuPlugin.actions?.handleAction?.({
637+action: "send",
638+params: {
639+to: "chat:oc_group_1",
640+message: "topic reply",
641+media: "/tmp/image.png",
642+},
643+ cfg,
644+accountId: undefined,
645+sessionKey: "feishu:group:oc_group_1:topic:om_inbound",
646+toolContext: { currentMessageId: "om_inbound" },
647+mediaLocalRoots: ["/tmp"],
648+} as never);
649+650+expect(feishuOutboundSendMediaMock).toHaveBeenCalledWith(
651+expect.objectContaining({
652+threadId: "om_inbound",
653+}),
654+);
655+expect(feishuOutboundSendMediaMock).toHaveBeenCalledWith(
656+expect.not.objectContaining({ replyToId: expect.anything() }),
657+);
658+});
659+660+it("auto-threads `send` in group_topic_sender sessions too", async () => {
661+sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_topic", chatId: "oc_group_1" });
662+663+await feishuPlugin.actions?.handleAction?.({
664+action: "send",
665+params: { to: "chat:oc_group_1", text: "topic reply" },
666+ cfg,
667+accountId: undefined,
668+sessionKey: "feishu:group:oc_group_1:topic:om_inbound:sender:ou_user",
669+toolContext: { currentMessageId: "om_inbound" },
670+} as never);
671+672+expect(sendMessageFeishuMock).toHaveBeenCalledWith(
673+expect.objectContaining({
674+replyToMessageId: "om_inbound",
675+replyInThread: true,
676+}),
677+);
678+});
679+680+it("does not auto-thread `send` in plain group sessions (no topic)", async () => {
681+sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_plain", chatId: "oc_group_1" });
682+683+await feishuPlugin.actions?.handleAction?.({
684+action: "send",
685+params: { to: "chat:oc_group_1", text: "plain group reply" },
686+ cfg,
687+accountId: undefined,
688+sessionKey: "feishu:group:oc_group_1",
689+toolContext: { currentMessageId: "om_inbound" },
690+} as never);
691+692+expect(sendMessageFeishuMock).toHaveBeenCalledWith({
693+ cfg,
694+to: "chat:oc_group_1",
695+text: "plain group reply",
696+accountId: undefined,
697+replyToMessageId: undefined,
698+replyInThread: false,
699+});
700+});
701+702+it("does not auto-thread `send` in group_topic when no inbound currentMessageId is available", async () => {
703+sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_topic", chatId: "oc_group_1" });
704+705+await feishuPlugin.actions?.handleAction?.({
706+action: "send",
707+params: { to: "chat:oc_group_1", text: "topic reply" },
708+ cfg,
709+accountId: undefined,
710+sessionKey: "feishu:group:oc_group_1:topic:om_inbound",
711+toolContext: {},
712+} as never);
713+714+expect(sendMessageFeishuMock).toHaveBeenCalledWith({
715+ cfg,
716+to: "chat:oc_group_1",
717+text: "topic reply",
718+accountId: undefined,
719+replyToMessageId: undefined,
720+replyInThread: false,
721+});
722+});
723+581724it("creates pins", async () => {
582725createPinFeishuMock.mockResolvedValueOnce({ messageId: "om_pin", chatId: "oc_group_1" });
583726此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。