Skip to content

Commit 1ba2023

Browse files
committed
fix(feishu): preserve media-only streaming previews
1 parent 1395b99 commit 1ba2023

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

extensions/feishu/src/reply-dispatcher.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,33 @@ describe("createFeishuReplyDispatcher streaming behavior", () => {
979979
});
980980
});
981981

982+
it("keeps partial streaming text when final replies send regular media only", async () => {
983+
const { result, options } = createDispatcherHarness({
984+
runtime: createRuntimeLogger(),
985+
});
986+
987+
result.replyOptions.onPartialReply?.({ text: "caption from stream" });
988+
await options.deliver(
989+
{
990+
mediaUrl: "https://example.com/image.png",
991+
},
992+
{ kind: "final" },
993+
);
994+
await options.onIdle?.();
995+
996+
expect(streamingInstances).toHaveLength(1);
997+
expect(streamingInstances[0].discard).not.toHaveBeenCalled();
998+
expect(streamingInstances[0].close).toHaveBeenCalledWith("caption from stream", {
999+
note: "Agent: agent",
1000+
});
1001+
expect(sendMessageFeishuMock).not.toHaveBeenCalled();
1002+
expect(sendStructuredCardFeishuMock).not.toHaveBeenCalled();
1003+
expect(sendMediaFeishuMock).toHaveBeenCalledTimes(1);
1004+
expectMockArgFields(sendMediaFeishuMock, "media send params", {
1005+
mediaUrl: "https://example.com/image.png",
1006+
});
1007+
});
1008+
9821009
it("sends skipped voice text when final voice media degrades to a file attachment", async () => {
9831010
sendMediaFeishuMock.mockResolvedValueOnce({
9841011
messageId: "file_msg",

extensions/feishu/src/reply-dispatcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,9 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
580580
!skipTextForDuplicateFinal &&
581581
!skipTextForClosedStreamingFinal;
582582
const shouldDiscardStreamingPreview =
583-
info?.kind === "final" && hasMedia && !shouldDeliverText;
583+
info?.kind === "final" &&
584+
hasMedia &&
585+
((hasVoiceMedia && !shouldDeliverText) || skipTextForDuplicateFinal);
584586

585587
if (!shouldDeliverText && !hasMedia) {
586588
return;

0 commit comments

Comments
 (0)