fix(telegram): gate sendMayHaveLanded retention to final context only

In update context, the caller doesn't treat 'retained' as success and
falls through to sendPayload. Calling markDelivered() prematurely in
update context can leave delivery state inconsistent.
This commit is contained in:
hougangdev
2026-03-10 23:58:33 +08:00
committed by Ayaan Zaidi
parent 8bfe7db27a
commit e75cb04ef0

View File

@@ -382,9 +382,11 @@ export function createLaneTextDeliverer(params: CreateLaneTextDelivererParams) {
context,
});
if (typeof previewTargetAfterStop.previewMessageId !== "number") {
// Only retain when a prior preview is already visible to the user —
// otherwise falling back is safer than silence.
if (lane.hasStreamedMessage && lane.stream?.sendMayHaveLanded?.()) {
// Only retain for final delivery when a prior preview is already visible
// to the user — otherwise falling back is safer than silence. For updates,
// always fall back so the caller can attempt sendPayload without stale
// markDelivered() state.
if (context === "final" && lane.hasStreamedMessage && lane.stream?.sendMayHaveLanded?.()) {
params.log(
`telegram: ${laneName} preview send may have landed despite missing message id; keeping to avoid duplicate`,
);