fix(slack): formatting consistency, table conversion, thread reply fix#2525
Closed
ghostmfr wants to merge 1 commit into
Closed
fix(slack): formatting consistency, table conversion, thread reply fix#2525ghostmfr wants to merge 1 commit into
ghostmfr wants to merge 1 commit into
Conversation
Bug 1: edit_message() now calls format_message() before chat_update so streaming edits render proper Slack mrkdwn instead of raw markdown. Bug 2: format_message() now converts markdown tables into fenced code blocks (stripping separator rows) and strips horizontal rules (---, ***, ___) that previously leaked into Slack messages as raw syntax. Bug 3: In the interrupt/follow-up path of run.py, the adapter.send() call now uses source.thread_id for thread metadata instead of event.metadata, ensuring follow-up replies land in the correct thread.
Contributor
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.
Summary
This PR fixes three bugs in the Hermes Slack gateway.
Bug 1 —
edit_message()skipsformat_message()(streaming sends raw markdown)File:
gateway/platforms/slack.pyedit_message()was callingchat_updatewith raw markdown content, bypassing theformat_message()conversion that translates standard markdown to Slack mrkdwn. This meant streamed message edits would show**bold**instead of*bold*,## Headerinstead of bold text, etc.Fix: Added
content = self.format_message(content)as the first line after the not-connected guard inedit_message().Bug 2 — Markdown tables and horizontal rules leak through
format_message()File:
gateway/platforms/slack.pyformat_message()had no handling for markdown tables (| col | col |) or horizontal rules (---,***,___), so these were passed through as-is to Slack, where they render as raw text.Fix: Added two new conversion steps in
format_message()before placeholder restoration:^\|.*\|are detected, separator rows (containing only-,:,|, space) are stripped, and data rows are formatted into a fenced code block (``````) with cells joined by two spaces.---,***, or___(3+ chars) are removed.Bug 3 — Wrong thread replies (interrupt/follow-up path)
File:
gateway/run.py(~line 5285)In the interrupt/follow-up path, when sending the first response before processing a queued message,
adapter.send()was usinggetattr(event, "metadata", None)for thread metadata. Theeventobject at that point may not carry correct thread context, causing replies to land in the wrong thread or at the channel level.Fix: Replaced with
{"thread_id": source.thread_id} if getattr(source, "thread_id", None) else Noneso the reply always targets the correct source thread.Tests
All 1378 gateway tests pass: