Skip to content

fix(telegram): edit rich callback messages through the rich raw API (#123886) - #124173

Closed
licheer-zte wants to merge 1 commit into
openclaw:mainfrom
licheer-zte:fix/telegram-rich-callback-edits-123886
Closed

licheer-zte wants to merge 1 commit into
openclaw:mainfrom
licheer-zte:fix/telegram-rich-callback-edits-123886

Conversation

@licheer-zte

Copy link
Copy Markdown
Contributor

What Problem

With channels.telegram.richMessages: true, the /models picker is sent through the rich raw API (sendRichMessage), but every callback edit — provider/model selection steps and the final "Model changed" confirmation — went through the legacy bot.api.editMessageText(chatId, messageId, text) text path. Telegram for iOS then rendered the new body over the stale rich picker body, producing overlapping, unreadable text (issue #123886).

Why

createTelegramCallbackMessageActions in extensions/telegram/src/bot-handlers.callback-actions.runtime.ts only ever called the legacy text editMessageText signature. The rich send funnel (send.ts, draft-stream.ts) already routes through getTelegramRichRawApi(api).editMessageText({ chat_id, message_id, rich_message, ... }) — the callback-edit owner was the one path that missed the rich branch, so it edited a rich message as if it were plain text.

User Impact

Telegram users with richMessages: true get a clean model picker: each step replaces the previous rich body in place, and the final confirmation no longer overlaps the stale "Select a provider:" text. Caller-authored HTML edits (e.g. the ✅ Model changed to <b>…</b> confirmation) stay on the legacy parse_mode: HTML path per the rich-wire blocks-only contract, and any rich-edit failure falls back to the previous legacy text edit — so nothing regresses when the rich raw API is unavailable.

Evidence

New unit tests in extensions/telegram/src/bot-handlers.callback-actions.runtime.test.ts (6/6 pass) covering rich routing, legacy fallback, HTML-mode preservation, not-modified re-raise, and missing-raw-API fallback:

 ✓  extension-telegram  ../../extensions/telegram/src/bot-handlers.callback-actions.runtime.test.ts (6 tests) 29ms

 Test Files  3 passed (3)
      Tests  14 passed (14)
   Start at  20:49:34
   Duration  13.18s (transform 6.14s, setup 544ms, import 12.34s, tests 69ms, environment 0ms)

Also verified with the full callback-related suites (bot-handlers.callback-questions.runtime.test.ts, approval-handler.runtime.test.ts) — all 14 tests pass, and tsc -p extensions/telegram/tsconfig.json reports no new errors from these files (the 6 remaining errors in that project pre-exist on origin/main and touch unrelated files: inbound-debounce, bot-message-context, bot-native-commands, state-migrations).

Note: this sandbox cannot run a live Telegram bot; per ClawSweeper's own review this is a source-reproducible representation mismatch with a clear focused test boundary (clawsweeper:source-repro, no needs-live-repro label).

[AI-assisted]

With channels.telegram.richMessages enabled the /models picker sends a
rich message, but callback edits (provider/model selection, final
confirmation) went through the legacy editMessageText text path, so
Telegram for iOS rendered the new body over the stale rich picker text.
Route callback edits through the rich raw API when rich messages are on
(caller-authored HTML edits keep legacy parse_mode HTML semantics), with
fallback to the legacy text edit when the rich edit fails.

Fixes openclaw#123886
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S r: too-many-prs Auto-close: author has more than twenty active PRs. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

a-yeyang pushed a commit to a-yeyang/openclaw that referenced this pull request Aug 24, 2026
…nclaw#123886)

The /models picker sends its initial body as a rich message when
richMessages is enabled; every lifecycle edit (provider list, model
list, pagination) already routes through the rich funnel via
createTelegramCallbackMessageActions. The final selection confirmation
was the one exception: it always fell back to the legacy HTML
editMessageText path, so Telegram rendered the new confirmation text
mixed with/over the prior rich body's stale markup instead of fully
replacing it.

- Add TelegramCallbackRichTextOverride so a parse_mode: "HTML" edit can
  opt back onto the rich funnel with hand-built blocks, following the
  progress-draft-preview.ts precedent.
- editCallbackMessage/editCallbackMessageWithButtons accept an optional
  richTextOverride; when richMessages is on, edits route through
  getTelegramRichRawApi(...).editMessageText with rich_message blocks
  instead of the legacy text funnel.
- buildModelSelectionConfirmation builds both the HTML and rich-block
  confirmation bodies from shared text-building logic, escaping only
  in the HTML variant (rich blocks are not parsed as markup).
- Split the ~290-line handleTelegramModelCallback function out of
  bot-handlers.callback-router.ts into bot-handlers.model-callback.ts
  to keep the router file under the repo's 700-line oxlint cap after
  the fix's additions.

Non-rich accounts are unaffected; the legacy HTML path is unchanged
for that funnel.

Supersedes closed PR openclaw#124173, which fixed the rich-block introduction
but left the confirmation edit on the legacy HTML path per
ClawSweeper's own review of that PR (partial_overlap).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram r: too-many-prs Auto-close: author has more than twenty active PRs. size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant