Merge pull request #2460 from NousResearch/hermes/hermes-5d6932ba

fix(discord): properly route slash event handling in threads
This commit is contained in:
Teknium
2026-03-22 04:28:53 -07:00
committed by GitHub
2 changed files with 48 additions and 1 deletions

View File

@@ -241,6 +241,42 @@ async def test_dispatch_thread_session_builds_thread_event(adapter):
assert "TestGuild" in event.source.chat_name
# ------------------------------------------------------------------
# _build_slash_event — preserve thread context for native slash commands
# ------------------------------------------------------------------
def test_build_slash_event_preserves_thread_context(adapter):
interaction = SimpleNamespace(
channel=_FakeThreadChannel(channel_id=555, name="Planning"),
channel_id=555,
user=SimpleNamespace(display_name="Jezza", id=42),
)
event = adapter._build_slash_event(interaction, "/status")
assert event.text == "/status"
assert event.source.chat_id == "555"
assert event.source.chat_type == "thread"
assert event.source.thread_id == "555"
assert "TestGuild" in event.source.chat_name
def test_build_slash_event_uses_group_context_for_channels(adapter):
interaction = SimpleNamespace(
channel=_FakeTextChannel(channel_id=123, name="general"),
channel_id=123,
user=SimpleNamespace(display_name="Jezza", id=42),
)
event = adapter._build_slash_event(interaction, "/status")
assert event.source.chat_id == "123"
assert event.source.chat_type == "group"
assert event.source.thread_id is None
assert "TestGuild / #general" == event.source.chat_name
# ------------------------------------------------------------------
# Auto-thread: _auto_create_thread
# ------------------------------------------------------------------