Skip to content

feat(feishu): use interactive card messages for markdown rendering#21000

Open
Only-Code-A wants to merge 2 commits intoNousResearch:mainfrom
Only-Code-A:feat/feishu-interactive-card-markdown
Open

feat(feishu): use interactive card messages for markdown rendering#21000
Only-Code-A wants to merge 2 commits intoNousResearch:mainfrom
Only-Code-A:feat/feishu-interactive-card-markdown

Conversation

@Only-Code-A
Copy link
Copy Markdown
Contributor

@Only-Code-A Only-Code-A commented May 7, 2026

Summary

Upgrade Feishu card messages from Card JSON 1.0 to Card JSON 2.0 structure, enabling full markdown rendering including headings, tables, and blockquotes.

Problem

The legacy Card JSON 1.0 markdown elements have severely limited rendering:

  • ## Heading renders as raw text
  • | Table | not rendered at all
  • > Blockquote not rendered
  • Tables in responses caused blank messages (had a workaround forcing plain text fallback)

Solution

Upgrade to Card JSON 2.0 ("schema": "2.0") which uses rich text markdown elements supporting the full markdown spec:

Feature Card JSON 1.0 Card JSON 2.0
Bold/Italic/Strikethrough
Inline code
Code blocks
Links
Ordered/unordered lists
Headings (# ## ###)
Tables
Blockquotes (>)

Changes

  • Add "schema": "2.0" declaration to card payload
  • Move elements under body.elements (2.0 structure requirement)
  • Update _build_markdown_card_payload() to produce Card JSON 2.0 structure
  • Remove legacy workarounds (table-to-plain-text fallback no longer needed)
  • Update fallback logic in send/edit/retry to handle interactive type alongside post

Testing

Manually verified on Feishu client (desktop + mobile):

  • ✅ Headings (#/##/###) render correctly with proper sizing
  • ✅ Tables render with proper alignment and borders
  • ✅ Blockquotes render with quote styling
  • ✅ Code blocks with syntax highlighting
  • ✅ Bold, italic, lists, links all work
  • ✅ Long messages split correctly across multiple elements
  • ✅ Fallback to plain text still works when card fails

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels May 7, 2026
@Only-Code-A Only-Code-A force-pushed the feat/feishu-interactive-card-markdown branch 2 times, most recently from 56b8b5a to 7c263e6 Compare May 7, 2026 04:37
…n support

Feishu's legacy card JSON 1.0 markdown elements have severely limited rendering:
- No heading support (## renders as raw text)
- No table support (| xxx | not rendered)
- No blockquote support (> not rendered)
- Tables in responses caused blank messages (had a workaround forcing plain text)

Upgrade to Card JSON 2.0 structure which uses rich text markdown elements that
render the full markdown spec reliably across all Feishu clients:
- Headings (# ## ###)
- Tables (| header | with separator rows)
- Blockquotes (> quoted text)
- Bold, italic, strikethrough, inline code
- Code blocks with language highlighting
- Ordered/unordered lists with nesting
- Links and emoji

Changes:
- Add Card JSON 2.0 schema declaration ("schema": "2.0")
- Move elements under body.elements (2.0 structure requirement)
- Update _build_markdown_card_payload() to produce Card JSON 2.0 structure
- Remove legacy workarounds (table-to-plain-text fallback no longer needed)
- Update fallback logic in send/edit/retry to handle 'interactive' type
  alongside 'post'
@Only-Code-A Only-Code-A force-pushed the feat/feishu-interactive-card-markdown branch from 7c263e6 to 6e75618 Compare May 7, 2026 04:41
The adapter now uses interactive card messages (Card JSON 2.0) instead
of post-type messages for markdown content. Update 6 test assertions:
- msg_type 'post' → 'interactive'
- payload structure from zh_cn.content rows to schema 2.0 body.elements
- element tag from 'md' to 'markdown', key from 'text' to 'content'
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