Skip to content

Conversation

@MikaKerman
Copy link
Contributor

@MikaKerman MikaKerman commented Nov 17, 2025

…n in message sending

Summary by CodeRabbit

  • New Features
    • Added reply broadcast functionality to Slack messaging integration. Users can now optionally configure thread replies to be automatically broadcast to the main channel, ensuring important responses are visible to all channel members. This enhancement provides greater control over message routing while maintaining the organizational benefits of threaded conversations in Slack.

@linear
Copy link

linear bot commented Nov 17, 2025

@github-actions
Copy link
Contributor

👋 @MikaKerman
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

The PR adds a new optional reply_broadcast parameter to SlackWebMessagingIntegration, threading it through initialization, message sending, and the internal _send_message method to control Slack's reply broadcast behavior during thread message operations.

Changes

Cohort / File(s) Summary
Slack reply broadcast feature
elementary/messages/messaging_integrations/slack_web.py
Added reply_broadcast parameter to __init__ (default False) as instance attribute; extended _send_message signature to accept and propagate reply_broadcast to chat_postMessage API call; updated reply_to_message to pass self.reply_broadcast to _send_message.

Sequence Diagram

sequenceDiagram
    participant Client
    participant SlackWebMessagingIntegration
    participant _send_message
    participant SlackAPI as Slack API

    Client->>SlackWebMessagingIntegration: __init__(reply_broadcast=True)
    SlackWebMessagingIntegration->>SlackWebMessagingIntegration: self.reply_broadcast = True

    Client->>SlackWebMessagingIntegration: reply_to_message(destination, message, thread_ts)
    SlackWebMessagingIntegration->>_send_message: _send_message(..., reply_broadcast=self.reply_broadcast)
    _send_message->>SlackAPI: chat_postMessage(..., reply_broadcast=True)
    SlackAPI-->>_send_message: MessageSendResult
    _send_message-->>SlackWebMessagingIntegration: Result
    SlackWebMessagingIntegration-->>Client: Result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify the Slack API chat_postMessage parameter reply_broadcast is correctly documented and used
  • Confirm that omitting reply_broadcast in the error-path retry (defaulting to False) is intentional and correct behavior
  • Check that parameter threading through the call chain is consistent and complete

Poem

🐰 A broadcast thread now hops with grace,
Parameters threaded through their place,
From init to send, the reply takes flight,
Slack messages channel-bound and bright!
thump thump

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for reply_broadcast option to SlackWebMessagingIntegration, which matches the file changes and PR objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch app-315-broadcast-slack-resolution-notifications-in-channel

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
elementary/messages/messaging_integrations/slack_web.py (1)

94-100: Retry path drops reply_broadcast, leading to inconsistent behavior on resend

The new reply_broadcast parameter is threaded into _send_message and down to chat_postMessage, but the retry path does not pass it:

return self._send_message(destination, formatted_message, thread_ts)

This means any retried send (once _handle_send_err is adjusted to allow retries for recoverable errors) will silently revert to reply_broadcast=False, which is inconsistent with the initial call and could surprise callers.

You can preserve behavior by forwarding the flag:

     def _send_message(
         self,
         destination: Channel,
         formatted_message: FormattedBlockKitMessage,
         thread_ts: Optional[str] = None,
         reply_broadcast: bool = False,
     ) -> MessageSendResult[SlackWebMessageContext]:
@@
         except SlackApiError as e:
             self._handle_send_err(e, destination)
-            return self._send_message(destination, formatted_message, thread_ts)
+            return self._send_message(
+                destination,
+                formatted_message,
+                thread_ts=thread_ts,
+                reply_broadcast=reply_broadcast,
+            )

Even though _handle_send_err currently always raises, fixing this now keeps the retry logic correct and future-proof if error handling is relaxed later.

Also applies to: 107-111

🧹 Nitpick comments (2)
elementary/messages/messaging_integrations/slack_web.py (2)

44-53: Constructor wiring for reply_broadcast looks good; consider exposing it via from_token as well

The new reply_broadcast flag is correctly added and stored on the instance. However, from_token cannot configure it and always uses the default False, which makes the feature harder to use via the primary factory constructor.

I suggest extending from_token to accept and pass through reply_broadcast so callers don’t need to bypass it just to enable broadcast replies:

-    @classmethod
-    def from_token(
-        cls, token: str, tracking: Optional[Tracking] = None
-    ) -> "SlackWebMessagingIntegration":
-        client = WebClient(token=token)
-        client.retry_handlers.append(RateLimitErrorRetryHandler(max_retry_count=5))
-        return cls(client, tracking)
+    @classmethod
+    def from_token(
+        cls,
+        token: str,
+        tracking: Optional[Tracking] = None,
+        reply_broadcast: bool = False,
+    ) -> "SlackWebMessagingIntegration":
+        client = WebClient(token=token)
+        client.retry_handlers.append(RateLimitErrorRetryHandler(max_retry_count=5))
+        return cls(client, tracking, reply_broadcast=reply_broadcast)

86-90: Reply wiring correctly propagates reply_broadcast; global flag vs per-message override is a design choice

Using reply_broadcast=self.reply_broadcast when replying to a message correctly ensures that only threaded replies are affected by this flag and plain send_message calls remain unchanged.

This does make reply_broadcast an integration-wide setting rather than something that can be toggled per reply. If you foresee needing per-message control (e.g., some replies broadcast, some not, within the same integration instance), consider allowing reply_to_message to accept an optional reply_broadcast override in the future. For now, the implementation is consistent and safe.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e346678 and e1b476e.

📒 Files selected for processing (1)
  • elementary/messages/messaging_integrations/slack_web.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
elementary/messages/messaging_integrations/slack_web.py (2)
elementary/messages/messaging_integrations/base_messaging_integration.py (1)
  • MessageSendResult (19-22)
elementary/clients/slack/slack_message_builder.py (2)
  • blocks (33-34)
  • attachments (37-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: code-quality
  • GitHub Check: test / test

@MikaKerman MikaKerman merged commit fe93c6e into master Nov 17, 2025
7 checks passed
@MikaKerman MikaKerman deleted the app-315-broadcast-slack-resolution-notifications-in-channel branch November 17, 2025 09:09
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