Skip to content

fix: Telegram stream preview finalizes in place#17218

Merged
obviyus merged 2 commits intomainfrom
fix/telegram-stream-preview-7123
Feb 15, 2026
Merged

fix: Telegram stream preview finalizes in place#17218
obviyus merged 2 commits intomainfrom
fix/telegram-stream-preview-7123

Conversation

@obviyus
Copy link
Copy Markdown
Contributor

@obviyus obviyus commented Feb 15, 2026

Summary

  • switch Telegram stream preview transport from sendMessageDraft to sendMessage + editMessageText
  • finalize text-only replies by editing the same preview message in place (no extra final send)
  • keep fallback path for non-text/complex finals (normal delivery + preview cleanup)
  • fix race where a late in-flight preview update could overwrite the final formatted edit
  • decouple preview streaming from forced block-stream disable so Telegram block streaming still works when enabled
  • update Telegram streaming docs/config help text to match current behavior

Testing

  • pnpm test src/telegram/draft-stream.test.ts src/telegram/bot-message-dispatch.test.ts src/telegram/send.edit-message.test.ts src/telegram/bot-message.test.ts src/auto-reply/reply.block-streaming.test.ts
  • pnpm check

Fixes #7123

Greptile Summary

Switched Telegram stream preview transport from sendMessageDraft to sendMessage + editMessageText, enabling text-only final replies to be delivered by editing the same preview message in place instead of sending a duplicate final message.

Key changes:

  • Preview messages now use standard sendMessage API (no longer requires private chat with topics enabled)
  • Text-only finals edit the preview message in place (prevents duplicate sends)
  • Non-text/complex finals fall back to normal delivery with preview cleanup
  • Race condition fix: flush() now waits for all in-flight preview updates before returning, preventing late updates from overwriting the final formatted edit
  • Decoupled preview streaming from block streaming disable (Telegram block streaming works independently when enabled)
  • Updated docs and config help text to reflect new behavior

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-tested with comprehensive test coverage including race condition handling, fallback paths, and cleanup logic. The implementation correctly addresses the race condition by ensuring flush() waits for in-flight operations before returning. The finally block properly handles cleanup in both success and failure scenarios. Documentation and config help text accurately reflect the new behavior.
  • No files require special attention

Last reviewed commit: 2f6ac9e

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Feb 15, 2026
@obviyus
Copy link
Copy Markdown
Contributor Author

obviyus commented Feb 15, 2026

ScreenRecording_02-15-2026.20-12-33_1.MP4

Works well! To enable, we need a minimum of:

{
  "agents": {
    "defaults": {
      "blockStreamingDefault": "off"
    }
  },
  "channels": {
    "telegram": {
      "streamMode": "partial",
      "blockStreaming": false
    }
  }
}

Huge thanks to @amiller for the deep root-cause analysis in #7123 (and @rursache for the original request/demo). Switched from sendMessageDraft to edit-based streaming because draft bubbles are limited to specific DM/topic contexts and can conflict with block streaming, while sendMessage + editMessageText works consistently across Telegram contexts and lets us finalize in place. If Telegram later adds draft streaming support across all message contexts, we can reevaluate and move back to that path.

@obviyus obviyus self-assigned this Feb 15, 2026
@obviyus obviyus force-pushed the fix/telegram-stream-preview-7123 branch from 2f6ac9e to 0b95f6e Compare February 15, 2026 15:02
@obviyus obviyus merged commit 86df160 into main Feb 15, 2026
10 checks passed
@obviyus obviyus deleted the fix/telegram-stream-preview-7123 branch February 15, 2026 15:02
@obviyus
Copy link
Copy Markdown
Contributor Author

obviyus commented Feb 15, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint (failed in unrelated baseline cron files), pnpm build, pnpm test
  • Land commit: 0b95f6e
  • Merge commit: 86df160

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@syabro
Copy link
Copy Markdown

syabro commented Feb 15, 2026

how to install it?

@aflag
Copy link
Copy Markdown

aflag commented Feb 18, 2026

I believe that, after this change, openclaw will constantly edit the same message. It will write a full message, delete it all and come back with a new one. Is that the original intention? I'd rather either it sent the intermediate message or not show me at all. Seeing multiple messages popping up, not having any time to read, just to get a revised one is infuriating

@obviyus
Copy link
Copy Markdown
Contributor Author

obviyus commented Feb 19, 2026

Hi, definitely not intentional. I believe this is fixed now, could you try running it on the latest commit?

jun-planfit pushed a commit to planfit/openclaw that referenced this pull request Feb 19, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…nks @obviyus)

(cherry picked from commit 86df160)

# Conflicts:
#	CHANGELOG.md
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…nks @obviyus)

(cherry picked from commit 86df160)

# Conflicts:
#	CHANGELOG.md
@aflag
Copy link
Copy Markdown

aflag commented Mar 4, 2026

@obviyus yeah, it seems better now. Thanks

zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Telegram message streaming without sendMessageDraft

3 participants