Skip to content

feat(telegram): generic inline keyboard buttons for gateway commands - #5857

Closed
rahimsais wants to merge 1 commit into
NousResearch:mainfrom
rahimsais:feat/telegram-inline-keyboards-v2
Closed

feat(telegram): generic inline keyboard buttons for gateway commands#5857
rahimsais wants to merge 1 commit into
NousResearch:mainfrom
rahimsais:feat/telegram-inline-keyboards-v2

Conversation

@rahimsais

Copy link
Copy Markdown
Contributor

Summary

Add a reusable inline keyboard button system for Telegram gateway commands, complementing the existing model picker (#5742).

Architecture

  • BasePlatformAdapter.send_inline_options() — generic method with text fallback for non-Telegram platforms
  • TelegramAdapter override renders native InlineKeyboardButton
  • Generic callback routing: cmd:args → synthetic /cmd args through _message_handler
  • Dedicated cpg: callback prefix for /commands pagination (edit-in-place, like model picker's mp:/mg:)
  • mc cancel callback as standard UX pattern
  • gateway_runner reference set on all adapters during init for cross-reference

Commands with inline buttons

Command Behavior
/commands Paginated Prev/Next that edits in-place (like model picker)
/personality Picker with all configured personalities
/rollback Checkpoint list picker
/resume Named session picker
Dangerous commands Approval buttons: Allow Once / Allow Session / Always Allow / Deny

Fixes included

  • Drop ParseMode.MARKDOWN from callback message edits — skill descriptions with unbalanced backticks break Telegram's markdown parser
  • Truncate skill descriptions to 120 chars in /commands pages to stay under Telegram's 4096 char limit
  • Use getattr for dynamically-set gateway_runner attribute

Files changed

  • gateway/platforms/base.pysend_inline_options() base method
  • gateway/platforms/telegram.py — native inline keyboard + callback handlers
  • gateway/run.py — extracted _build_commands_page() helper, inline buttons for 4 commands, gateway_runner init on all adapters

Add a reusable inline keyboard button system for Telegram gateway
commands, complementing the existing model picker.

Architecture:
- BasePlatformAdapter.send_inline_options() with text fallback
- TelegramAdapter override renders native InlineKeyboardButton
- Generic callback routing: 'cmd:args' -> synthetic '/cmd args'
- Dedicated cpg: prefix for /commands pagination (edit-in-place)
- Cancel button (mc) and approval buttons (approve:once/session/always/deny)
- gateway_runner ref set on all adapters for cross-reference

Commands with inline buttons:
- /commands: paginated Prev/Next that edits in-place (like model picker)
- /personality: picker with all configured personalities
- /rollback: checkpoint list picker
- /resume: named session picker
- Dangerous command approval: Allow Once/Session/Always/Deny buttons

Fixes:
- Drop ParseMode.MARKDOWN from callback edits (skill descriptions
  with unbalanced backticks break Telegram's markdown parser)
- Truncate skill descriptions to 120 chars in /commands pages
- Use getattr for dynamically-set gateway_runner attribute
@teknium1

teknium1 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

The approval button functionality was merged in #5890 (approval buttons for Slack & Telegram + callback handling). The generic inline button system for other commands (/commands, /personality, etc.) is an interesting idea but would need a full rebase and removal of the now-redundant approval parts. Closing as substantially superseded — if you'd like to resubmit just the generic button system as a separate PR, that would be welcome.

@teknium1 teknium1 closed this Apr 7, 2026
@rahimsais
rahimsais deleted the feat/telegram-inline-keyboards-v2 branch April 13, 2026 08:09
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.

3 participants