Skip to content

fix(feishu): render Markdown tables using interactive card with table component - #16194

Open
highland0971 wants to merge 1 commit into
NousResearch:mainfrom
highland0971:fix/feishu-table-rendering
Open

highland0971 wants to merge 1 commit into
NousResearch:mainfrom
highland0971:fix/feishu-table-rendering

Conversation

@highland0971

Copy link
Copy Markdown

Problem

Markdown tables were silently dropped in Feishu messages:

  1. _MARKDOWN_HINT_RE didn't detect | character for table syntax
  2. Feishu md tag doesn't support Markdown tables - content returns empty [[]]

Solution

  1. Add (^\s*\|) pattern to _MARKDOWN_HINT_RE for table detection
  2. Add _parse_markdown_table() to extract table structure from content
  3. Add _build_table_card_payload() to generate Feishu interactive card JSON
  4. Modify _build_outbound_payload() to use interactive msg_type for tables

Feishu Table Format

Reference: github.com/alexaundre/mycc_init buildTableCard

{
  "tag": "table",
  "columns": [{"name": "col_0", "display_name": "Header", "data_type": "text", "width": "auto"}],
  "rows": [{"col_0": "value"}]  // object format with keys matching column names
}

Testing

  • Local instance: verified table rendering
  • CT108 (多吉) instance: deployed and verified

Screenshots

Before: tables silently dropped, empty content
After: tables render correctly as Feishu table component

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Likely duplicate of #12114 — same fix: route GFM tables to Feishu Card v2 native table component in gateway/platforms/feishu.py.

… component

Problem: Markdown tables were silently dropped in Feishu messages.
- _MARKDOWN_HINT_RE didn't detect '|' character for table syntax
- Feishu 'md' tag doesn't support Markdown tables (content returns empty [[]])

Solution:
1. Add '(^\s*\|)' pattern to _MARKDOWN_HINT_RE for table detection
2. Add _parse_markdown_table() to extract table structure from content
3. Add _build_table_card_payload() to generate Feishu interactive card JSON
4. Modify _build_outbound_payload() to use 'interactive' msg_type for tables

Feishu table format (reference: github.com/alexaundre/mycc_init):
- columns: [{name, display_name, data_type, width}]
- rows: [{col_0: 'value', col_1: 'value', ...}] (object format)

Tested: Local + CT108 (多吉) instance, table rendering verified.
@C-fog

C-fog commented May 4, 2026

Copy link
Copy Markdown

多表格场景未处理

_parse_markdown_table() 只解析第一个 Markdown 表格就 break 了,after_table 中的后续表格以 lark_md 纯文本渲染,用户看到的是竖线原始文本而非表格。

复现: 一条消息包含多个表格时,只有第一个正确渲染为飞书 Card table 组件,其余全部退化。

建议修复方向: 循环解析多个表格,每个生成独立的 table 组件(飞书 Card 上限 5 个 table)。超过 5 个时可拆为多条消息或截断提示。

当前 workaround:手动拆成每天一条消息发送。

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for tackling a real Feishu rendering limitation. The blank-message symptom is already mitigated on current main: plugins/platforms/feishu/adapter.py:4524-4534 detects pipe tables and routes them to text, but main does not yet provide the native interactive table rendering proposed here.

Problems

  • _parse_markdown_table() stops after the first matched table. Later tables remain in after_table and _build_table_card_payload() emits that content as lark_md, matching the multiple-table failure reported in the discussion.
  • The PR adds no tests, and its only changed path, gateway/platforms/feishu.py, was moved to plugins/platforms/feishu/adapter.py by 5600105478ffde29d7566b45421b100eaa29c4ef.

Suggested changes

  • Port the implementation to plugins/platforms/feishu/adapter.py and retain text fallback for unsupported card payloads.
  • Parse ordered text/table segments so multiple tables are rendered or safely capped.
  • Add current-surface tests for multi-table input, fenced-code false positives, and fallback behavior.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have needs-decision Awaiting maintainer decision before any implementation and removed type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants