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)
This commit is contained in:
hope 2026-03-12 19:17:19 +08:00
parent 51f31021b9
commit 17243b9cb7

View File

@ -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;
}