telegram: per-topic session isolation#173
Open
ybuzko wants to merge 3 commits intomoazbuilds:masterfrom
Open
Conversation
Adds `telegram.dmIsolation: "shared" | "perUser"` setting. Defaults to "shared" to match Discord DM behaviour (all DMs share the global session). Set to "perUser" to give each DM sender their own isolated session. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Routes each supergroup topic (chat+thread) and optionally each DM user
to its own session key ("tg:<chatId>:<threadId>"), so /reset, /compact,
/status, and /context all operate on the correct isolated session instead
of the global one.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
getTelegramSessionKey()helper that maps each Telegram context to an isolated session key:tg:<chatId>:<threadId>for supergroup topics,tg:<chatId>for general group chat,tg:dm:<userId>for per-user DMs (opt-in), orundefinedto fall through to the global sessiontelegram.dmIsolation: "shared" | "perUser"config setting (default"shared"to match existing Discord DM behavior)/reset,/compact,/status, and/contextto the per-topic session when a key is presentMotivation
Without this, all Telegram group topics share a single global session. A conversation in one topic bleeds context into unrelated topics, and
/resetnukes every topic at once. This matches the isolation pattern Discord already uses for guild channels.Test plan
/resetin one topic does not affect another topic's session/statusand/contextshow the correct per-topic session/compactruns on the correct thread sessiondmIsolation: "shared"(default) still use the global sessiondmIsolation: "perUser"isolate per user IDtg:<chatId>key correctly🤖 Generated with Claude Code