Skip to content

fix(telegram): linkPreview:false is ignored on streamed replies - #114125

Merged
steipete merged 2 commits into
openclaw:mainfrom
zak-li:fix/telegram-draft-link-preview
Jul 29, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
zak-li:fix/telegram-draft-link-preview

Conversation

@zak-li

@zak-li zak-li commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Closes #111525

AI-assisted: written with Claude Code. The source tracing and the before/after test runs below were verified locally by me.

What Problem This Solves

Fixes an issue where users running Telegram with channels.telegram.linkPreview: false would still get link-preview cards on streamed replies. Any answer containing a URL unfurls it, so the setting silently does not hold for the delivery path most users actually see.

Non-streamed sends (the message tool, the CLI send path) already honor the flag, which makes the inconsistency hard to diagnose: the same config visibly works on one path and not the other.

Why This Change Was Made

createTelegramDraftStream was never given linkPreview at its creation site in createDraftLane, and never set link_preview_options on either its initial sendMessage or any of its editMessageText calls.

Finalization does not rescue it. editStreamMessage does pass linkPreview, but finalization deliberately skips that edit when the streamed draft text already equals the final text — which is the common case, since the draft is the final message. So the preview survives.

Two details drove the shape of the fix:

  • Every edit needs the field, not just the send. Telegram re-enables the preview on any editMessageText that omits link_preview_options, so setting it once on the first send is not enough.
  • Rich messages are already handled. The rich path expresses this as skip_entity_detection at render time (bot-message-dispatch-draft.ts:111), matching how delivery.send.ts splits the two transports. This PR deliberately leaves that path alone and only fixes the HTML/plain transports, plus the plain fallbacks the rich path drops to on error.

Edit calls go through a small helper that preserves call arity when no preview options apply — appending an explicit undefined would have changed existing three-argument editMessageText assertions without changing behavior.

User Impact

channels.telegram.linkPreview: false now suppresses link previews on streamed replies, matching the non-streamed send path and the documented meaning of the setting. Users who set it stop seeing unfurled cards on the streaming path. Behavior is unchanged when linkPreview is unset or true: no link_preview_options field is sent at all.

Evidence

Three tests added to extensions/telegram/src/draft-stream.test.ts: preview disabled on send and on the follow-up edit, parse_mode preserved alongside it on the HTML transport, and a guard that the field stays absent by default.

Before (fix neutralized, tests present) — the two behavior tests fail, and the default-path guard correctly still passes:

 × disables link previews on the streamed send and on every edit 16ms
 × keeps parse_mode alongside disabled link previews on the HTML transport 4ms

 Test Files  1 failed (1)
      Tests  2 failed | 85 passed (87)

After (fix applied):

$ node scripts/run-vitest.mjs run extensions/telegram/src/draft-stream.test.ts

 Test Files  1 passed (1)
      Tests  87 passed (87)

No regressions in the dispatch paths that build the draft lane:

$ node scripts/run-vitest.mjs run \
    extensions/telegram/src/bot-message-dispatch.draft-finalization.test.ts \
    extensions/telegram/src/bot-message-dispatch.draft-rotation.test.ts \
    extensions/telegram/src/bot-message-dispatch.draft-failures-progress.test.ts

 Test Files  3 passed (3)
      Tests  45 passed (45)

I do not have a live Telegram bot to record the unfurl itself, so the proof here is the transport-level assertion that link_preview_options: { is_disabled: true } now rides on both the send and the edit — which is the exact API contract the issue identifies as missing. The issue reporter states they are carrying a local patch doing the same thing and offered to test a fix.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Jul 26, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 4:45 AM ET / 08:45 UTC.

ClawSweeper review

What this changes

The branch forwards Telegram's existing linkPreview configuration into streamed draft replies and applies the disabled-preview option to plain and HTML sends and edits, with regression coverage.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 3 items remain

Keep this PR open: it is a focused, API-aligned fix for the linked current bug, but the required after-fix real Telegram proof is still absent. Likely related people: steipete is the best routing candidate (medium confidence) from the active branch update, assignment, and the merged Telegram-proof harness work.

Priority: P2
Reviewed head: 0c2c6ba80121cc9092714fea39912f4730ff0471

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and contract-aligned with useful regression coverage, but merge readiness is capped by mock-only proof for visible Telegram behavior.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR supplies focused test assertions and reported test output, but no redacted after-fix Telegram result shows a streamed URL reply and later edit without a preview; add a live run, recording, terminal/live output, or redacted runtime logs. The merged harness PR makes native Telegram proof practical; redact chat identifiers, endpoints, IP addresses, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR supplies focused test assertions and reported test output, but no redacted after-fix Telegram result shows a streamed URL reply and later edit without a preview; add a live run, recording, terminal/live output, or redacted runtime logs. The merged harness PR makes native Telegram proof practical; redact chat identifiers, endpoints, IP addresses, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current-main behavior: At current main, the streamed-draft function accepts thread, reply, rich-message, throttle, and rendering options but not the channel link-preview preference; its plain and HTML send/edit calls therefore have no disabled-preview option. This matches the reported streaming-only inconsistency.
Patch boundary and coverage: The PR adds the existing resolved telegramCfg.linkPreview at the draft-controller call site, carries the Bot API option on the plain/HTML streamed send and edit paths, and adds tests for disabled previews, HTML parse mode, and the default omission case.
Upstream API contract: Telegram's Bot API defines link_preview_options for both sendMessage and editMessageText, and is_disabled disables a text-message preview. The PR uses that documented field rather than introducing a parallel setting.
Findings None None.
Security None None.

How this fits together

Telegram answer streaming keeps one visible reply message by first sending it and then editing it as tokens arrive. This path receives the resolved Telegram channel configuration and calls the Bot API, so it must preserve the same link-preview preference as ordinary outbound messages.

flowchart LR
  A[Telegram channel config] --> B[Draft reply controller]
  B --> C[Streaming draft builder]
  C --> D{Rich or plain transport}
  D --> E[Initial Telegram send]
  D --> F[Later message edits]
  E --> G[Visible streamed reply]
  F --> G
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR supplies focused test assertions and reported test output, but no redacted after-fix Telegram result shows a streamed URL reply and later edit without a preview; add a live run, recording, terminal/live output, or redacted runtime logs. The merged harness PR makes native Telegram proof practical; redact chat identifiers, endpoints, IP addresses, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The implementation is not yet demonstrated against a real Telegram client, so the exact streamed initial-send and subsequent-edit behavior remains unobserved despite the transport-level assertions.
  • Complete next step (P2) - No code repair is currently indicated; the contributor or assigned reviewer needs to provide the required after-fix real Telegram evidence before merge.
Agent review details

Security

None.

PR surface

Source +34, Tests +69. Total +103 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 41 7 +34
Tests 1 69 0 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 110 7 +103

Review metrics

None.

Mantis proof suggestion

A Telegram Desktop before/after capture can directly prove the user-visible initial-send and follow-up-edit behavior that tests alone cannot show. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify a streamed URL reply and its later edit remain without a link-preview card when linkPreview is false.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the existing channels.telegram.linkPreview contract as the sole control, land this narrow propagation fix only after a redacted live Telegram run shows both the streamed URL reply and a later edit remain without a preview card.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the existing channels.telegram.linkPreview contract as the sole control, land this narrow propagation fix only after a redacted live Telegram run shows both the streamed URL reply and a later edit remain without a preview card.

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

Yes, at source level: current main's streamed draft path omits the resolved linkPreview value and its Bot API options, while the linked report provides a concrete Telegram configuration and streamed-URL scenario. This review did not execute a live Telegram bot run.

Is this the best way to solve the issue?

Yes, conditionally: forwarding the existing setting into the one missing streaming path and using Telegram's documented send/edit option is narrower and more maintainable than adding a new preference or fallback. A live Telegram result is still needed to confirm the client-visible outcome.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a real but bounded Telegram delivery inconsistency for users who explicitly disable link previews.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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 focused test assertions and reported test output, but no redacted after-fix Telegram result shows a streamed URL reply and later edit without a preview; add a live run, recording, terminal/live output, or redacted runtime logs. The merged harness PR makes native Telegram proof practical; redact chat identifiers, endpoints, IP addresses, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change directly affects whether Telegram displays a visible URL-preview card on streamed replies and later in-place edits.

Evidence

What I checked:

  • Current-main behavior: At current main, the streamed-draft function accepts thread, reply, rich-message, throttle, and rendering options but not the channel link-preview preference; its plain and HTML send/edit calls therefore have no disabled-preview option. This matches the reported streaming-only inconsistency. (extensions/telegram/src/draft-stream.ts, ac6009eab195)
  • Patch boundary and coverage: The PR adds the existing resolved telegramCfg.linkPreview at the draft-controller call site, carries the Bot API option on the plain/HTML streamed send and edit paths, and adds tests for disabled previews, HTML parse mode, and the default omission case. (extensions/telegram/src/draft-stream.test.ts, 0c2c6ba80121)
  • Upstream API contract: Telegram's Bot API defines link_preview_options for both sendMessage and editMessageText, and is_disabled disables a text-message preview. The PR uses that documented field rather than introducing a parallel setting.
  • Scoped Telegram review policy: The Telegram guide requires real Telegram proof for behavior PRs that touch transport or streaming; focused synthetic assertions are useful supplemental coverage but do not satisfy that merge gate. (extensions/telegram/AGENTS.md:12, ac6009eab195)
  • Proof infrastructure is available: The related merged harness PR added a delayed streamed link-preview scenario specifically so an initial send and later edit can be exercised before Gateway startup. It supports obtaining the missing live proof but is not itself proof that this branch works against Telegram. (45bad50e2690)

Likely related people:

  • steipete: steipete assigned this PR, updated its current head with the added parity tests, and merged the related Telegram proof-harness work that explicitly supports this scenario. (role: recent Telegram proof and branch contributor; confidence: medium; commits: 0c2c6ba80121, 45bad50e2690; files: extensions/telegram/src/draft-stream.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture redacted real Telegram evidence showing both the initial streamed URL message and a later edit remain without a preview when linkPreview is false.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-07-26T15:26:59.567Z sha f5ccba1db696305fe79b996c787818e0259677b6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T06:55:18.745Z sha 58f925ba8ba2a33a57126f47fde7773bc498753b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T07:29:46.306Z sha 2a85b9b71c53fd7944173ecfdfefe37ec46e80db :: needs real behavior proof before merge. :: none

@steipete steipete self-assigned this Jul 27, 2026
@steipete
steipete force-pushed the fix/telegram-draft-link-preview branch from 58f925b to 2a85b9b Compare July 27, 2026 07:25
Zakaria Rahali and others added 2 commits July 27, 2026 01:34
Replies delivered through draft streaming still unfurled the first URL
even with channels.telegram.linkPreview: false. Non-streamed sends
already honored the flag.

createTelegramDraftStream never received linkPreview and never set
link_preview_options, on either its initial sendMessage or its
editMessageText calls. Finalization could not clean it up: it skips the
final edit when the streamed draft text already equals the final text,
which is the common case, so the draft message stays as-is with the
preview attached.

Passes linkPreview from telegramCfg into the draft stream and applies
link_preview_options: { is_disabled: true } on the send and on every
edit, since an edit that omits the field re-enables the preview
server-side. Rich messages keep expressing this as skip_entity_detection
at render time, which already worked.

Call arity is preserved when no preview options apply, so existing edit
assertions are unaffected.

Closes openclaw#111525

Co-Authored-By: Claude Opus 5 <[email protected]>
@zak-li

zak-li commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

On the outstanding real behavior proof item: I don't have a live Telegram bot setup, so I can't produce a redacted after-fix capture of a streamed URL reply myself.

The mantis: telegram-visible-proof label is already applied here, but the @openclaw-mantis comment trigger in mantis-telegram-desktop-proof.yml gates on authorize_actor requiring maintainer-level repository access, so I can't kick off the harness from my side either.

@steipete since you're assigned and already pushed the parity test commit — would you be able to trigger the native Telegram proof run? Happy to fold the resulting artifact into the PR body and re-request review afterwards.

For what it's worth on the transport contract: the fix carries link_preview_options: { is_disabled: true } on both the initial sendMessage and every editMessageText, because an edit that omits the field re-enables the preview server-side — and finalization can't clean it up, since it skips the final edit when the streamed draft already equals the final text. That skip is what makes this streaming-only. The issue reporter (#111525) also mentions carrying a local patch doing the same thing and offered to test a fix, so they may be able to confirm against a real client if that's easier than a harness run.

@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

pull Bot pushed a commit to yann0001/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  fix(codex): restore connected apps for token-authenticated runs (openclaw#115075)
  fix(codex): classify hosted search timeouts (openclaw#115837)
  fix(msteams): keep attachment replies in channel threads (openclaw#94348)
  fix(telegram): linkPreview:false is ignored on streamed replies (openclaw#114125)
  fix(protocol): make Swift model checks non-mutating (openclaw#115793)
  fix(searxng): avoid duplicating search endpoint (openclaw#113661)
  fix(agents): preserve tool-result middleware identity (openclaw#115821)
  refactor(meetings): consolidate runtime facades (openclaw#115819)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…claw#114125)

* fix(telegram): linkPreview:false is ignored on streamed replies

Replies delivered through draft streaming still unfurled the first URL
even with channels.telegram.linkPreview: false. Non-streamed sends
already honored the flag.

createTelegramDraftStream never received linkPreview and never set
link_preview_options, on either its initial sendMessage or its
editMessageText calls. Finalization could not clean it up: it skips the
final edit when the streamed draft text already equals the final text,
which is the common case, so the draft message stays as-is with the
preview attached.

Passes linkPreview from telegramCfg into the draft stream and applies
link_preview_options: { is_disabled: true } on the send and on every
edit, since an edit that omits the field re-enables the preview
server-side. Rich messages keep expressing this as skip_entity_detection
at render time, which already worked.

Call arity is preserved when no preview options apply, so existing edit
assertions are unaffected.

Closes openclaw#111525

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(telegram): cover streamed reply option parity

Co-authored-by: Zakaria Rahali <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* origin/main:
  fix(codex): restore connected apps for token-authenticated runs (openclaw#115075)
  fix(codex): classify hosted search timeouts (openclaw#115837)
  fix(msteams): keep attachment replies in channel threads (openclaw#94348)
  fix(telegram): linkPreview:false is ignored on streamed replies (openclaw#114125)
  fix(protocol): make Swift model checks non-mutating (openclaw#115793)
  fix(searxng): avoid duplicating search endpoint (openclaw#113661)
  fix(agents): preserve tool-result middleware identity (openclaw#115821)
  refactor(meetings): consolidate runtime facades (openclaw#115819)
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. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

telegram: linkPreview:false is ignored by the draft-streaming path (previews persist on streamed replies)

2 participants