#18529: feat(feishu): add parentId and rootId to inbound context for quote/reply support
channel: feishu
size: XS
Cluster:
Feishu Enhancements and Fixes
## Summary
This PR includes two fixes for Feishu integration:
### 1. Add ReplyToId/RootMessageId support (parentId/rootId)
Enables agents to identify quoted/replied messages and fetch original content.
**Changes:**
- `bot.ts`: Add `ReplyToId` and `RootMessageId` to inbound context
- `send.ts`: Parse interactive card content when fetching quoted messages
### 2. Fix message chunking in topics/threads
Keeps all message chunks in the topic context instead of sending subsequent chunks to main chat.
**Problem:**
When sending long messages that get chunked, only the first chunk stayed in the topic. Subsequent chunks appeared in the main chat.
**Root Cause:**
All chunks used the same `replyToMessageId`, causing Feishu to interpret subsequent chunks as replies to the first chunk.
**Solution:**
Only use `replyToMessageId` for the first chunk. Subsequent chunks omit the reply target.
**Changes:**
- `reply-dispatcher.ts`: Conditional `replyToMessageId` based on `first` flag
## Testing
- [x] Quoted messages show original content
- [x] Interactive cards are parsed correctly
- [x] Long messages stay in topic after chunking (verified)
---
*Includes Greptile AI review feedback*
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds quote/reply support to the Feishu integration by setting `ReplyToId` (and `RootMessageId`) in the inbound context and parsing interactive card content when fetching quoted messages.
**Key changes:**
- Sets `ReplyToId: ctx.parentId` to enable standard reply-to functionality (consistent with other channels like Telegram, Slack)
- Adds `RootMessageId: ctx.rootId` for thread reconstruction (note: this field is not in the `MsgContext` type)
- Enhances `getMessageFeishu` to parse interactive card elements (div and markdown tags) when fetching quoted messages
**Issues found:**
- `RootMessageId` is not defined in the `MsgContext` type definition (`src/auto-reply/templating.ts`), making it an untyped ad-hoc property with no downstream consumers currently reading it
<h3>Confidence Score: 3/5</h3>
- This PR is mostly safe but has a typing issue that should be addressed
- The `ReplyToId` implementation follows established patterns from other channels and the interactive card parsing is correct. However, `RootMessageId` is an untyped property not defined in `MsgContext`, which violates TypeScript best practices and could cause confusion for maintainers
- Pay attention to `extensions/feishu/src/bot.ts` - the `RootMessageId` field needs to be properly typed in the `MsgContext` interface
<sub>Last reviewed commit: e6f45eb</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
82.5%
#13211: feat(feishu): skip reply-to in DM conversations
by Vincentwei1021 · 2026-02-10
81.7%
#19793: feat(feishu): reply-in-thread, parallel group sessions, and fire-an...
by yinsn · 2026-02-18
79.4%
#9253: Fix: Feishu chat ID mismatch causing session context confusion
by vishaltandale00 · 2026-02-05
78.3%
#20744: fix(feishu): reply under topic instead of creating new topic in top...
by paceyw · 2026-02-19
77.9%
#13970: feat: add Feishu topic auto-threading for message tool
by 4ier · 2026-02-11
77.3%
#10309: fix: use group ID for peer.id in Feishu group messages
by ParsifalC · 2026-02-06
75.2%
#16123: Feishu card default
by QiuYi111 · 2026-02-14
73.7%
#9756: fix(feishu): prevent message redelivery during long AI generation
by cszhouwei · 2026-02-05
73.4%
#9662: fix(feishu): include sender ID in direct messages for auth
by cszhouwei · 2026-02-05
73.3%