fix(reply): refresh followup drain callbacks

This commit is contained in:
Vincent Koc
2026-03-23 09:45:21 -07:00
committed by Peter Steinberger
parent bcaadc39ea
commit a35dcf608e
4 changed files with 65 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
import { resolveGlobalDedupeCache } from "../../../infra/dedupe.js";
import { applyQueueDropPolicy, shouldSkipQueueItem } from "../../../utils/queue-helpers.js";
import { kickFollowupDrainIfIdle } from "./drain.js";
import { kickFollowupDrainIfIdle, rememberFollowupDrainCallback } from "./drain.js";
import { getExistingFollowupQueue, getFollowupQueue } from "./state.js";
import type { FollowupRun, QueueDedupeMode, QueueSettings } from "./types.js";
@@ -59,6 +59,7 @@ export function enqueueFollowupRun(
run: FollowupRun,
settings: QueueSettings,
dedupeMode: QueueDedupeMode = "message-id",
runFollowup?: (run: FollowupRun) => Promise<void>,
): boolean {
const queue = getFollowupQueue(key, settings);
const recentMessageIdKey = dedupeMode !== "none" ? buildRecentMessageIdKey(run, key) : undefined;
@@ -92,6 +93,9 @@ export function enqueueFollowupRun(
if (recentMessageIdKey) {
RECENT_QUEUE_MESSAGE_IDS.check(recentMessageIdKey);
}
if (runFollowup) {
rememberFollowupDrainCallback(key, runFollowup);
}
// If drain finished and deleted the queue before this item arrived, a new queue
// object was created (draining: false) but nobody scheduled a drain for it.
// Use the cached callback to restart the drain now.