fix: include thread_id in _parse_session_key and fix stale parts reference

_parse_session_key() now extracts the optional 6th part (thread_id) from
session keys, and _notify_active_sessions_of_shutdown uses _parsed.get()
instead of the removed 'parts' variable. Without this, shutdown notifications
silently failed (NameError caught by try/except) and forum topic routing
was lost.
This commit is contained in:
Teknium 2026-04-15 11:07:24 -07:00 committed by Teknium
parent 2276b72141
commit f61cc464f0
2 changed files with 17 additions and 7 deletions

View file

@ -383,9 +383,15 @@ def test_parse_session_key_valid():
def test_parse_session_key_with_extra_parts():
"""Extra trailing parts (thread_id etc.) are ignored — only first 5 matter."""
"""Thread ID (6th part) is extracted; further parts are ignored."""
result = _parse_session_key("agent:main:discord:group:chan123:thread456")
assert result == {"platform": "discord", "chat_type": "group", "chat_id": "chan123"}
assert result == {"platform": "discord", "chat_type": "group", "chat_id": "chan123", "thread_id": "thread456"}
def test_parse_session_key_with_user_id_part():
"""7th part (user_id) is ignored — only up to thread_id is extracted."""
result = _parse_session_key("agent:main:telegram:group:chat1:thread42:user99")
assert result == {"platform": "telegram", "chat_type": "group", "chat_id": "chat1", "thread_id": "thread42"}
def test_parse_session_key_too_short():