fix: filter NO_REPLY prefixes

This commit is contained in:
Peter Steinberger
2026-01-09 23:29:01 +00:00
parent a9a70ea278
commit 96e17d407a
11 changed files with 85 additions and 16 deletions

View File

@@ -18,6 +18,14 @@ describe("msteams messenger", () => {
expect(messages).toEqual([]);
});
it("filters silent reply prefixes", () => {
const messages = renderReplyPayloadsToMessages(
[{ text: `${SILENT_REPLY_TOKEN} -- ignored` }],
{ textChunkLimit: 4000 },
);
expect(messages).toEqual([]);
});
it("splits media into separate messages by default", () => {
const messages = renderReplyPayloadsToMessages(
[{ text: "hi", mediaUrl: "https://example.com/a.png" }],

View File

@@ -1,5 +1,5 @@
import { chunkMarkdownText } from "../auto-reply/chunk.js";
import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import type { ReplyPayload } from "../auto-reply/types.js";
import type { MSTeamsReplyStyle } from "../config/types.js";
import type { StoredConversationReference } from "./conversation-store.js";
@@ -107,14 +107,14 @@ function pushTextMessages(
if (opts.chunkText) {
for (const chunk of chunkMarkdownText(text, opts.chunkLimit)) {
const trimmed = chunk.trim();
if (!trimmed || trimmed === SILENT_REPLY_TOKEN) continue;
if (!trimmed || isSilentReplyText(trimmed, SILENT_REPLY_TOKEN)) continue;
out.push(trimmed);
}
return;
}
const trimmed = text.trim();
if (!trimmed || trimmed === SILENT_REPLY_TOKEN) return;
if (!trimmed || isSilentReplyText(trimmed, SILENT_REPLY_TOKEN)) return;
out.push(trimmed);
}