Avoid duplicate merge_ready finalize follow-ups

This commit is contained in:
Eyejoker
2026-04-05 01:08:02 +09:00
parent ac225f2b1e
commit f5e9400b9b
2 changed files with 43 additions and 5 deletions

View File

@@ -897,10 +897,30 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
openWorkItem,
);
if (!delivered) return false;
const skipQueuedFollowUpForInlineFinalize =
hasReviewerLease(chatJid) &&
deliveryRole === 'reviewer' &&
pendingTask?.status === 'merge_ready';
// Keep stale final delivery isolated from the next conversational turn.
// A follow-up run will pick up any queued user messages or paired-room
// auto-review/finalize transitions after this retry succeeds.
deps.queue.enqueueMessageCheck(chatJid);
//
// merge_ready is special: the delivered reviewer bot message itself
// triggers the inline finalize path. Queueing a generic follow-up here
// can race with that path and produce a second owner finalize turn.
if (skipQueuedFollowUpForInlineFinalize) {
log.info(
{
workItemId: openWorkItem.id,
chatJid,
deliveryRole,
pendingTaskStatus: pendingTask?.status ?? null,
},
'Skipping queued follow-up after reviewer merge_ready delivery because inline finalize will handle the handoff',
);
} else {
deps.queue.enqueueMessageCheck(chatJid);
}
return true;
}