Repository navigation
fix(telegram): route Markdown tables to rich messages - #1832
Open
key1989han wants to merge 1 commit into
Open
key1989han wants to merge 1 commit into
key1989han wants to merge 1 commit into
Conversation
Telegram's legacy HTML parse mode has no table element, so a Markdown table sent through markdownToTelegramHTML reached the user as raw pipe-delimited rows. Only messages carrying canonical Parts or LaTeX math took the sendRichMessage path, which is the one that renders tables. Detect a Markdown table (header row followed by a delimiter row) in the rich-path gate and rename renderTelegramMarkdownMathRichMessage to renderTelegramMarkdownRichMessage to match its widened role. Call sites in stream.go and telegram.go only change the name.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author
Type
Summary
A Markdown table in an assistant reply reached Telegram as raw pipe-delimited text (
| a | b |and|---|---|shown literally) instead of a rendered table. Plain prose in the same chat rendered fine, and adding a line of LaTeX math to the same message made the whole message — table included — render correctly, which located the problem in path selection rather than in the transport.Two outbound paths exist for this channel. The rich path (
sendRichMessagewithInputRichMessage.markdown) renders tables, headings, checklists, and footnotes. The legacy path (formatTelegramOutput->markdownToTelegramHTMLwithparseMode: HTML) has no table element at all, so table rows were passed through untouched. Selection inshouldUseTelegramFinalRichMessageandrenderTelegramOutboundBodyonly consulted canonicalPartsand LaTeX math, so a table-only message always fell through to the legacy path.This change teaches the rich-path gate about Markdown tables and renames
renderTelegramMarkdownMathRichMessagetorenderTelegramMarkdownRichMessageto match its widened role. A table is detected as a header row immediately followed by a delimiter row of dashes with optional alignment colons, so stray pipes in prose or inline code are not misread. Messages with neither math nor a table keep using the legacy path, so nothing changes for the common case. The existing rich-length guard and plain-text fallback still apply.Related Issues
Closes #1826
Validation
go test ./internal/channel/adapters/telegram/passes on the patched tree, against currentmain(5db320a), including four new tests:TestTelegramMarkdownHasTable(positive cases with outer pipes, alignment colons, Persian header cells; negative cases for pipes in prose, a separator row without a header, a single-column separator, and plain prose),TestRenderTelegramMarkdownRichMessageTableRoutesToRich,TestRenderTelegramMarkdownRichMessagePlainTextStaysLegacy, andTestShouldUseTelegramFinalRichMessageForTable.mise run lint(golangci-lint) and the widergo test ./internal/...sweep, because the toolchain installed for this session only covers the affected package. The change is confined to one package and adds no new imports.Screenshots / Recordings
No capture is available here: reproducing the visual difference needs a live Telegram bot channel and a Telegram client, and this session has neither a bot token nor browser access to Telegram clients. Verification is therefore the unit tests above plus the before/after screenshots already attached to #1826, which show the raw pipe rows and a correctly rendered table from the same Markdown source.
Human QA