Skip to content

fix(feishu): reply inside P2P threads instead of main chat#38814

Closed
xinhuagu wants to merge 2 commits intoopenclaw:mainfrom
xinhuagu:fix/feishu-p2p-thread-reply
Closed

fix(feishu): reply inside P2P threads instead of main chat#38814
xinhuagu wants to merge 2 commits intoopenclaw:mainfrom
xinhuagu:fix/feishu-p2p-thread-reply

Conversation

@xinhuagu
Copy link
Copy Markdown
Contributor

@xinhuagu xinhuagu commented Mar 7, 2026

Summary

When a user sends a message inside a thread in a P2P (direct message) chat, the bot replies outside the thread as a standalone message.

This regression was introduced by #33789, which fixed group reply targeting (#32980) but inadvertently broke P2P thread replies by gating all thread-aware logic behind isGroup checks.

Changes

Three places in extensions/feishu/src/bot.ts now handle P2P threads:

  1. replyInThread — was forced false for P2P; now true when thread_id is present (indicating a thread message per Feishu API docs)
  2. replyTargetMessageId — ignored root_id for P2P; now uses root_id for P2P threads so the reply targets the thread root
  3. skipReplyToInMessages — was always true for P2P; now false for P2P threads so the send layer uses im.message.reply instead of im.message.create

The distinction between thread_id (thread message) and root_id alone (quote reply) is preserved — only messages with thread_id trigger thread-aware behavior in P2P.

Testing

  • All 339 existing Feishu tests pass
  • No group chat behavior is affected (changes are gated behind isDirect && Boolean(ctx.threadId))

Closes #38806

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 7, 2026

Greptile Summary

This PR fixes a regression (#33789) where bot replies inside P2P (direct message) threads landed in the main chat instead of staying in the thread. Three coordinated changes in extensions/feishu/src/bot.ts gate thread-aware behaviour on isDirect && Boolean(ctx.threadId), correctly using thread_id (Feishu's marker for a threaded message) rather than root_id alone (which only signals a quote-reply).

  • replyInThread — now true for P2P messages that carry a thread_id
  • replyTargetMessageId — now uses ctx.rootId ?? ctx.messageId for P2P threads so the reply targets the thread root
  • skipReplyToInMessages — now false for P2P threads so the Feishu im.message.reply API is used instead of im.message.create

The fix is correct and well-scoped; existing group-chat behaviour is unaffected. One minor note: the P2P-thread condition is computed twice under different variable names (isP2pThread at line 1162 and p2pThread at line 1363), which creates a small maintainability risk. Additionally, no new test cases were added to cover P2P thread routing, leaving the fixed scenario without regression protection.

Confidence Score: 4/5

  • Safe to merge. The fix is narrowly scoped to P2P thread detection and does not affect group-chat paths.
  • The PR is safe to merge. The fix is correct and well-documented, properly gating all thread-aware logic behind the isDirect && Boolean(ctx.threadId) condition. The only concern is a minor style issue: the P2P-thread predicate is computed twice with different names (~200 lines apart), which creates a small maintainability risk. All 339 existing tests continue to pass.
  • extensions/feishu/src/bot.ts — minor style consolidation suggested for the duplicated P2P-thread condition.

Last reviewed commit: 90331bf

Comment thread extensions/feishu/src/bot.ts
@xinhuagu xinhuagu force-pushed the fix/feishu-p2p-thread-reply branch from 86204bb to 3922ed1 Compare March 7, 2026 20:44
xinhuagu added 2 commits March 8, 2026 09:45
When a user sends a message inside a thread in a P2P (direct message)
chat, the bot replies outside the thread as a standalone message.

This was introduced by openclaw#33789, which gated all thread-aware reply logic
behind isGroup checks. Three places need to handle P2P threads:

1. replyInThread was forced false for P2P — now true when thread_id
   is present (indicating a thread message per Feishu API docs)
2. replyTargetMessageId ignored root_id for P2P — now uses root_id
   for P2P threads so the reply targets the thread root
3. skipReplyToInMessages was always true for P2P — now false for P2P
   threads so the send layer uses im.message.reply (thread reply)
   instead of im.message.create (new standalone message)

Closes openclaw#38806
@xinhuagu xinhuagu force-pushed the fix/feishu-p2p-thread-reply branch from 3922ed1 to f270cda Compare March 8, 2026 08:45
@xinhuagu
Copy link
Copy Markdown
Contributor Author

xinhuagu commented Mar 8, 2026

Closing in favor of #38808 which landed first with the same approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bot replies outside thread in P2P direct message thread

1 participant