Skip to content

Enable concurrent processing of messages across topics #102

@tschuehly

Description

@tschuehly

Summary

When using project threads mode (group), messages sent to different topics are processed sequentially. This means a long-running Claude task in one project topic blocks all other topics until it completes.

Proposed Change

Enable concurrent message processing so that messages in different project topics are handled in parallel. Each topic/handler gets its own isolated snapshot of thread state (working directory, session ID, thread context) to avoid race conditions.

Key Design Decisions

  • Per-update state isolation: context.user_data is shared per-user, so concurrent handlers for different topics would overwrite each other's values. Thread state is stored in a per-update dictionary on the orchestrator instance, keyed by update.update_id.
  • Note: telegram.Update uses __slots__, so arbitrary attributes cannot be set on it directly — an instance-level dictionary is used instead.
  • Claude Code internal paths: Concurrent processing surfaces more tool-result reads (~/.claude/projects/, /tmp/claude-<uid>/). These paths need to be whitelisted in _CLAUDE_INTERNAL_SUBDIRS alongside plans and todos.

I have an implementation ready at https://github.com/tschuehly/claude-code-telegram/tree/fix/concurrent-topic-processing and can open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions