Skip to content

Conversation

@david-lyft
Copy link
Contributor

This pull request introduces support for handling thread replies in Slack apps by adding new configuration options and updating the message processing logic. The changes ensure that thread replies can be properly matched and processed by handlers, while also improving the overall structure of the SlackMessage class.

Enhancements for handling thread replies:

  • Documentation Update: Added a note in docs/root/adding_new_slack_apps.rst to explain that setting match_reply: true is required for apps to handle thread replies.
  • Message Handler Logic: Updated _process_message_message_handlers in omnibot/processor.py to skip processing thread replies unless the handler explicitly specifies match_reply: true.

Updates to the SlackMessage class:

  • Payload Enhancements: Added parent_user_id to the _payload dictionary in omnibot/services/slack/message.py to capture the user ID of the parent message in thread replies.
  • Removed Thread Ignoring Logic: Removed the logic in _check_unsupported that previously ignored thread messages, allowing them to be processed.
  • New Properties: Introduced parent_user_id and updated the thread_ts property in omnibot/services/slack/message.py to provide clearer access to thread-related metadata.

@david-lyft david-lyft requested a review from Copilot July 21, 2025 15:01

This comment was marked as outdated.

@david-lyft david-lyft requested a review from colinsl July 21, 2025 15:10
@colinsl colinsl requested a review from Copilot July 21, 2025 16:54
@colinsl
Copy link
Contributor

colinsl commented Jul 21, 2025

PTAL @grahamnedelka

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces support for handling thread replies in Slack apps by adding configuration options and updating message processing logic to allow thread replies to be processed when explicitly enabled.

  • Add match_reply: true configuration option to allow handlers to process thread replies
  • Remove automatic filtering of thread messages and add parent_user_id property to SlackMessage
  • Update documentation to explain the new thread reply handling configuration

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
omnibot/processor.py Added logic to skip thread replies unless handler has match_reply: true
omnibot/services/slack/message.py Removed thread filtering, added parent_user_id property and improved thread_ts documentation
tests/unit/omnibot/services/slack/message_test.py Removed test case that expected thread messages to be unsupported
docs/root/adding_new_slack_apps.rst Added documentation for the new match_reply: true configuration option

"""
The user_id of the parent message, if this is a reply to a message.
"""
return self._payload["parent_user_id"]
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent_user_id property can return None when parent_user_id is not present in the event, but this isn't documented in the docstring. Consider adding a return type annotation and documenting the None case.

Copilot uses AI. Check for mistakes.
def thread_ts(self):
"""
The timestamp of the parent message, if this is a reply to a message.
:return:
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring for thread_ts property is missing return type information and doesn't document that it can return None when not in a thread.

Suggested change
:return:
:return: The timestamp of the parent message as a string, or None if the message is not part of a thread.
:rtype: Optional[str]

Copilot uses AI. Check for mistakes.
super().__init__(bot, event, event_trace, "message")
self._payload["ts"] = event["ts"]
self._payload["thread_ts"] = event.get("thread_ts")
self._payload["parent_user_id"] = event.get("parent_user_id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a parent_user_id?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reference to parent message

message.parent.user.id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the user id for the first message in the thread and exists for thread replies but not for regular messages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel this needs to go on infradocs

Copy link
Contributor

@colinsl colinsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention comments.

@david-lyft david-lyft merged commit 3ec6488 into master Jul 21, 2025
5 checks passed
@david-lyft david-lyft deleted the INTPROD-9686 branch July 21, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants