























@@ -9,6 +9,7 @@ import {
99canFinalizeMattermostPreviewInPlace,
1010deliverMattermostReplyWithDraftPreview,
1111evaluateMattermostMentionGate,
12+formatMattermostFinalDeliveryOutcomeLog,
1213MattermostRetryableInboundError,
1314processMattermostReplayGuardedPost,
1415resolveMattermostReactionChannelId,
@@ -555,6 +556,74 @@ describe("deliverMattermostReplyWithDraftPreview", () => {
555556});
556557});
557558559+describe("formatMattermostFinalDeliveryOutcomeLog", () => {
560+it("logs delivered only for visible text and media outcomes", () => {
561+expect(
562+formatMattermostFinalDeliveryOutcomeLog({
563+outcome: "text",
564+payload: { text: "hello" } as never,
565+to: "channel:town-square",
566+accountId: "default",
567+agentId: "agent-1",
568+}),
569+).toBe("delivered reply to channel:town-square");
570+571+expect(
572+formatMattermostFinalDeliveryOutcomeLog({
573+outcome: "media",
574+payload: { mediaUrl: "https://example.com/a.png" } as never,
575+to: "channel:town-square",
576+accountId: "default",
577+agentId: "agent-1",
578+}),
579+).toBe("delivered reply to channel:town-square");
580+});
581+582+it("does not log delivered for empty no-send outcomes without diagnostic violations", () => {
583+expect(
584+formatMattermostFinalDeliveryOutcomeLog({
585+outcome: "empty",
586+payload: { text: " \n\t " } as never,
587+to: "channel:town-square",
588+accountId: "default",
589+agentId: "agent-1",
590+}),
591+).toBeUndefined();
592+});
593+594+it("logs a diagnostic for substantive empty outcomes", () => {
595+expect(
596+formatMattermostFinalDeliveryOutcomeLog({
597+outcome: "empty",
598+payload: { text: "work result" } as never,
599+to: "channel:town-square",
600+accountId: "default",
601+agentId: "agent-1",
602+}),
603+).toBe(
604+"mattermost no-visible-reply: no-visible-reply-after-final-delivery" +
605+" to=channel:town-square" +
606+" accountId=default" +
607+" agentId=agent-1" +
608+" outcome=empty" +
609+" finalTextLength=11" +
610+" mediaUrlCount=0",
611+);
612+});
613+614+it("does not log reasoning-suppressed outcomes", () => {
615+expect(
616+formatMattermostFinalDeliveryOutcomeLog({
617+outcome: "reasoning_skipped",
618+payload: { text: "Reasoning: hidden" } as never,
619+to: "channel:town-square",
620+accountId: "default",
621+agentId: "agent-1",
622+}),
623+).toBeUndefined();
624+});
625+});
626+558627describe("shouldFinalizeMattermostPreviewAfterDispatch", () => {
559628it("reuses the preview only for a single eligible final payload", () => {
560629expect(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。