Skip to content

fix(feishu): markdown table auto-wrap + card content, text parsing, reply truncation, parent_id fallback - #19312

Closed
resurgence wants to merge 2 commits into
NousResearch:mainfrom
resurgence:fix/feishu-card-v3
Closed

fix(feishu): markdown table auto-wrap + card content, text parsing, reply truncation, parent_id fallback#19312
resurgence wants to merge 2 commits into
NousResearch:mainfrom
resurgence:fix/feishu-card-v3

Conversation

@resurgence

Copy link
Copy Markdown

Summary

8 Feishu patches for Hermes gateway, combining existing fixes with a new markdown table rendering fix.

Patches included:

  1. card_msg_content_type via add_query() — Get real card content instead of placeholder text
  2. _fetch_message_text uses Patch 1 request — Auto-includes user_card_content param
  3. _fetch_message_detail REST fallback — New method to fetch full message from API
  4. parent_id REST fallback — Complete reply chain when WebSocket event lacks parent_id
  5. text tag content extraction — Add "text" to _collect_text_segments rich block trigger set
  6. 3000 char truncation + Chinese prompt — Raise reply_to_text limit from 500 to 3000 chars
  7. Replying to earlier message marker — Detect history repeats, show compact marker
  8. Markdown table auto-wrap (NEW) — Wrap markdown table blocks in code fences before outbound, preventing Feishu text channel from stripping table content
  9. lines[:100] expansion — Interactive message line limit from 12 to 100

New in this update (Patch 8):

Feishu text message type strips markdown table syntax entirely, and the post type md tag does not support native tables either. The _wrap_markdown_tables() method detects table blocks via _MARKDOWN_TABLE_BLOCK_RE and wraps them in code fences. The code fences trigger _MARKDOWN_HINT_RE, routing the message through the post channel where code blocks render correctly.

Files changed:

  • gateway/platforms/feishu.py
  • gateway/run.py

Testing:

  • Round 1 (before fix): Tables in replies disappeared on Feishu
  • Round 2 (after fix): 3 tables (5/7/9 rows) all rendered correctly via code block wrapping

Closes: Previous closed PR #17709

root added 2 commits April 30, 2026 10:00
…arent_id REST fallback

Cherry-pick from origin/fix/feishu-card-content-and-text-parsing onto upstream/main:
- card_msg_content_type='user_card_content' for interactive message detail API
- Add 'text' tag to _collect_text_segments for card text extraction
- Increase action lines limit from 12 to 100
- Raise reply_to_text limit from 500 to 3000 chars with Chinese truncation marker
- session_id injection via event._session_id
- _fetch_message_detail REST fallback for missing parent_id
- History-aware reply marker

Also applied async build_channel_directory from stash@{0}:
- startup: await build_channel_directory
- reconnect: await build_channel_directory
- cron ticker: run_coroutine_threadsafe with 10s timeout
…s (Patch 8)

Feishu text message type strips markdown table syntax entirely,
and the post type md tag doesn't support native tables either.
Pre-process outbound content with _wrap_markdown_tables() to
detect table blocks via _MARKDOWN_TABLE_BLOCK_RE and wrap them
in code fences. The code fences trigger _MARKDOWN_HINT_RE which
routes the message through the post channel where code blocks
render correctly.

Fixes: tables in replies disappearing on Feishu
@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 May 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #10336 (same card content/text parsing/parent_id patches) and #17006 / #16194 (competing markdown table approaches). This PR supersedes #10336 with additional table auto-wrap fix.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #10336, #17006, #16194

@resurgence resurgence closed this May 3, 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 P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants