fix(telegram): slash menu + repo navigator + inline approvals#189
Merged
Conversation
Fix A — slash menu: register the bot's command list with Telegram via setMyCommands at bridge startup so typing `/` shows the command popup. BOT_COMMANDS in commands.ts is the single source of truth for the menu + /help (list/session/status/doctor/help — only the real handled commands). Idempotent, fire-and-forget, gated on botToken. Fix B — repo navigator: the callback_query session-picker path was structurally intact at #188 (proven by new integration tests) — its real- world "broken" symptom was the missing slash menu (Fix A) making /list undiscoverable. Hardened: webhook picker re-render now uses PAGE_SIZE instead of a hardcoded 20, and set_session/paginate/unknown callbacks are now covered by integration tests that lock the contract. Fix C — inline approval prompts: when a Telegram-driven session hits a tool permission prompt it no longer blocks silently. ws/agent.ts emits a permission_request:pending event (new isolated bus, mirrors assistant- events); the bridge surfaces it inline with Approve/Deny buttons to users whose default session matches. Taps route through the existing callback_query path → handlePermissionCallback forwards a permission_response frame on the agent socket (same frame the web client sends). Pending prompts are tracked in an in-memory registry keyed by request_id (callback_data is too small for session+request UUIDs) which also enforces per-user authorization. No new dispatch path — this is a control-frame reply to a runner-initiated prompt, so the cost-cap pipeline is untouched. Tests: telegram-approvals (registry + codec), telegram-bridge (slash menu + permission surfacing), telegram-webhook (callback set_session/paginate + approve/deny/stale/foreign/offline). check-baseline GREEN (947 pass, 0 fail). docs/telegram-bridge.md updated in lockstep. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
finedesignz
added a commit
that referenced
this pull request
May 30, 2026
#191) Three deliverables for the hub Telegram bridge (one cohesive feature): 1. MarkdownV2 formatting. All user-facing bridge messages now send with parse_mode MarkdownV2. New sendMessageMd / editMessageTextMd wrap the send with a 400->plain-text single retry so an unbalanced reserved char never silently drops a session reply. Reuses the existing escapeMarkdownV2 (full reserved set). Inline approve/deny prompt is MarkdownV2 with the same fallback; keyboard unaffected. 2. Summarized streaming. New session-activity event bus (tool_use one-liners) emitted from ws/agent.ts. The bridge maintains one editable "Working..." message per (chat, session): each tool_use appends a collapsed one-liner (throttled edit), a typing chat-action refreshes ~every 4s, and assistant_message:final edits the same message to the full answer. Gated on config.telegram.summarizedStreaming (TELEGRAM_SUMMARIZED_STREAMING=false reverts to a single final-blob send). No parallel dispatch path; cost-cap gate untouched. 3. MED fast-follow (#189 review). approvals.ts pending-prompt registry was keyed by requestId alone -> a shared default session clobbered the first binding and locked out a valid approver. Re-keyed by (sessionId, requestId) holding a set of authorized userIds; takePendingPrompt(requestId, userId) folds in the authorization check and resolves exactly once for whichever authorized user taps first. Tests: escaper (every reserved char, existing) + 400->plaintext fallback (new file, cache-busted import to dodge cross-file Bun mock pollution) + approval re-keying incl. two-users-same-default-session. check-baseline GREEN (956 pass / 0 fail). docs/telegram-bridge.md updated. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
@-