Repository navigation
Conversation
export_unread_messages ran its batching loop unconditionally, so a fully read chat (unread_count == 0, or the chat missing from the first 500 dialogs) exported its entire history to disk. Gate the loop on unread_count so zero-unread chats record an empty export. Fixes chigwell#296 (chigwell/telegram-mcp) Co-Authored-By: Claude Code <[email protected]>
chigwell
approved these changes
Oct 17, 2026
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.
What changed
export_unread_messagesis annotated read-only, but withunread_count == 0its batching loop fell back to a limit of 100 per page and the unread-based stop condition never fired — so it exported the entire chat history to disk. The loop is now gated onwhile unread_count:; a zero-unread chat still gets an entry withunread_count_at_export: 0and an empty message list.Before
Chat with 350 messages in history,
unread_count = 0(fully read):The read-only tool dumped the whole history — nothing is unread, everything was exported.
After
Same chat, same call:
No
get_messagescalls are made; only truly unread messages are exported.Tests
tests/test_export_unread_messages.py: newtest_export_skips_chat_with_zero_unread— 350 messages,unread_count=0→ noget_messagescalls,messages_exported: 0.uv run pytest -q→ 1196 passed.Fixes #296
🤖 Generated with Claude Code