fix(slack): handle leading-space text commands - #56718
Conversation
Related: leading-space slash-command cluster. This PR fixes it at the shared |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused Slack command fix. The premise is confirmed on current main: plugins/platforms/slack/adapter.py:3410 recognizes only text beginning with /, while first thread replies fetch and prepend context at plugins/platforms/slack/adapter.py:3391-3406 before that classification.
Problems
tests/e2e/test_platform_commands.py:60does not exercise the changed Slack inbound path. Its helper constructs aMessageEventdirectly (tests/e2e/conftest.py:273-281) and invokesadapter.handle_message(), bypassingSlackAdapter._handle_slack_message()where this PR adds the normalization and thread-context guard.
Suggested changes
- Add a raw Slack-event test in
tests/gateway/test_slack.pyfor" /stop"through_handle_slack_message(), asserting a/stopMessageEventwithMessageType.COMMAND. - Add a threaded case asserting
_fetch_thread_context()is not called for that command. - The Mattermost precedent is adapter-local normalization (
plugins/platforms/mattermost/adapter.py:881); preserve or intentionally justify the broader shared-base behavior during salvage.
Automated hermes-sweeper review.
| assert "no" in response_lower or "stop" in response_lower or "not running" in response_lower | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_leading_space_stop_is_still_a_command(self, adapter, platform): |
There was a problem hiding this comment.
This test creates a MessageEvent directly through send_and_capture(), so it bypasses SlackAdapter._handle_slack_message() entirely. Please add a Slack-adapter test with a raw {"text": " /stop"} event, including a thread case that verifies _fetch_thread_context() is not called.
|
Merged via #69479 — your commit was cherry-picked/reapplied onto current main with your authorship preserved in git history: your leading-space command recognition was cherry-picked directly. Thanks for the contribution! |
Summary
/stopas a gateway command after trimming leading Slack-avoidance whitespaceTest
uv run pytest tests/e2e/test_platform_commands.py::TestSlashCommands::test_leading_space_stop_is_still_a_command tests/e2e/test_platform_commands.py::TestSlashCommands::test_stop_when_no_agent_running -q