Repository navigation
feat(slack): forward reaction_added/removed to gateway hooks #33111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2464,6 +2464,24 @@ def _resolve_turn_agent_config(self, user_message: str, model: str, runtime_kwar | |
| route["request_overrides"] = overrides or {} | ||
| return route | ||
|
|
||
| async def _handle_reaction_event(self, ctx: Dict[str, Any]) -> None: | ||
| """Forward a normalised reaction event to the HookRegistry. | ||
|
|
||
| Adapters call this via ``set_reaction_handler`` for every | ||
| platform-native reaction event they choose to surface. We map | ||
| the adapter-supplied ``event_name`` ("reaction:added" / | ||
| "reaction:removed") onto a hook event so user hooks can subscribe | ||
| with the same name scheme as the existing ``agent:*`` family. | ||
|
|
||
| Errors are swallowed at the HookRegistry layer per the | ||
| non-blocking hook contract. | ||
| """ | ||
| event_name = ctx.get("event_name", "reaction:added") | ||
| try: | ||
| await self.hooks.emit(event_name, ctx) | ||
| except Exception as e: | ||
| logger.exception("[Gateway] reaction hook emit failed: %s", e) | ||
|
|
||
| async def _handle_adapter_fatal_error(self, adapter: BasePlatformAdapter) -> None: | ||
| """React to an adapter failure after startup. | ||
|
|
||
|
|
@@ -4130,6 +4148,7 @@ async def start(self) -> bool: | |
| adapter.set_fatal_error_handler(self._handle_adapter_fatal_error) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also wire this callback for multiplexed-profile adapters. Current main has a separate bootstrap at |
||
| adapter.set_session_store(self.session_store) | ||
| adapter.set_busy_session_handler(self._handle_active_session_busy_message) | ||
| adapter.set_reaction_handler(self._handle_reaction_event) | ||
| adapter._busy_text_mode = self._busy_text_mode | ||
|
|
||
| # Try to connect | ||
|
|
@@ -5743,6 +5762,7 @@ async def _platform_reconnect_watcher(self) -> None: | |
| adapter.set_fatal_error_handler(self._handle_adapter_fatal_error) | ||
| adapter.set_session_store(self.session_store) | ||
| adapter.set_busy_session_handler(self._handle_active_session_busy_message) | ||
| adapter.set_reaction_handler(self._handle_reaction_event) | ||
| adapter._busy_text_mode = self._busy_text_mode | ||
|
|
||
| success = await self._connect_adapter_with_timeout(adapter, platform) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add dispatch tests for both event names, normalized payloads, and a failed permalink lookup. Current Slack coverage only asserts registration of the two event names (
tests/gateway/test_slack.py:241-242).