Skip to content

[Feat] One forum topic per task in Topics-enabled Telegram supergroups#54

Open
daniel-lxs wants to merge 1 commit into
developfrom
feat/telegram-forum-topic-per-task
Open

[Feat] One forum topic per task in Topics-enabled Telegram supergroups#54
daniel-lxs wants to merge 1 commit into
developfrom
feat/telegram-forum-topic-per-task

Conversation

@daniel-lxs

Copy link
Copy Markdown
Member

What

Telegram has no threads in plain chats — but Topics-enabled supergroups do, and all our plumbing was already thread-aware (message_thread_idcommunicationThreadId). This turns that on: when a task launches outside any topic in a forum chat, the bot creates a forum topic named after the request and moves the task's life there.

  • The job's communicationThreadId points at the new topic, so follow-ups typed in the topic queue to the job and worker replies land there (they re-anchor to the in-topic started card).
  • The started card (Follow Task / ✖️ Cancel) posts inside the topic; a pointer reply with an Open topic deep link is left next to the launch message so it's discoverable.
  • The group's topic list becomes a task list — the closest Telegram gets to Slack threads.

Behavior boundaries

  • Launch from inside an existing topic → stays in that topic (no nesting).
  • Plain groups / DMs / missing manage-topics right / API failure → falls back to today's chat-scoped behavior; the task is never dropped.
  • Works with routing confirmation: the Yes/Nope card stays where the user asked; the topic is created at actual launch (Yes click, picker pick, or auto-confirm).

Setup required (per group, one-time)

Create a group → enable Topics in group settings → add the bot as admin with "Manage topics". Same install-shaped setup as a Slack workspace.

Changes

  • TelegramCommunicationProvider.createForumTopic; is_forum on the chat schema.
  • launchTelegramTask topic creation + reply re-anchoring (setLatestInboundMessageId) + pointer message; chatIsForum threaded through routing-confirmation pending state and auto-confirm.
  • Mock harness: forumTopics state, createForumTopic route, and real-Telegram forum semantics (unknown message_thread_id in a forum chat 400s; createForumTopic on a non-forum chat 400s).

Testing

  • 201 tests pass across the telegram / mcp / communication suites (5 new: topic-per-task launch, in-topic entry no-nesting, creation-failure fallback, harness topic round-trip + rejections). Typecheck, lint, knip, knowledge-check clean on the current develop base (isolated worktree).
  • Live end-to-end through the mock harness against the dev stack: mention in General → Yes on the routing card → topic "fix the flaky login test in the web app" created, started card posted inside it, Open-topic pointer in General, task canceled from the in-topic card (cloud job 85: communicationThreadId = 3, canceled).

Docs

.agent-guidance/features/telegram-integration.md (inbound flow + parity notes) and the mock-telegram-testing scenario catalog (new scenario 6, harness forum semantics).

🤖 Generated with Claude Code

Telegram has no threads in plain chats, but Topics-enabled supergroups do.
When a task launches outside any topic in a forum chat, the bot now creates
a forum topic named after the request: the job's communicationThreadId points
at it, the started card (Follow/Cancel) posts inside it, worker replies
re-anchor to the in-topic card, and follow-ups typed in the topic queue to
the job — the chat's topic list becomes a task list, Slack-thread style.
A pointer reply with an "Open topic" deep link is left next to the launch
message so the topic is discoverable.

- TelegramCommunicationProvider.createForumTopic (needs bot admin with the
  manage-topics right); chat schema gains is_forum.
- launchTelegramTask creates the topic at launch; launches from inside an
  existing topic stay there; creation failure (plain groups, missing rights)
  falls back to the main chat rather than dropping the task. chatIsForum is
  threaded through routing confirmation (pending state + auto-confirm).
- Mock harness: forumTopics state + createForumTopic route, and forum
  semantics enforced (topic-less thread ids in forum chats 400 like real
  Telegram).

Verified live end-to-end through the mock harness against the dev stack:
mention in General -> Yes on the routing card -> topic created, started card
in the topic, Open-topic pointer in General, cancel from the in-topic card
(cloud job canceled with communicationThreadId = topic id). 201 tests pass
across the telegram/mcp/communication suites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roomote-roomote-v1

Copy link
Copy Markdown

Reviewing the PR now. Follow

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.

1 participant