Skip to content

Long threaded reply leaks out of a topic/thread chat: reply_to dropped on chunks after the first #5

Description

@Ydz0616

Summary

In a Feishu/Lark thread (topic) chat, the tail of a long threaded reply leaks out of the thread into the main chat.

Root cause

lark_channel/channel/outbound/sender.pyOutboundSender._send_text splits a message longer than text_chunk_limit into multiple bodies, but applies reply_to only to the first chunk:

# Only apply `reply_to` to the first chunk; subsequent chunks are
# fresh messages so they all render in the original chat.
effective_reply_to = reply_to if idx == 0 else None

For a normal reply, "fresh messages render in the original chat" holds. But in a thread/topic chat, a message sent without a reply parent does not render in the thread — it drops into the main chat. So with reply_in_thread=True, every chunk after the first leaks out of the thread.

Reproduction

  1. In a topic-mode group, send a markdown message longer than text_chunk_limit (default 3500) with SendOpts(reply_to=<root_message_id>, reply_in_thread=True).
  2. Observed: the first chunk is a threaded reply under the root; the remaining chunks appear as top-level messages in the main group.
  3. Expected: all chunks stay in the thread.

Suggested fix

Keep reply_to on every chunk when threading:

effective_reply_to = reply_to if (idx == 0 or reply_in_thread) else None

Replying each chunk to the same root with reply_in_thread=True keeps all pieces in the thread; non-thread replies keep the current first-chunk-only behavior.

Observed on 1.1.0 and current main (lines ~388–390). A PR with this change is opened separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions