← Back to PRs

#18529: feat(feishu): add parentId and rootId to inbound context for quote/reply support

by qiangu open 2026-02-16 20:10 View on GitHub →
channel: feishu size: XS
## 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