refactor: unify pending history helpers

This commit is contained in:
Peter Steinberger
2026-01-23 22:36:43 +00:00
parent 05e7e06146
commit 521ea4ae5b
13 changed files with 196 additions and 155 deletions

View File

@@ -5,7 +5,7 @@ import {
type ResponsePrefixContext,
} from "../auto-reply/reply/response-prefix-template.js";
import { EmbeddedBlockChunker } from "../agents/pi-embedded-block-chunker.js";
import { clearHistoryEntries } from "../auto-reply/reply/history.js";
import { clearHistoryEntriesIfEnabled } from "../auto-reply/reply/history.js";
import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js";
import { removeAckReactionAfterReply } from "../channels/ack-reactions.js";
import { danger, logVerbose } from "../globals.js";
@@ -180,8 +180,8 @@ export const dispatchTelegramMessage = async ({
});
draftStream?.stop();
if (!queuedFinal) {
if (isGroup && historyKey && historyLimit > 0) {
clearHistoryEntries({ historyMap: groupHistories, historyKey });
if (isGroup && historyKey) {
clearHistoryEntriesIfEnabled({ historyMap: groupHistories, historyKey, limit: historyLimit });
}
return;
}
@@ -197,7 +197,7 @@ export const dispatchTelegramMessage = async ({
);
},
});
if (isGroup && historyKey && historyLimit > 0) {
clearHistoryEntries({ historyMap: groupHistories, historyKey });
if (isGroup && historyKey) {
clearHistoryEntriesIfEnabled({ historyMap: groupHistories, historyKey, limit: historyLimit });
}
};