fix(telegram): preserve auto-titled sessions and bind chat on switch (#121)#122
Closed
leshchenko1979 wants to merge 6 commits into
Closed
fix(telegram): preserve auto-titled sessions and bind chat on switch (#121)#122leshchenko1979 wants to merge 6 commits into
leshchenko1979 wants to merge 6 commits into
Conversation
Label drift compared the full title to the default DM template on every message, reverting auto-titled names after the second message (issue adolfousier#121). Introduce session_resolve::should_refresh_label and prefer chat_sessions map on ingest after /sessions switch. Adds Rust tests, a Python TDD simulator (pytest -k production shows red), and validate-hermes.sh for post-deploy checks. Fixes adolfousier#121
…p Python sim - Apply session_idle_expired to chat-bound path (parity with suffix resolve) - Use session_resolve::build_session_title for /new - Add choose_resolve_source + TelegramState policy tests - Remove tools/telegram_session_sim from upstream (lives in vds/servers repo)
Document resolve policy in handler. Add chat_bound_idle integration test and session_idle_expired boundary tests per review.
Guest session switch used register_session_chat only; extra_sessions map was never read on ingest. Document choose_resolve_source on bound branch.
Sibling module was declared in mod.rs but not in scope for handler.rs.
Contributor
Author
|
Superseded by a fresh PR from a squashed branch (clean history, same fix). |
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
Fixes #121: Telegram DM sessions kept the default
Telegram: DM … [chat:ID]title after auto-title ran,/sessionslooked like duplicate rows, and switching felt broken.Root cause: Label drift compared the full stored title to the default DM template on every message reuse. Auto-titled names were overwritten on message 2+;
auto_title_attemptedstayed true, so rename never retried.Fix:
session_resolve::should_refresh_label— never clobber auto-titled / custom DM titleshandle_message—chat_sessionsmap first, then suffix fallback; idle timeout on bound path too/newusessession_resolve::build_session_titleextra_sessionsremoved — see belowextra_sessions(guest switching)Previously, guest
/sessionsswitch wrote to a separateextra_sessions: HashMap<user_id, …>inagent.rsthat was never read inhandle_message. Owner and guest both already callregister_session_chat(session_id, chat_id)on switch, which is what ingest uses.This PR: remove the dead
extra_sessionsmap; guest switching relies onchat_sessionsonly (same as owner). Test:register_session_chat_binds_guest_dm.choose_resolve_sourcevs nestedif letDoes not require a large refactor. Full replacement would mean: prefetch
chat_session+ bound row + suffix row, thenmatch choose_resolve_source(…), moving ~80–120 lines in thesession_idblock — behavior-neutral, optional cleanup.This PR keeps the existing structure and adds
matches!(choose_resolve_source(…), ChatBound)on the bound branch so policy is checked at runtime and in unit tests. Suffix/create paths still use the sameelseblock; policy ischoose_resolve_sourcewithsuffix_matchset (tests:archived_chat_map_entry_uses_suffix_not_bound,suffix_path_when_chat_map_empty).A full
match-based rewrite can be a follow-up PR if desired.Test plan
cargo test telegram_session_resolve session_resolve::testsCoverage includes: label drift, chat-bound idle archive+create,
session_idle_expiredboundaries,choose_resolve_sourcematrix, guestregister_session_chat, suffix switch race.Manual:
/new→ message → wait for auto-title → second message (title in/sessionsmust stay non-default) →/sessionsswitch to an older session → send a message and confirm that session’s context is used.