Skip to content

fix(telegram): tighten table row-group spacing and drop redundant first bullet#32433

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/telegram-table-density-29775
May 26, 2026
Merged

fix(telegram): tighten table row-group spacing and drop redundant first bullet#32433
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/telegram-table-density-29775

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

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:

  1. "\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.

  2. 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: Alice directly under **Alice**).

Fix

gateway/platforms/telegram.py::_render_table_block_for_telegram:

  • Single newline between heading and its bullets within a row-group, blank line only between row-groups.
  • When 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:

**A. Copy Handsanitizer2 (HK+SZ)**
• Capital: $5-10k
• Build: 2 wk
• $/day: $30-70
• Risk: Low

**B. NO-sweeper (Hans323-style)**
• Capital: $50-100k
...

Salvage notes

  • 504 commits behind main, but _render_table_block_for_telegram and its callers were untouched since the PR's merge-base — git cherry-pick applied cleanly with no conflicts.
  • _render_table_block_for_telegram / _wrap_markdown_tables are only used inside gateway/platforms/telegram.py and its tests — no cross-platform impact.
  • Original commit by @krislidimo (krislidimo@gmail.com) preserved via plain cherry-pick.

Tests

  • 5 existing assertions in tests/gateway/test_telegram_format.py updated to match the new spacing + dedup behavior (the old assertions documented the bug as expected behavior).
  • 2 new regression tests:
    • 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.
  • Full tests/gateway/: 5911 passed.

Closes #29775

…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
@kshitijk4poor kshitijk4poor merged commit 9d10c45 into NousResearch:main May 26, 2026
17 of 18 checks passed
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants