Skip to content

fix(gateway): Mattermost Thread and Command Handling Fixes - #25187

Closed
JoshuaBowerman wants to merge 5 commits into
NousResearch:mainfrom
JoshuaBowerman:feature/mattermost-bug-fixes
Closed

fix(gateway): Mattermost Thread and Command Handling Fixes#25187
JoshuaBowerman wants to merge 5 commits into
NousResearch:mainfrom
JoshuaBowerman:feature/mattermost-bug-fixes

Conversation

@JoshuaBowerman

Copy link
Copy Markdown

What does this PR do?

This PR changes the mattermost thread handling to properly choose the thread's root id.
It also changes the mattermost command handling code to accept commands preceded by a single space character.

Related Issue

Fixes #25181
Fixes #25184

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/base.py - uses thread_id if available.
  • gateway/platforms/mattermost.py - Allows prefixed ' ' character in commands for mattermost.
  • tests/gateway/test_mattermost.py - Tests for changed behaviour.

How to Test

  1. Run hermes gateway with mattermost configured and threading enabled.
  2. Post /help to a channel
  3. You should see the proper help command output.
  4. Post /help as a reply to the bot reply.
  5. You should get the same output again.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

@JoshuaBowerman JoshuaBowerman changed the title Feature/mattermost bug fixes Mattermost Thread and Command Handling Fixes May 13, 2026
@JoshuaBowerman JoshuaBowerman changed the title Mattermost Thread and Command Handling Fixes fix(gateway): Mattermost Thread and Command Handling Fixes May 13, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels May 13, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #20874 (comprehensive Mattermost thread-mode fix that supersedes #12096, #6617, #12299, #18280).

This PR fixes #25181 and #25184 with a more targeted approach (3 files vs. #20874's broader scope). The thread root_id fix in base.py overlaps with #20874's approach in mattermost.py.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Mattermost coverage. This is now implemented on current main; automated hermes-sweeper review found both requested guarantees already shipped.

  • plugins/platforms/mattermost/adapter.py:163-176 resolves a send's reply_to/thread metadata through _resolve_root_id(), and :326-340 replaces a reply post ID with its actual Mattermost thread root before delivery.
  • plugins/platforms/mattermost/adapter.py:881-884 normalizes whitespace-prefixed slash commands before command classification; tests/gateway/test_mattermost.py:593-639 covers both /new and preservation of ordinary leading-space text.
  • The root-ID behavior shipped in 06161c6ed8d3b878e0076f0eba244de8f3208bc8 (v2026.5.28). The leading-space command behavior was later salvaged in 1197d2bc966727194b52fb227c805793e7327a15 via merged PR fix(mattermost): accept leading-space slash commands #59127 (v2026.7.7).
  • The earlier discussion's broader fix(mattermost): make thread routing configurable and reliable #20874 thread work was considered separately; this close is limited to this PR's two specific guarantees.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mattermost mobile users are unable to send commands. [Bug]: Mattermost gateway threading doesn't work after first reply.

3 participants