feat(slack): mention gating, thread cache, Block Kit, commands#6734
Closed
bennyhodl wants to merge 1 commit into
Closed
feat(slack): mention gating, thread cache, Block Kit, commands#6734bennyhodl wants to merge 1 commit into
bennyhodl wants to merge 1 commit into
Conversation
- Per-channel config (requireMention, allowBots, users, threadHistoryLimit) - check_mention_gate() replaces inline conditionals — pure function, testable - ThreadParticipationCache replaces _bot_message_ts/_mentioned_threads sets — TTL, LRU, async-safe - load_thread_context() replaces _fetch_thread_context() — structured, paginated, preserves bot messages - Connection health monitoring (SlackConnectionState, probe, stale socket detection) - Block Kit rendering: send() wraps messages in section blocks via _content_to_blocks() - Interactive Block Kit actions for hermes:.* buttons/selects - Message edit detection (message_changed events) - /hermes slash commands: help, skills, status, config - Per-channel user authorization (is_user_allowed_in_channel) - OAuth scope validation (fetch_slack_scopes, validate_slack_scopes) - Shared utilities module: SSRF protection, table conversion, message update helpers
5c104a9 to
4c89782
Compare
Contributor
|
Merged via PR #6809 as part of a consolidated Slack adapter improvement. Your contribution was superseded by the consolidated salvage. Your authorship is preserved in git history. Thank you @bennyhodl for your work on this! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Overhauls the Slack adapter with enterprise-grade capabilities. The existing inline mention logic, thread tracking sets, and thread context fetcher are replaced with testable, structured utilities extracted into
slack_utils.py. New features include per-channel configuration, Block Kit message rendering, connection health monitoring, slash commands, and message edit detection.+2,500 lines across 4 files (
slack.py,slack_utils.py,slack_commands.py,test_slack_approval_buttons.py)Related Issue
Fixes #
Type of Change
Changes Made
Refactors (behavior-preserving replacements of existing code)
check_mention_gate()replaces inline mention conditional — pure function returningMentionGateResultwithshould_respond,was_mentioned,implicit_mention,reason(gateway/platforms/slack_utils.py)ThreadParticipationCachereplaces_bot_message_ts/_mentioned_threadssets — LRU OrderedDict with 24h TTL, async lock, account-aware keys (gateway/platforms/slack_utils.py)load_thread_context()+format_thread_context_for_prompt()replaces_fetch_thread_context()— returnsThreadContext/ThreadMessagedataclasses, cursor pagination, preserves bot messages as "Assistant" (gateway/platforms/slack_utils.py)_has_active_session_for_thread()kept as fallback whenThreadParticipationCachemisses after restart (gateway/platforms/slack.py)New features
channelsblock undergateway.slackwithrequireMention,allowBots,users,threadHistoryLimit,replyBroadcastoverrides. Resolved early viaresolve_channel_config()(gateway/platforms/slack_utils.py)is_user_allowed_in_channel()whitelists user IDs per channel (gateway/platforms/slack_utils.py)SlackConnectionState,probe_slack_connection(),is_non_recoverable_slack_error(), stale socket detection via_mark_event_received()(gateway/platforms/slack_utils.py)fetch_slack_scopes()+validate_slack_scopes()against required/recommended sets (gateway/platforms/slack_utils.py)send()wraps every outgoing message in Block Kit section blocks via_content_to_blocks(), matching the pattern that makessend_exec_approvalwork. Splits on---for native dividers, handles oversized sections at line boundaries (gateway/platforms/slack.py)hermes:.*action IDs (buttons/selects), routes as syntheticMessageEvent(gateway/platforms/slack.py)message_changedevents extract the inner edited message and re-process it instead of being ignored (gateway/platforms/slack.py)/hermes help,/hermes skills,/hermes status,/hermes configwith Block Kit formatting, dispatch viaSLASH_COMMANDSregistry (gateway/platforms/slack_commands.py)Shared utilities module (
gateway/platforms/slack_utils.py)validate_slack_file_url,is_slack_hostname)looks_like_html_content)normalize_slack_voice_mimetype)convert_markdown_tables_to_slack)update_slack_message,SlackMessageRef)Tests
TestSlackThreadContextto testload_thread_context()instead of removed_fetch_thread_context()TestThreadEngagementto testThreadParticipationCacheinstead of removed_bot_message_ts/_mentioned_threadssetsHow to Test
@hermes— verify mention gating responds correctly@needed)/hermes status— verify Block Kit formatted response with connection state/hermes skills— verify skills list renders/hermes config— verify config summary renderschannelsblock togateway.slackinconfig.yamlChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A