Skip to content

Support topics in private bot chats - #3315

Open
genuss wants to merge 1 commit into
sipeed:mainfrom
genuss:fix/telegram-private-topic-mode
Open

Support topics in private bot chats#3315
genuss wants to merge 1 commit into
sipeed:mainfrom
genuss:fix/telegram-private-topic-mode

Conversation

@genuss

@genuss genuss commented Aug 3, 2026

Copy link
Copy Markdown

📝 Description

Fix Telegram topic handling for private chats with bots that have forum topic mode enabled.

PicoClaw previously recognized topics only when Chat.IsForum was true. That works for forum supergroups but not private bot chats, where Telegram instead provides IsTopicMessage and MessageThreadID.

This change:

  • recognizes both forum-supergroup and private-chat topics
  • preserves the thread ID in the composite chat ID and InboundContext.TopicID
  • routes replies to the originating private topic
  • isolates conversation history between private topics
  • preserves existing behavior for non-forum group reply threads
  • adds regression tests for inbound metadata, outbound routing, and session isolation

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Follow-up to #3110. The original fix covered Telegram forum supergroups, while this PR covers forum topic mode in private bot chats.

📚 Technical Context (Skip for Docs)

  • Reference URL: https://core.telegram.org/bots/api#message
  • Reasoning: Telegram sets Chat.IsForum for forum supergroups, but private chats with topic-enabled bots use Message.IsTopicMessage together with a nonzero MessageThreadID. PicoClaw checked only Chat.IsForum, causing private-topic messages to lose their thread routing and session context. The fix treats a message as topic-aware when it has a thread ID and either Chat.IsForum or IsTopicMessage is true.

🧪 Test Environment

  • Hardware: Apple Silicon arm64
  • OS: macOS 15.7.7
  • Model/Provider: N/A — unit tests do not invoke an LLM
  • Channels: Telegram

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly. No documentation changes are required because this is an internal Telegram routing fix with no configuration or API changes.

@CLAassistant

CLAassistant commented Aug 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown

This PR has had no activity for 7 days and has been marked as stale. If you are still working on it, please push an update or leave a comment; otherwise it will be closed automatically in 7 days.

@github-actions github-actions Bot added the stale label Aug 11, 2026
@genuss

genuss commented Aug 11, 2026

Copy link
Copy Markdown
Author

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants