Repository navigation
feat(telegram): add a persistThreadHistory option - #1098
Merged
Merged
Conversation
Telegram always copied every incoming message into the Chat state adapter, and persistThreadHistory was typed as the literal `true`, so neither config nor a subclass could turn it off. An app that keeps its own transcript ended up with a second, unredacted copy of every message in the state store. Add a persistThreadHistory config option, defaulting to true as before, and type the field as boolean so a subclass can override it too. Signed-off-by: Miłosz Lenczewski <m.lenczewski@tidio.net>
…ions With persistThreadHistory set to false, the SDK stops saving the bot's own posts as well as incoming messages. The changeset, docs page, README, and JSDoc now say so, and the core history docs explain that Telegram uses the thread cache by default and what bot.history.thread.list() returns when the option is off. The catalog lists persistThreadHistory as a config-only option, with a patch bump for @chat-adapter/catalog. Add tests that run a real Chat with the Telegram adapter and check the msg-history list in state: with the default it holds the incoming message and the bot's reply, and with false it is empty. A runtime test covers a subclass override, and the type test now asserts the base field is typed boolean. Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 of 5 tasks
This branch was successfully deployed
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.
This picks up #1079 from @mlenczewski-tidio. That PR comes from a fork owned by the
tidio-toolsorganization, and GitHub doesn't let maintainers push to organization-owned forks, so we couldn't update it in place. Their commit is kept with their authorship and sign-off, and a second commit adds the follow-up changes. The branch is rebased onto main, which resolves the merge conflict inpackages/adapter-telegram/src/subclass.test-d.tswith the new long message tests.The Telegram adapter copied every incoming message into the Chat state adapter, and
persistThreadHistorywas typed as the literaltrue, so neither config nor a subclass could turn it off. An app that keeps its own transcript ended up with a second, unredacted copy of every message in the state store. This adds apersistThreadHistoryoption that defaults totrue, and types the field asbooleanso a subclass can override it.With
false, the SDK saves neither incoming messages nor the bot's own posts, sothread.messagesandbot.history.thread.list()only see what the current process has cached. On serverless that's empty after a cold start. The Telegram docs, README, core history docs, and catalog entry now describe this.New tests run a real
Chatwith the Telegram adapter and check what lands in state with the option on and off.