Skip to content

feat(feishu): auto-convert markdown tables to native table component - #43882

Closed
UniGood wants to merge 2 commits into
NousResearch:mainfrom
UniGood:unigood/feishu-table-to-card-v2
Closed

feat(feishu): auto-convert markdown tables to native table component#43882
UniGood wants to merge 2 commits into
NousResearch:mainfrom
UniGood:unigood/feishu-table-to-card-v2

Conversation

@UniGood

@UniGood UniGood commented Jun 11, 2026

Copy link
Copy Markdown

What does this PR do?

Converts markdown tables in Feishu outbound messages to native Feishu card v2 interactive tables, replacing the previous plain-text fallback with raw pipe characters.

Related Issue

Fixes #41980

Type of Change

  • New feature (non-breaking change which adds functionality)

Changes Made

  • **** — Parses markdown table content and builds a Feishu card v2 JSON with native table component. Returns None on failure (caller falls back to plain text).
  • **** — Builds a Feishu card v2 table component dict from a parsed table segment (columns + rows).
  • _parse_table_segments(content) — Splits content into alternating text/table segments. Tables are parsed into header + rows dicts.
  • _TABLE_MAX_ROWS = 50 — Truncation threshold; large tables get a warning note.
  • Modified _build_outbound_payload() — Tries card conversion first when table detected; falls back to plain text on failure.

tests/gateway/test_feishu.py

  • 11 tests in TestBuildTableCardPayload covering:
    • Single table → card with native table component
    • Mixed text + table
    • Multiple tables in one message
    • Large table truncation (>50 rows)
    • Malformed input handling
    • Empty/whitespace input
    • Alignment markers stripped
    • Integration with _build_outbound_payload()

How to Test

python -m pytest tests/gateway/test_feishu.py -x -q

All 216 tests pass.

Checklist

  • Tests pass locally
  • No breaking changes
  • Code follows existing style

UniGood added 2 commits June 8, 2026 17:31
Feishu post-type 'md' elements cannot render markdown tables. When the
adapter detects a table in outbound content, it now converts it to a
Feishu card v2 interactive card using the native 'table' component
instead of falling back to plain text with raw pipe characters.

No LLM involved — pure regex detection + string parsing, zero additional
latency.

Changes:
- _build_table_card_payload(): Parses markdown tables and builds a Feishu
  card v2 JSON with native table component (columns + rows).
- _build_feishu_table_element(): Builds the table element dict.
- _parse_table_segments(): Splits content into text/table segments.
- _TABLE_MAX_ROWS = 50: Truncation threshold for large tables.
- Modified _build_outbound_payload() to try card conversion first.
- 11 new tests covering single table, mixed text+table, multiple tables,
  large table truncation, malformed input, and alignment marker stripping.
…rsion

- Change default card title from '📊 数据' to '📊 Data'
- Change truncation message from Chinese to English
- Update test assertion to match new English message
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jun 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #12114 — converting Feishu outbound markdown tables to a native Card v2 table component is a heavily-saturated cluster (#17006, #38453, #18155, same-author closed #41980 all implement the same feature). Marking as duplicate of the canonical open PR #12114.

@UniGood UniGood closed this Jun 11, 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 duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have 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