From 17243b9cb73c94796bf7b1e5c3ee03cd3a03acc6 Mon Sep 17 00:00:00 2001 From: hope Date: Thu, 12 Mar 2026 19:17:19 +0800 Subject: [PATCH] fix: address Greptile review - remove redundant block and add persistedLastTo guard - Remove redundant if block in resolveLastChannelRaw (lines 113-120) The existing block at lines 106-112 already handles this case - Add params.persistedLastTo guard in resolveLastToRaw (lines 153-160) Prevents premature return of undefined when persistedLastTo is falsy This avoids silently dropping message delivery Ref: #43703 (PR review from Greptile) --- src/auto-reply/reply/session-delivery.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/auto-reply/reply/session-delivery.ts b/src/auto-reply/reply/session-delivery.ts index e69c3c7267f..08da775f603 100644 --- a/src/auto-reply/reply/session-delivery.ts +++ b/src/auto-reply/reply/session-delivery.ts @@ -117,14 +117,6 @@ export function resolveLastChannelRaw(params: { resolved = sessionKeyChannelHint; } } - // Fix #34308: When channel is INTERNAL but session has a persisted external channel - // (deliveryContext), use the persisted channel for reply delivery. - if ( - originatingChannel === INTERNAL_MESSAGE_CHANNEL && - isExternalRoutingChannel(persistedChannel) - ) { - resolved = persistedChannel; - } return resolved; } @@ -160,10 +152,11 @@ export function resolveLastToRaw(params: { } // Fix #34308: When channel is INTERNAL but session has a persisted external channel - // (deliveryContext), use the persisted to address for reply delivery. + // (deliveryContext) AND a persisted lastTo address, use the persisted to address for reply delivery. if ( originatingChannel === INTERNAL_MESSAGE_CHANNEL && - isExternalRoutingChannel(persistedChannel) + isExternalRoutingChannel(persistedChannel) && + params.persistedLastTo ) { return params.persistedLastTo; }