Skip to content

fix(telegram): use native rich drafts for live previews#93438

Closed
snowzlm wants to merge 3 commits into
openclaw:mainfrom
snowzlm:fix/telegram-rich-draft-visibility-clean-93416
Closed

fix(telegram): use native rich drafts for live previews#93438
snowzlm wants to merge 3 commits into
openclaw:mainfrom
snowzlm:fix/telegram-rich-draft-visibility-clean-93416

Conversation

@snowzlm

@snowzlm snowzlm commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Recreated the closed PR fix(telegram): use native rich drafts for live previews #93416 from a clean branch based on current main.
  • Rebased after fix(telegram): restore readable default text sends #93279 and again onto latest main; kept the readable default path intact.
  • Add Bot API 10.1 native sendRichMessageDraft support for Telegram live previews only when the selected account has richMessages enabled.
  • Preserve the standard sendMessage / editMessageText fallback when rich transport is disabled or when native drafts are rejected.
  • Keep final replies on the existing persistent rich-message path; this PR changes live preview behavior, not final-answer persistence.
  • Fix the prior review blocker: stream.temporary?.() now reports true only after a native draft has actually been delivered, so debounce-delayed flushes without a message id still preserve fallback delivery.
  • Improve Telegram progress rich HTML line breaks so tool label, status, process, and command details display as readable separate lines.

Clean-branch scope

Validation

  • node scripts/run-vitest.mjs run extensions/telegram/src/draft-stream.test.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/lane-delivery.test.ts --reporter=dot
    • Result after latest rebase: 3 files passed, 218 tests passed.
  • node scripts/run-vitest.mjs run test/scripts/openclaw-cross-os-release-checks.test.ts --config test/vitest/vitest.tooling.config.ts --reporter=verbose
    • Result after latest rebase: 1 file passed, 89 tests passed.
  • git diff --check origin/main...HEAD plus conflict-marker scan
    • Result after latest rebase: no whitespace errors and no conflict markers.

Real behavior proof

  • Behavior or issue addressed: Supported private Telegram chats use native sendRichMessageDraft for temporary live previews only when rich messages are enabled for the selected account, rich-disabled or rejected native-draft paths stay on the standard send/edit preview fallback, and final reply persistence remains unchanged.
  • Real environment tested: Local Linux OpenClaw checkout on exact rebased PR head c2dccb728891d70ada68acc6b8d1d6a5eec339cd.
  • Exact steps or command run after this patch: node scripts/run-vitest.mjs run extensions/telegram/src/draft-stream.test.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/lane-delivery.test.ts --reporter=dot and node scripts/run-vitest.mjs run test/scripts/openclaw-cross-os-release-checks.test.ts --config test/vitest/vitest.tooling.config.ts --reporter=verbose.
  • Evidence after fix: Terminal output captured after the rebase showed Test Files 3 passed (3), Tests 218 passed (218), followed by Test Files 1 passed (1) and Tests 89 passed (89). The same checkout reported no conflict markers and the diff remains limited to the six Telegram live-preview/progress source/test files.
  • Observed result after fix: The rich opt-in/native-draft fallback coverage passed on the exact rebased head: native drafts are gated by selected-account rich messages, rejected native drafts fall back to preview messages, and delayed native drafts are not treated as temporary until delivered. The tooling reproducer also passed locally.
  • What was not tested: Live Telegram client exact-head proof was not rerun in this cycle; the latest inspected upstream Mantis attempt failed before candidate capture because the baseline Telegram session did not receive a bot reply.

Current CI note

  • Latest inspected CI run on this head has unrelated failures outside the Telegram diff: extensions/codex/src/app-server/bounded-turn.ts type errors, prompt snapshot drift, and plugin SDK surface budget drift. I reproduced the bounded-turn TypeScript error locally with pnpm tsgo:extensions; the PR diff remains limited to the six Telegram live-preview/progress files.

Risk / rollback

  • Risk is limited to Telegram private-chat live-preview behavior and progress rich HTML layout.
  • Unsupported targets and accounts without rich messages enabled retain the standard send/edit preview path.
  • Rollback: revert this PR to disable native temporary rich drafts while keeping the current final-answer rich-message behavior.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 15, 2026
@snowzlm snowzlm force-pushed the fix/telegram-rich-draft-visibility-clean-93416 branch from be5234c to ae76bdc Compare June 15, 2026 23:39
@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 15, 2026
@steipete

Copy link
Copy Markdown
Contributor

This needs rebasing and a policy adjustment after #93279 landed.

Current main makes rich transport account-scoped and opt-in: extensions/telegram/src/bot-message-dispatch.ts:996 passes the selected account's richMessages setting into the draft stream, and extensions/telegram/src/draft-stream.ts:181 keeps standard send/edit previews as the default. This PR currently sets preferNativeDraft: true unconditionally and falls back to persistent rich preview messages, which would reintroduce the unsupported-message regression for operators who did not enable rich messages.

Best fix: rebase on main, make native sendRichMessageDraft conditional on the existing selected-account richMessages flag, and retain the landed standard sendMessage / editMessageText fallback when rich transport is disabled or rejected. Please also add exact-head native Telegram Desktop proof for the opt-in draft path; #93279's proof only covers the readable default path.

@snowzlm snowzlm force-pushed the fix/telegram-rich-draft-visibility-clean-93416 branch 2 times, most recently from 8968c77 to 7fbb5e7 Compare June 16, 2026 00:56
@snowzlm snowzlm force-pushed the fix/telegram-rich-draft-visibility-clean-93416 branch from 7fbb5e7 to bfa36ea Compare June 16, 2026 03:43
@snowzlm

snowzlm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and pushed updated head bfa36eaf280d. The native draft path remains gated by the selected account richMessages opt-in, with the standard send/edit preview fallback preserved when rich messages are disabled or the native draft call is rejected. Local verification after the rebase: Telegram targeted tests passed (3 files, 218 tests) and the previously failing tooling shard reproducer passed locally (1 file, 89 tests). Real behavior proof is still pending exact-head live evidence. @clawsweeper Re-review

@snowzlm snowzlm force-pushed the fix/telegram-rich-draft-visibility-clean-93416 branch from bfa36ea to bb0efd4 Compare June 16, 2026 04:53
@snowzlm

snowzlm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and pushed exact head bb0efd45d7f836ae1bf98a9f64f9b064b0aa0004. Local targeted validation on the rebased head passed: Telegram draft/dispatch/lane-delivery tests 218/218, tooling reproducer 89/89, plus diff whitespace/conflict-marker checks. Updated the PR body with the terminal evidence and retained the rich opt-in/fallback scope. @clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 16, 2026
@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 16, 2026, 1:29 AM ET / 05:29 UTC.

Summary
The PR adds Telegram native rich-message draft support for live previews behind the selected account's richMessages opt-in, keeps standard send/edit fallback paths, and adjusts progress rich HTML formatting and tests.

PR surface: Source +110, Tests +97. Total +207 across 6 files.

Reproducibility: not applicable. as a PR review: this is a proposed Telegram transport capability rather than a standalone issue reproduction. The source path and targeted tests are clear, but the live Telegram runtime behavior remains unproven.

Review metrics: 1 noteworthy metric.

  • Rich-preview activation path: 1 existing account setting extended. The existing selected-account richMessages opt-in now also controls native live draft transport, so existing opt-in users get a different preview surface after merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add exact-head redacted Telegram Desktop proof for richMessages-enabled private-chat native draft previews.
  • Show that rich-disabled or rejected-native-draft paths still render through the standard send/edit fallback in the same proof or linked logs.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR supplies targeted test and terminal-output evidence, but no exact-head real Telegram client run for the visible native draft behavior; add redacted screenshot, recording, logs, or live output and update the PR body to trigger re-review.

Mantis proof suggestion
A native Telegram Desktop run would directly show whether the opt-in native draft preview and fallback paths behave correctly on the exact PR head. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify exact head bb0efd45d7f836ae1bf98a9f64f9b064b0aa0004 uses native rich live previews only with richMessages true and keeps disabled or rejected fallback readable.

Risk before merge

  • [P1] Existing richMessages opt-in users would switch private-chat live previews from persistent rich preview messages to ephemeral native drafts; exact-head live proof is needed to confirm current clients render, update, and clear that path acceptably.
  • [P1] The default disabled and native-rejected paths look preserved in source and tests, but green CI does not prove real Telegram transport behavior for the new Bot API surface.

Maintainer options:

  1. Require exact-head Telegram proof (recommended)
    Ask the contributor or Mantis to capture a redacted real Telegram Desktop run on bb0efd4 showing the opt-in native draft path and fallback behavior before merge.
  2. Accept opt-in transport risk
    Maintainers may intentionally merge based on the source and test coverage, accepting that richMessages users are the only users who get the new temporary draft transport before live proof.
  3. Pause native draft shipping
    If exact-head proof cannot be produced, keep the readable default from fix(telegram): restore readable default text sends #93279 and defer native draft previews until the live client behavior is demonstrated.

Next step before merge

  • [P1] Human follow-up is needed for exact-head live Telegram proof; this read-only review did not find a narrow code repair for automation to make.

Security
Cleared: The diff stays within Telegram source and tests and does not add dependencies, workflows, credentials, lockfiles, package metadata, or new script execution surfaces.

Review details

Best possible solution:

Land the opt-in native draft path only after exact-head real Telegram proof shows richMessages-enabled private chats use native live previews and disabled or rejected paths remain readable fallback.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a PR review: this is a proposed Telegram transport capability rather than a standalone issue reproduction. The source path and targeted tests are clear, but the live Telegram runtime behavior remains unproven.

Is this the best way to solve the issue?

Yes at code-shape level: using the existing account richMessages opt-in and preserving send/edit fallback is the narrowest maintainable path after the readable-default fix. It is not merge-ready until exact-head live Telegram proof covers the native draft path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7ac2bbaaf0ae.

Label changes

Label changes:

  • add P2: This is a normal-priority Telegram opt-in live-preview improvement with limited blast radius and a proof blocker, not an urgent default-path regression.
  • add merge-risk: 🚨 compatibility: Merging changes behavior for existing Telegram accounts that already enabled richMessages by switching their private-chat live previews to native temporary drafts.
  • add merge-risk: 🚨 message-delivery: The PR changes Telegram live-preview delivery through a new Bot API method, and the exact-head real transport path has not been demonstrated yet.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies targeted test and terminal-output evidence, but no exact-head real Telegram client run for the visible native draft behavior; add redacted screenshot, recording, logs, or live output and update the PR body to trigger re-review.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. This changes visible Telegram live-preview behavior, which is a good fit for a short Telegram Desktop proof run.

Label justifications:

  • P2: This is a normal-priority Telegram opt-in live-preview improvement with limited blast radius and a proof blocker, not an urgent default-path regression.
  • merge-risk: 🚨 compatibility: Merging changes behavior for existing Telegram accounts that already enabled richMessages by switching their private-chat live previews to native temporary drafts.
  • merge-risk: 🚨 message-delivery: The PR changes Telegram live-preview delivery through a new Bot API method, and the exact-head real transport path has not been demonstrated yet.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies targeted test and terminal-output evidence, but no exact-head real Telegram client run for the visible native draft behavior; add redacted screenshot, recording, logs, or live output and update the PR body to trigger re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. This changes visible Telegram live-preview behavior, which is a good fit for a short Telegram Desktop proof run.
Evidence reviewed

PR surface:

Source +110, Tests +97. Total +207 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 127 17 +110
Tests 2 104 7 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 231 24 +207

What I checked:

  • Root policy read: Root AGENTS.md was read fully and requires scoped policy checks, dependency/API contract proof, and real behavior proof for Telegram-visible changes. (AGENTS.md:1, 7ac2bbaaf0ae)
  • Scoped extension policy read: extensions/AGENTS.md keeps bundled plugin work inside the plugin boundary; the touched Telegram files stay within that boundary. (extensions/AGENTS.md:1, 7ac2bbaaf0ae)
  • Telegram maintainer note applied: The Telegram maintainer note says draft previews are ephemeral, final delivery still needs persistent send behavior, and Telegram behavior PRs touching streaming need real Telegram proof. (.agents/maintainer-notes/telegram.md:1, 7ac2bbaaf0ae)
  • Current main behavior: Current main has account-scoped richMessages draft rendering but no native sendRichMessageDraft live-preview path, so this PR is not obsolete on main. (extensions/telegram/src/draft-stream.ts:164, 7ac2bbaaf0ae)
  • PR head implementation: The PR head adds native draft gating on preferNativeDraft, richMessages, private positive chat IDs, non-forum scope, and raw sendRichMessageDraft availability, then falls back to the existing rich/send preview message path after native rejection. (extensions/telegram/src/draft-stream.ts:188, bb0efd45d7f8)
  • Dispatch gate: The dispatch path passes preferNativeDraft only when the selected account has richMessages enabled, matching the maintainer-requested policy after the readable-default fix. (extensions/telegram/src/bot-message-dispatch.ts:999, bb0efd45d7f8)

Likely related people:

  • obviyus: GitHub file history shows repeated recent work on Telegram rich messages, draft previews, progress rendering, and the earlier native-draft removal in the same files. (role: rich-message feature owner and recent area contributor; confidence: high; commits: da92615816b6, 663fabbe30eb, e8b142feb117; files: extensions/telegram/src/draft-stream.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/rich-message.ts)
  • NianJiuZst: Authored the merged readable-default richMessages opt-in fix that this PR rebased onto and now follows for the native draft gate. (role: recent regression-fix contributor; confidence: high; commits: a375d6c84963, 37bc4f2b7fa9; files: extensions/telegram/src/draft-stream.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/rich-message.ts)
  • steipete: Provided the live maintainer review instruction on this PR and authored the final policy/test follow-up commits in the merged readable-default Telegram PR. (role: recent reviewer and follow-up patch contributor; confidence: high; commits: beafa2bcca0a, 26853c078053, 14c5aa5e689d; files: extensions/telegram/src/draft-stream.test.ts, extensions/telegram/src/send.test.ts, extensions/telegram/src/bot-message-dispatch.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 16, 2026
@snowzlm snowzlm force-pushed the fix/telegram-rich-draft-visibility-clean-93416 branch from bb0efd4 to c2dccb7 Compare June 16, 2026 06:44
@snowzlm

snowzlm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and pushed updated exact head c2dccb728891d70ada68acc6b8d1d6a5eec339cd. Local targeted validation passed again: Telegram draft/dispatch/lane-delivery tests 218/218, tooling reproducer 89/89, plus diff whitespace/conflict-marker checks. I also inspected the failed native Telegram proof attempt on the previous head; it failed before candidate capture because the baseline Telegram session did not receive a bot reply, so it did not capture a PR code failure. @clawsweeper re-review

@vincentkoc vincentkoc self-assigned this Jun 16, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Closing because this conflicts with the established Telegram streaming contract, not merely because live proof is missing.

OpenClaw intentionally keeps one persistent preview message, edits it forward, and finalizes it in place. Native sendRichMessageDraft is an ephemeral 30-second private-chat preview; this branch would switch existing richMessages opt-in users to that temporary surface and then send a separate persistent final message. That reintroduces the exact extra-final-bubble behavior the Telegram maintainer decision rejects.

The existing account-scoped persistent rich preview path is the supported shape. Native draft methods should not be used for answer streaming unless the maintainer contract itself is deliberately changed with real Telegram proof and a one-bubble finalization design.

Official draft behavior: https://core.telegram.org/bots/api#sendrichmessagedraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants