fix(telegram): tighten table row-group spacing and drop redundant first bullet#32433
Merged
kshitijk4poor merged 1 commit intoMay 26, 2026
Conversation
…st bullet
The GFM → Telegram-row-group rewriter previously joined every line in
every row with a blank line ("\n\n".join(rendered_rows)), which made
multi-column tables explode into one-bullet-per-paragraph walls on
mobile. It also emitted the row heading twice when the table had no
row-label column: once as the standalone bold heading and once again
as the first labeled bullet (heading == headers[0] == data_cells[0]).
This commit:
* Uses single newlines between the heading and its bullets within a
row-group, and a blank line only BETWEEN row-groups.
* Skips any bullet whose value duplicates the heading text when the
table has no row-label column (the heading already carries that
information). Tables WITH a row-label column are unaffected since
the heading comes from the label cell and never duplicates a header.
Updated existing test assertions accordingly and added two regression
tests: one that reproduces the screenshot bug (wide five-column "Plays"
comparison table) and one that pins the row-label-column behavior so
the dedup logic doesn't accidentally swallow real data.
tests/gateway/test_telegram_format.py: 101 passed
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.
Summary
Salvage of #29775 by @krislidimo onto current main.
Telegram's pipe-table rewriter turns GFM tables into bold-heading + bulleted-cell row-groups (since MarkdownV2 has no table syntax). Two visual bugs were making wide tables unreadable on mobile:
"\n\n".join(rendered_rows)— every line, including bullets inside the same row-group, was separated by a blank line. Telegram renders blank lines as paragraph breaks, so a five-column comparison table became one-bullet-per-paragraph wall-of-text.Duplicate first bullet. When the table had no row-label column, the heading was set to
data_cells[0]and then re-emitted as the first labeled bullet (• Player: Alicedirectly under**Alice**).Fix
gateway/platforms/telegram.py::_render_table_block_for_telegram:has_row_label_col=False, skip any bullet whose value equals the heading (the duplicated first cell). Row-label tables are untouched because their heading comes from the label cell and never duplicates a header value.After fix, the screenshot scenario renders as:
Salvage notes
_render_table_block_for_telegramand its callers were untouched since the PR's merge-base —git cherry-pickapplied cleanly with no conflicts._render_table_block_for_telegram/_wrap_markdown_tablesare only used insidegateway/platforms/telegram.pyand its tests — no cross-platform impact.krislidimo@gmail.com) preserved via plain cherry-pick.Tests
tests/gateway/test_telegram_format.pyupdated to match the new spacing + dedup behavior (the old assertions documented the bug as expected behavior).test_row_group_uses_single_newlines_within_group— pins the exact screenshot scenario (5-column comparison table) and asserts no"\n\n• "substring anywhere in the output.test_row_label_column_preserves_first_bullet— pins the row-label-table case so the dedup logic doesn't accidentally swallow real data when the heading IS distinct from any cell.tests/gateway/test_telegram_format.py: 101 passed.tests/gateway/: 5911 passed.Closes #29775