Repository navigation
feat(telegram): show widgets as interactive Telegram message widgets - #196991
Conversation
Telegram private chats get Bot API 10.4 message widgets from show_widget: - core passes the agent-authored source, a stable widget name, and an optional state to channel presenters that declare it, and lets them replace the browser-host authoring rules - widget taps become agent turns and state-only show_widget calls edit the tapped widget in place - a QuickJS trial run returns script errors, removed content, unsupported CSS and Telegram stop limits to the model before anything is sent Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: d1c37407-ba5d-496a-9e31-2084fd7304b4
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesAdds opt-in interactive Telegram widgets through show_widget, with widget taps starting agent turns and updating state in place. Example: A private-chat poll stores {"v":0}, and the user taps Vote.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds a useful capability absent from main, and both prior blockers are resolved; two failing checks still need attribution. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCore owns show_widget authoring and presentation selection; the Telegram plugin validates and sends widget code, admits incoming taps through existing authorization and ingress owners, and stores widget state through plugin-state storage. flowchart LR
Agent[Agent show_widget call] --> Core[Core widget tool]
Core --> Presenter[Telegram presenter]
Presenter --> Check[QuickJS trial run]
Check --> Telegram[Telegram message widget]
Telegram --> Ingress[Durable tap ingress]
Ingress --> Auth[Telegram authorization]
Auth --> Agent
Technical reviewBest possible solution: Keep the existing core presenter architecture and opt-in Telegram implementation, then resolve attribution of the failing checks before landing. Do we have a high-confidence way to reproduce the issue? This is a new capability; inspected Telegram screenshots and supplied live Gateway results demonstrate rendering and interactive state updates. Is this the best way to solve the issue? The change uses the existing show_widget presenter, Telegram transport, durable ingress, authorization, and plugin-state owners; the channel-specific runtime justifies its adapter and bounded checker. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8830ff6d8ed6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2203, Tests +706, Docs +22, Config +8, Generated 0, Other +5. Total +2944 across 45 files. Added test files: 4. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (10 earlier review cycles; latest 8 shown)
Reviewed November 11, 2026, 4:20 AM ET / 09:20 UTC (Revision 11). |
- record failed-retryable when tap routing fails before dispatch or the dispatch itself is retryable, instead of tombstoning the acknowledged tap - admit a durable replay of an already admitted query id - always send widgets with allow_queries; the query router gates taps - keep an explicitly empty show_widget state distinct from omission - do not reject undefined/NaN the author wrote as text or string literals Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 5dbff3c5-52ad-48ed-8e45-b4ea4a8c46e9
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… the trial run
- check an empty or missing state as null, as Telegram exposes it, while
still sending the empty state to clear the widget
- resolve request() with { result: null } like Telegram's acknowledgment
Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 2c2d8092-39e4-4a96-ba2e-586159fd75b0
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
OpenClaw-Publication: 5f1a4009-f666-4c2a-bc3e-f3fe53d120e7
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Agents in a Telegram private chat could not show
show_widgetdashboards, charts, checklists or polls. They fell back to text tables or images.User Impact
User impact: with the new opt-in setting
channels.telegram.widgets: true,show_widgetin a private chat with the bot sends a Telegram message widget (Bot API 10.4). Tapping it updates that same widget in place. Typed messages still start new messages, so the chat keeps its order.Default: off. Older Telegram clients cannot render widgets, the same compatibility problem that made
richMessagesopt-in in #93279. With the setting off, nothing changes:show_widgetbehaves as before, and taps on earlier widgets are dropped./statusshowsTelegram widgets: on/off. Groups, channels and DM topics are always unchanged.Why This Change Was Made
show_widget):state.statefield.stateand nowidget_codeupdates the tapped widget. An explicitly emptystateclears it.notes; the tool result passes them to the model while reporting the widget as delivered.pin=truewith such code returns a clear error. Pinned reports still work.channels.telegram.widgetsandchannels.telegram.accounts.<id>.widgetsbooleans (default off), with a config UI hint, docs and a/statusline. The channel config-surface budget goes from 4003 to 4005 for these two paths, because a compatibility opt-in needs a setting, likerichMessages.sendWidgetwith size checks; widgets in private chats only (never in topics, since taps come back without a thread), always sent withallow_queries.widget_querytaps are acknowledged as soon as they are durably admitted, then routed as agent turns./or!commands.failed-retryableso durable ingress retries it instead of dropping it./newor compaction.editMessageWidgetData. New code always becomes a new message.quickjs-wasi3.6.3, the same pinned engine Code Mode uses. It runs on the shared compute pool with a 1 s and 64 MB limit.TelegramWidgetAPI (theme colors and viewer included), runs 3 s of timers and taps every enabled button. State updates replay the stored code with the old state, then the new one.null, andrequest()resolves with{ result }.vh,sticky, scrolling,color-mix()) and network userequest()outside a tapshow_widgetresult:undefined/NaNshown on screenURL,crypto, ...) are sent unchecked.TextEncoderandTextDecoderare supplied.Evidence
Live Telegram Test Server (leased bot plus TDLib 1.8.70 user, real models through the Claude CLI, 20 prompts modelled on widget requests seen in production):
Taps on real widgets updated them in place with no extra message: poll vote, hotel pick, and a checklist's "Done for the day" sent from a later session.
Authorization through final effects (Test Server, head code, Sonnet 5.5, 2026-11-11). The allowlist was edited live in the Gateway config file, and each edit was hot-reloaded (
[reload] config source revision N accepted). Model turns are counted fromcli turnlog lines; widget state and bot messages are read from the tester's chat.{"w":0,"v":0,"p":0}→{"w":0,"v":1,"p":0}, in placeallowFrom, then taps Widgetsp→ 1, in placeA denied sender never reaches a model or Telegram. Revocation after a turn has been admitted does not cancel that turn. This matches how ordinary text messages already behave, so widget taps add no new path.
Upgrade from the latest stable release (
pnpm test:docker:published-upgrade-survivor, baseline[email protected], candidate packed from843ccf6): passed in 946 s.assert-automatic-migration,assert-survival,doctor,gateway-startandgateway-probes.telegram.widgetsandtelegram.widget-taps. Those names don't collide with the Telegram namespaces already onmain(bot-info-cache,poll-registry,sticker-cache,update-offsets), so existing Telegram rows are never read or rewritten by this change.Trial run against 92 widgets written by real models: 3 of them were really broken on Telegram.
overflow: auto.undefinedgets a note.Trap prompts (sticky header, Chart.js, live price, text inputs, avatar URLs):
Review fixes, each with a regression test:
failed-retryablestatereaches the presenter as a clearing update, and the checker sees it asnullrequest().then(a => a.result)passes the trial runpin=truewith Telegram-native widget code is refused before anything is written to the dashboardwidgetsunset or false, the presenter does not match and taps are dropped before any lookup or agent turn;/statusshows both statesthemeParams,viewer,TextEncoderand data GIFs work; CSS conditional rules and specificity follow the cascadeChecks: 167 tests pass across
src/canvasand the Telegram widget suites. Typecheck is clean (tsgo:core,tsgo:extensions,tsgo:core:test,tsgo:extensions:test). The baseline ratchets, extension lint and boundary lint pass.Screenshots
Telegram Web, dark theme, widgets sent by real models on the Telegram Test Server. All data is sample data. Light theme and mobile clients have not been checked yet.