Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions gateway/platforms/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,32 @@ def _render_table_block_for_telegram(table_block: list[str]) -> str:
if len(headers) < 2:
return "\n".join(table_block)

# Detect row-label column: present when data rows have one more cell
# than the header row (the row-label column carries no header).
first_data_row = _split_markdown_table_row(table_block[2]) if len(table_block) > 2 else []
has_row_label_col = len(first_data_row) == len(headers) + 1

rendered_rows: list[str] = []
for index, row in enumerate(table_block[2:], start=1):
cells = _split_markdown_table_row(row)
if len(cells) < len(headers):
cells.extend([""] * (len(headers) - len(cells)))
elif len(cells) > len(headers):
cells = cells[: len(headers)]
if has_row_label_col:
# First cell is the row-label (heading); remaining cells align with headers.
heading = cells[0] if cells and cells[0] else f"Row {index}"
data_cells = cells[1:]
else:
# No row-label column: use first non-empty cell as heading.
heading = next((cell for cell in cells if cell), f"Row {index}")
data_cells = cells

# Pad or trim data_cells to match headers length.
if len(data_cells) < len(headers):
data_cells.extend([""] * (len(headers) - len(data_cells)))
elif len(data_cells) > len(headers):
data_cells = data_cells[: len(headers)]

heading = next((cell for cell in cells if cell), f"Row {index}")
rendered_rows.append(f"**{heading}**")
rendered_rows.extend(
f"• {header}: {value}" for header, value in zip(headers, cells)
f"• {header}: {value}" for header, value in zip(headers, data_cells)
)

return "\n\n".join(rendered_rows)
Expand Down
6 changes: 3 additions & 3 deletions hermes_cli/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def generate_zsh(parser: argparse.ArgumentParser) -> str:
typeset -A opt_args

_arguments -C \\
'(-h --help){{-h,--help}}[Show help and exit]' \\
'(-V --version){{-V,--version}}[Show version and exit]' \\
'(-p --profile){{-p,--profile}}[Profile name]:profile:_hermes_profiles' \\
'(-)'{-h,--help}'[Show help and exit]' \\
'(-)'{-V,--version}'[Show version and exit]' \\
'(-)'{-p,--profile}'[Profile name]:profile:_hermes_profiles' \\
'1:command:->commands' \\
'*::arg:->args'

Expand Down