Skip to content

fix(telegram): remove duplicate heading and fix multi-row table rendering#29366

Closed
Deserett wants to merge 6 commits into
NousResearch:mainfrom
Deserett:main
Closed

fix(telegram): remove duplicate heading and fix multi-row table rendering#29366
Deserett wants to merge 6 commits into
NousResearch:mainfrom
Deserett:main

Conversation

@Deserett

Copy link
Copy Markdown

Problem

When converting markdown tables to Telegram-friendly bullet lists, the first cell was used as the row heading but remained in data_cells, causing duplicate output:

**Вечер (18:00–21:00)**
• Время: Вечер (18:00–21:00)  ← duplicate
• Температура: +17°C

Additionally, the headers slice was inside the loop, breaking multi-row tables (headers became empty on second iteration).

Solution

  1. Remove first cell from data_cells after extracting as heading (eliminates duplicate)
  2. Move headers[1:] slice before the loop (fixes multi-row tables)
  3. Change row separator from \n\n to \n within groups, keep \n\n between groups (cleaner output)

Testing

  • All 10 existing tests in tests/gateway/test_telegram_format.py::TestWrapMarkdownTables pass
  • Manually tested with weather digest cronjob — no duplicates, proper spacing between time periods

Files Changed

  • gateway/platforms/telegram.py_render_table_block_for_telegram() function
  • tests/gateway/test_telegram_format.py — updated assertions to match new behavior

Fixes: _render_table_block_for_telegram() in gateway/platforms/telegram.py

When converting markdown tables to Telegram-friendly bullet lists,
the first cell was used as the row heading but remained in data_cells,
causing duplicate output like:

  **Вечер (18:00–21:00)**
  • Время: Вечер (18:00–21:00)  ← duplicate
  • Температура: +17°C

Now the first cell is removed from data_cells after being extracted
as the heading, eliminating the duplication.

Additionally:
- Fixed headers slice to happen once before the loop (was inside loop, breaking multi-row tables)
- Changed row separator from double newline to single newline for cleaner output

Fixes: _render_table_block_for_telegram() in gateway/platforms/telegram.py
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists labels May 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Supersedes closed #29333 (one-line fix for duplicate heading only). This PR additionally fixes multi-row table rendering (headers slice moved before loop) and adjusts row separator spacing.

@Deserett Deserett closed this Jun 7, 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.

2 participants