[Feat] Mock Telegram Bot API harness and routing confirmation for Telegram task entry - #22
Merged
daniel-lxs merged 1 commit intoJul 9, 2026
Conversation
…egram task entry Testing harness (packages/communication): - MockTelegramServer: fake Bot API (sendMessage, sendPhoto, editMessageText, reactions, buttons, webhooks) with /mock/state + /mock/events control plane and signed update dispatch into the real webhook handler. Enforces real Telegram limits (4096 chars, unknown chats, missing reply targets) and auto-computes entities so bot-command/mention detection matches production. - TELEGRAM_API_BASE_URL env override reroutes every runtime provider construction to the harness (mirrors SLACK_API_BASE_URL). - CLI runner (mock:telegram), LLM-judged eval runner (eval:telegram-scenario) with three scenario fixtures, and the mock-telegram-testing skill with a user-journey scenario catalog. Routing confirmation (apps/api telegram handler): - When the router is below 0.95 confidence, remapped, or picks all-repos while environments exist, task entry posts a compact Yes/Nope card that auto-starts the suggestion after ~5s; Nope edits the same message into a workspace picker (no timer). Router fallback shows the picker directly instead of silently launching in all repos. - Pending choice lives in Redis (one-shot GETDEL claim; 64-byte-safe callback data; requester-only clicks; Nope re-keys state so the timer can never fire a rejected suggestion; superseding requests invalidate stale cards). Suggestion-button launches skip the card. - New TelegramCommunicationProvider.editMessageText with HTML-to-plain fallback, used to finalize cards in place. Verified with 56 API handler tests + 17 harness tests and a live end-to-end run through the mock harness against the dev stack (card, Nope-to-picker, Nevermind, timer no-op, zero jobs created). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
2 issues outstanding. See task
|
mrubens
pushed a commit
that referenced
this pull request
Jul 9, 2026
Resolves conflicts by porting develop's changes onto the new data-model contract: - setup-new onboarding kickoff adopts develop's web-only Teams fallback (#48) with the new enqueue contract (user initiator, setup_onboarding workflow, provider stamp) instead of attributionOverride - Telegram routing-confirmation launch helper (#22) ported to the new contract, keeping launchClass: 'human' for keepalive policy - snapshot refresh keeps the automation initiator; dropped the re-merged forged-owner fallback - setup redirect guard keeps the provider-agnostic completion check - drizzle baseline regenerated to fold develop's 0001 (nullable environments.created_by_user_id + declarative_source) into the single 0000 baseline - develop-added tests updated to the new enqueue/factory shapes
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
Two related pieces that bring the Telegram integration up to Slack-grade testability and routing UX:
1. Mock Telegram Bot API harness (
packages/communication)MockTelegramServer— impersonates both halves of the Bot API: outbound methods (sendMessage,sendPhoto,editMessageText, reactions, inline keyboards, webhook registration) and inbound update dispatch (signed with the secret-token header) into the real/api/webhooks/telegramhandler. Control plane at/mock/state+/mock/events, mirroring the mock Slack harness.entitiesfor injected text so bot-command/mention detection behaves exactly as in production.TELEGRAM_API_BASE_URLenv override (defaulthttps://api.telegram.org) reroutes every runtime provider construction — zero production impact.pnpm --filter @roomote/communication mock:telegram), LLM-judged eval runner (eval:telegram-scenario) + three fixtures, and themock-telegram-testingskill with a 16-scenario user-journey catalog.2. Routing confirmation for Telegram task entry (
apps/api)Previously Telegram launched every routed task immediately, and router fallback silently launched into all repos — the only mis-route recovery was cancel.
Now (mirroring Slack's gate): when router confidence is < 0.95, the workspace was remapped, or all-repositories was picked while environments exist, task entry posts a compact ✅ Yes / ✖️ Nope card that auto-starts the suggestion after ~5s. Nope edits the same message into a workspace picker (environments + all repos + Nevermind, no timer). Router fallback shows the picker directly.
Mechanics: pending choice in Redis with one-shot
GETDELclaim (click and timer can never both launch), 64-byte-safe callback data, requester-only clicks, Nope re-keys state so the timer can never fire a rejected suggestion, superseding requests invalidate stale cards, and any confirmation-plumbing failure falls back to immediate launch so tasks are never dropped. Suggestion-button launches skip the card. NewTelegramCommunicationProvider.editMessageText(with HTML→plain fallback) finalizes cards in place.Testing
lint:fast,check-types:fast,knipclean.Docs
.agent-guidance/features/telegram-integration.md(config, inbound flow, testing, parity notes) and themock-telegram-testingskill updated in the same change.🤖 Generated with Claude Code