hotfix(telegram): stream final replies without completion notify#1113
Conversation
(cherry picked from commit bc6e0ec9e6d6e11f033bd903deeacb78a0a63c17)
Greptile SummaryThis hotfix corrects
Confidence Score: 5/5Safe to merge — the change is a single-line correction to a method that previously hardcoded the wrong return value, all three paths (stream on, stream off, notify off) are now covered by tests, and no production logic in the dispatcher was modified. The fix is minimal and precisely targeted: one line in stream.rs changes a hardcoded false to a delegation to is_stream_enabled, which is the same check already used by receives_progress_deltas. The surrounding tests explicitly cover the notify-off configuration and the dispatcher completion semantics in both the true and false cases. No unguarded paths were introduced. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/telegram/src/outbound/stream.rs | Core one-line fix: streams_final_replies now delegates to is_stream_enabled, correctly marking Telegram as a final-reply stream when edit-in-place mode is on. |
| crates/telegram/src/outbound/tests.rs | Existing test updated to cover the notify-off + streaming-on configuration and assert corrected streams_final_replies = true behavior. |
| crates/chat/src/agent_loop.rs | Two new dispatcher unit tests added documenting progress-only vs final-reply stream semantics; no changes to production logic in this file. |
Sequence Diagram
sequenceDiagram
participant CL as ChatLayer
participant D as ChannelStreamDispatcher
participant TG as TelegramOutbound
participant W as StreamWorker
CL->>D: for_session(...)
D->>TG: is_stream_enabled(account_id)
TG-->>D: "true (stream_mode != Off)"
D->>TG: streams_final_replies(account_id)
Note over TG: BEFORE fix: always false, AFTER fix: is_stream_enabled
TG-->>D: true (after fix)
D->>W: spawn(send_stream with rx)
CL->>D: send_progress_delta(...)
D->>W: StreamEvent::ProgressDelta
CL->>D: send_delta(final text)
D->>W: StreamEvent::Delta
CL->>D: finish()
D->>W: StreamEvent::Done
W-->>D: Ok() - insert key into completed
CL->>D: completed_target_keys()
D-->>CL: target_key - skip normal final delivery
Reviews (1): Last reviewed commit: "fix(telegram): stream final replies with..." | Re-trigger Greptile
Summary
Hotfix for Telegram edit-in-place streaming after #1099.
When Telegram streaming was enabled but completion notifications were disabled, the final answer was not treated as a streamed final reply. This restores the expected behavior: Telegram can keep editing/streaming the final reply while
stream_notify_on_complete = falseonly suppresses the completion notification.What was observed
In live Telegram testing with anonymized session details:
stream_mode = edit_in_placestream_notify_on_complete = falseRoot Cause
The channel streaming layer distinguishes between:
After #1099, Telegram still reported
streams_final_replies = falseeven when edit-in-place streaming was enabled. That made the chat layer treat Telegram as a progress-only stream for final delivery bookkeeping.The fix changes Telegram's
streams_final_repliesimplementation to followis_stream_enabled(...), so a Telegram account with streaming enabled is marked as a final-reply stream regardless of whether completion notifications are enabled.Code Investigation
Relevant paths checked:
crates/telegram/src/outbound/stream.rsstream_notify_on_completecontrols whether Telegram gets a separate completion notification/final send behavior.streams_final_repliesnow returns the effective stream-enabled state.crates/chat/src/agent_loop.rsstreams_final_repliescontrols whether the target is considered completed for normal final deliverycrates/telegram/src/outbound/tests.rsValidation
Passed:
Also manually validated the deployed hotfix with Telegram settings
stream=on, notify=off: the final answer streamed/edited in Telegram and no completion notification was emitted.