Skip to content

Your lightweight open-source personal agent.

fix(slack): skip thread_ts for direct messages

Re-bin28330940d0b2
diff --git a/nanobot/channels/slack.py b/nanobot/channels/slack.py
index e36c4c9c6..0384d8d11 100644
--- a/nanobot/channels/slack.py
+++ b/nanobot/channels/slack.py
@@ -81,9 +81,8 @@ class SlackChannel(BaseChannel):
slack_meta = msg.metadata.get("slack", {}) if msg.metadata else {}
thread_ts = slack_meta.get("thread_ts")
channel_type = slack_meta.get("channel_type")
- # Only reply in thread for channel/group messages; DMs don't use threads
- use_thread = bool(thread_ts and channel_type != "im")
- thread_ts_param = thread_ts if use_thread else None
+ # Slack DMs don't use threads; channel/group replies may keep thread_ts.
+ thread_ts_param = thread_ts if thread_ts and channel_type != "im" else None
# Slack rejects empty text payloads. Keep media-only messages media-only,
# but send a single blank message when the bot has no text or files to send.
diff --git a/tests/test_slack_channel.py b/tests/test_slack_channel.py
index 18b96efc5..891f86afb 100644
--- a/tests/test_slack_channel.py
+++ b/tests/test_slack_channel.py
@@ -61,6 +61,7 @@ async def test_send_uses_thread_for_channel_messages() -> None:
)
assert len(fake_web.chat_post_calls) == 1
+ assert fake_web.chat_post_calls[0]["text"] == "hello\n"
assert fake_web.chat_post_calls[0]["thread_ts"] == "1700000000.000100"
assert len(fake_web.file_upload_calls) == 1
assert fake_web.file_upload_calls[0]["thread_ts"] == "1700000000.000100"
@@ -83,6 +84,7 @@ async def test_send_omits_thread_for_dm_messages() -> None:
)
assert len(fake_web.chat_post_calls) == 1
+ assert fake_web.chat_post_calls[0]["text"] == "hello\n"
assert fake_web.chat_post_calls[0]["thread_ts"] is None
assert len(fake_web.file_upload_calls) == 1
assert fake_web.file_upload_calls[0]["thread_ts"] is None