feat: 解析飞书 interactive 卡片内容到历史上下文 - #240
Merged
Merged
Conversation
历史消息中 interactive 类型卡片被白名单 drop,导致 bot 拉不到话题开头的卡片内容(如 SpaceX/XOVR 分享卡)。 - 新增 formatInteractiveCard():递归解析卡片 header.title + elements (div/markdown/note/column_set/action),未知 tag 走 content 字段兜底 - client.ts fetchRecentMessages 白名单加入 interactive,parsing 分支调用 formatInteractiveCard - message-parser.ts formatMergeForwardSubMessage interactive 分支同步切换 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
覆盖 header/div/fields/note/column_set/action 已知 tag,以及第三方卡片未知 tag 的兜底,共 12 个用例。同步更新 merge-forward.test.ts 的 interactive 用例。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Claude finished @lishuceo's task in 1m 42s —— View job Claude Code Review
Verdict: ✅ ApprovedPR 实现干净、目标明确,测试覆盖充分。 评估要点正确性
安全性
测试
次要观察(不阻塞合并)🟡 低置信度提示 — |
lishuceo
added a commit
that referenced
this pull request
May 24, 2026
PR #240 在 message-parser.ts 中加了 formatInteractiveCard 作为同问题 的局部修复。本 PR 的统一 extractCardText 设计是其超集,故: - 删除 formatInteractiveCard,client.ts/interactive-card.test.ts 改用新 API - 增强 extractCardText: v2 body.elements、嵌套 title.text.content、 未知 tag 兜底递归(覆盖第三方 share-card) - 更新 message-text.test.ts: 适配 main 已删除的 buildResultCard/ buildSimpleResultCard,改用 buildOverviewCard/buildTextContentCard Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
历史消息中
interactive类型卡片之前被fetchRecentMessages白名单直接 drop(reason:unsupported_type),导致 bot 拉历史时拿不到话题开头的卡片内容(如 SpaceX/XOVR 分享卡片),看到的只有空话题或[卡片消息]占位。实现方案2:递归解析卡片 JSON 提取可读文本。
formatInteractiveCard():解析header.title+elements(支持div/markdown/note/column_set/action/img/hr,以及 v2 form 的body.elements),未知 tag 走content/text字段递归兜底以兼容第三方 share-card 等格式client.tsfetchRecentMessages白名单加入interactive,parsing 分支调用formatInteractiveCardmessage-parser.tsformatMergeForwardSubMessage的interactive分支同步切换(之前固定返回[卡片消息])Test plan
interactive-card.test.ts12 个新单测merge-forward.test.ts更新interactive用例vitest run无回归tsc --noEmit通过🤖 Generated with Claude Code