fix(feishu): route tables and multi-line code blocks to CardKit 2.0#19038
Closed
shiping430 wants to merge 1 commit into
Closed
fix(feishu): route tables and multi-line code blocks to CardKit 2.0#19038shiping430 wants to merge 1 commit into
shiping430 wants to merge 1 commit into
Conversation
Feishu's post/md tag silently drops GFM table rows and truncates fenced code blocks after ~6 lines with no way to expand. Fix by detecting these patterns in _build_outbound_payload and routing them to CardKit 2.0 interactive cards instead: - Tables: detect via _TABLE_MARKDOWN_RE (|cells| + |---| separator) - Code blocks: detect via _CODE_BLOCK_RE (opening fence + 2+ content lines + closing fence); 1-2 line blocks render fine in post/md and are left unchanged CardKit 2.0's tag=markdown element natively supports GFM tables and fenced code blocks with scrollable rendering and a Copy button. Fixes NousResearch#19035 (code block truncation) Fixes NousResearch#9549 (table rendering)
23 tasks
This was referenced May 5, 2026
Contributor
|
Thanks for the PR. Closing because the immediate user-visible bug (tables rendering as blank in Feishu) was already fixed on main via #20275 (salvage of #13723) — tables now fall back to plain text, which is readable if not pretty. The CardKit 2.0 upgrade would be a real improvement for both tables and code blocks, but landing it without a live Feishu bot to validate — and without a fallback when a bot doesn't have card permission — is a risk we aren't in a position to accept right now. If you're able to test this against a real Feishu bot and add a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feishu's
post/mdtag has two rendering limitations that this PR fixes:(| col1 | col2 | ... |)is silently dropped; rows after the separator line don't appearBoth are fixed by detecting these patterns in
_build_outbound_payloadand routing them to CardKit 2.0interactivemessage format instead ofpost. CardKit 2.0'stag: markdownelement natively supports GFM tables and fenced code blocks with scrollable rendering and a Copy button.Changes
gateway/platforms/feishu.py:_TABLE_MARKDOWN_RE— matches GFM tables (| cells |rows +|---|separator)_CODE_BLOCK_RE— matches fenced code blocks with 2+ content lines (1-2 line blocks are unaffected; they render fine in post/md)_build_outbound_payloadto check these patterns before the generic markdown hint and route matching content to_build_card_payload→msg_type: interactive_build_card_payload— builds a CardKit 2.0 card withtag: markdownelementWhy CardKit 2.0
CardKit 2.0's
markdownelement is the officially recommended way to render markdown that Feishu'spost/mdtag doesn't support. It handles tables natively and renders code blocks with scroll + copy — no custom parsing needed.Testing
Regex patterns tested:
_TABLE_MARKDOWN_RE→ matches tables, does not false-positive on non-table content_CODE_BLOCK_RE→ matches 3-line+ code blocks, does not match inline code or 2-line blocksRelated Issues
_should_send_as_card()trigger condition #9536, ## Problem When sending markdown table syntax (| col1 | col2 |) in Feishu, the message displays as plain text instead of being rendered as a table. This works correctly in OpenClaw. ## Environment - Hermes Agent version: [latest] - Feishu integration via WebSocket - Using native markdown table syntax in messages ## Expected behavior Markdown tables should render as formatted Feishu table messages, similar to how OpenClaw handles them. ## Screenshots [Attach screenshot comparing OpenClaw vs Hermes Agent rendering] ## Additional context The Feishu platform adapter usespostmsg_type with markdown, but the markdown hint regex may not be detecting table syntax properly. #7310 (same root cause)