feat(gateway): interactive controls with Telegram inline keyboards (Phase 1 of #503) - #2188
feat(gateway): interactive controls with Telegram inline keyboards (Phase 1 of #503)#2188gaelcado wants to merge 4 commits into
Conversation
2a0fc97 to
5404f5b
Compare
|
Rebased this onto latest main and reorganized into 3 clean, incrementally reviewable commits. Quick summary of where this stands: Status: Rebased, all 5719 tests pass (the 3 failures are pre-existing upstream issues in transcription/delegate tests). I'll keep this rebased every 2-3 days. Why this is low-risk:
Design alignment with #503:
Let me know if anything needs changing! |
|
Would it make sense to also use inline keyboards for long message truncation? When a response exceeds 25 lines, show the first 25 with an 'Expand 📄' button. |
…model Introduce ControlsDef and ButtonDef TypedDicts as a transport-agnostic abstraction for interactive controls (buttons, option lists). Add render_controls_as_text() fallback for platforms without native support, MAX_INTERACTIVE_BUTTONS on BasePlatformAdapter, and send_interactive() base method with automatic text fallback. This serves as the shared component model for gateway and future RPC, as discussed in #503. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ram inline keyboards Wire ControlsDef into the clarify and approval flows: - Clarify tool gains controls parameter with 120s timeout - Approval uses inline accept/reject buttons - _pending_clarifications dict tracks active sessions - Telegram adapter builds native InlineKeyboardMarkup via build_telegram_reply_markup() and handles CallbackQueryHandler - send_interactive() Telegram override for rich button rendering - Cleanup on /stop and shutdown Phase 1 of #503. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive test coverage for the interactive controls feature: - test_approval_interactions.py (new, 326 lines) - test_clarify_interactions.py (new, 389 lines) - test_telegram_conflict.py (updated) - test_telegram_text_batching.py (updated) - test_send_message_tool.py (updated) - 9 existing test files updated with _pending_clarifications stubs All 62 interaction tests pass. Backward compatibility verified by stub updates across existing gateway test suite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5404f5b to
beeb8fb
Compare
|
(Rebased on latest main; resolved one gateway/run.py conflict with no scope change)
For this PR, I kept scope strictly to Issue #503 (transport-agnostic controls + Telegram clarify/approval lifecycle) to keep changes focused and incremental. I’d prefer to land this first, then open a small follow-up PR for long-message expand/collapse Feel free to open an issue! |
|
Thanks for this @gaelcado — Phase 1 of #503 is one of the more thoughtful design proposals we've gotten, and the transport-agnostic ControlsDef/ButtonDef shape directly informed how we built this out. Closing because the feature has since shipped on
The merged design follows the same shape you proposed (transport-agnostic core + per-platform native renderers + numbered-text fallback), so credit for the direction is yours. We won't be cherry-picking from this branch — it's ~5700 commits behind If you want to tackle Phase 2 (execution plans / structured todo presentation from #503) on top of the current |
Phase 1 of #503 — Transport-Agnostic Interactive Controls
Implements the shared component model discussed in #503 — a transport-agnostic
ControlsDef/ButtonDefabstraction that any platform adapter can render natively, with Telegram inline keyboards as the first native renderer.What this adds
ControlsDef/ButtonDefTypedDicts — transport-agnostic controls model ingateway/platforms/base.pyrender_controls_as_text()fallback — platforms without native support automatically get text-based buttonssend_interactive()API — base method with text fallback, Telegram override for InlineKeyboardMarkup_pending_clarificationssession tracking — maps callback queries to pending clarify futuresCallbackQueryHandler— handles button presses, routes to correct session/stopand shutdown — pending interactions are cancelled gracefullyKey design decisions
send_interactive()MAX_INTERACTIVE_BUTTONS— per-adapter limit (Telegram: 8, WhatsApp: 3) to respect platform constraintsCommit structure (reviewable incrementally)
feat(gateway): add transport-agnostic ControlsDef/ButtonDef controls model— foundation types and fallback renderingfeat(gateway): wire interactive clarify/approval lifecycle with Telegram inline keyboards— lifecycle integration and Telegram adaptertest(gateway): add interaction controls test suite (62 tests)— full test coverage including backward compat stubsTesting
_pending_clarificationsstubs to maintain backward compatibilityFiles changed (20 files, ~1850 additions)
base.py,whatsapp.pyrun.py,telegram.py,clarify_tool.py,send_message_tool.py