-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
message:sent hook not emitted when Telegram streaming preview finalizes #50878
Description
Summary
message:sent internal hook events are never fired for Telegram DM replies when streaming preview mode is active (default). This means hooks registered for message:sent (like custom loggers) never trigger on normal DM conversations.
Root Cause
In extensions/telegram/src/lane-delivery-text-deliverer.ts, when the final answer fits within 4096 chars and streaming is active, the code takes the preview-finalize path:
tryMaterializeDraftPreviewForFinal(line ~500) ortryUpdatePreviewForLane(line ~510) edits the existing preview message in-place- Returns
"preview-finalized"or"preview-retained" - Neither path calls
sendPayload→deliverRepliesis never invoked →emitMessageSentHooksis never called →message:sentnever fires
Expected Behavior
message:sent should fire whenever a message is delivered to a channel, regardless of whether delivery happened via sendPayload or preview finalization.
Affected Paths
- DM replies with streaming enabled (default) — broken
- Cron deliveries via
deliverOutboundPayloads— works - Webhook deliveries via
route-reply.ts→deliverOutboundPayloads— works - Replies where preview fails and falls through to
sendPayload— works
Suggested Fix
Call emitMessageSentHooks (or equivalent callback) when returning "preview-finalized" or "preview-retained" in lane-delivery-text-deliverer.ts.
Workaround
Set blockStreaming: true in the Telegram channel config to force all replies through the normal sendPayload → deliverReplies path.
Reproduction
- Register an internal hook for
message:sentwith aconsole.errorat the top of the handler - Send a DM to the bot via Telegram
- Observe that the hook handler is never called
- Set
blockStreaming: true→ hook fires correctly