Skip to content

feat(feishu): render markdown tables as Feishu interactive card table elements - #27768

Closed
jefferyzhang963 wants to merge 1 commit into
NousResearch:mainfrom
jefferyzhang963:feat/feishu-markdown-table-card
Closed

feat(feishu): render markdown tables as Feishu interactive card table elements#27768
jefferyzhang963 wants to merge 1 commit into
NousResearch:mainfrom
jefferyzhang963:feat/feishu-markdown-table-card

Conversation

@jefferyzhang963

Copy link
Copy Markdown

Summary

Convert markdown tables in outbound Feishu messages to interactive-card JSON 2.0 native table elements instead of falling back to plain text.

Problem

Feishu post-type md elements cannot render markdown tables — sending table content as post causes the message to appear blank on the client. The workaround was to force plain text for anything that looked like a markdown table (_MARKDOWN_TABLE_RE). This makes tables barely readable.

Solution

When _build_outbound_payload detects a markdown table, it now:

  1. Splits the content into alternating text/table segments
  2. Parses each table into headers + data rows
  3. Builds a Feishu interactive card with:
    • markdown elements for surrounding prose
    • table elements (with lark_md data type) for each detected table
  4. Falls back to plain text if the card exceeds Feishu 30KB size limits

The card uses wide_screen_mode: true and row_height: "low" for compact rendering.

Changes

gateway/platforms/feishu.py (+207 / -11)

  • New functions (lines 608–770): _is_table_separator_row, _parse_table_row, _pad_row, _parse_markdown_table, _split_content_by_tables, _build_table_card_element, _build_interactive_table_card
  • Modified _build_outbound_payload: table detection now returns ("interactive", card_json) instead of ("text", ...)
  • Modified send(): added interactive-card failure fallback (exception + response check)
  • Modified edit_message(): added interactive-card failure fallback

tests/gateway/test_feishu.py (+333)

  • 18 new tests in TestFeishuMarkdownTableCard covering:
    • Row/separator/table parsing
    • Content splitting (text-only, table-only, mixed, multiple tables)
    • Card JSON generation (single table, table + surrounding text, no table)
    • _build_outbound_payload integration (returns interactive for table, post for non-table)
    • Full send() integration (interactive card sends, API error fallback, response failure fallback)
    • edit_message() integration

Verification

  • ✅ All 216 tests pass (198 existing + 18 new)
  • ✅ Zero regressions
  • ✅ Backward compatible: no-table messages still use post/text routing

Screenshots

Before: plain text table → barely readable
After: native Feishu card table with proper column alignment, inline markdown rendering

… elements

Convert markdown tables in outbound messages to Feishu interactive-card
JSON 2.0 native `table` elements instead of falling back to plain text.

Previously, the adapter detected markdown tables and forced plain-text
rendering because Feishu's post-type 'md' elements cannot render tables.
Now it builds an interactive card with alternating `markdown` (for
surrounding prose) and `table` (for each detected table) elements.

Changes:
- Add markdown table parser and card builder functions
- Modify _build_outbound_payload to return interactive cards for tables
- Add interactive-card failure fallbacks in send() and edit_message()
- 18 new tests covering parsing, card generation, send/edit paths,
  and API error fallbacks

Fixes the issue where reply text disappears on Feishu client when the
message contains markdown tables.
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #12114 — this is the 10th+ competing PR for Feishu markdown table → interactive card rendering. See also #24249, #25453, #17006, #20152, #27046, #26429, #27328. The canonical PR is #12114.

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/feishu Feishu / Lark adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants