Skip to content

Show OpenUI answer content in Telegram replies - #503

Open
rpavlovs wants to merge 1 commit into
hamedgitty:mainfrom
rpavlovs:telegram-openui-reply
Open

rpavlovs wants to merge 1 commit into
hamedgitty:mainfrom
rpavlovs:telegram-openui-reply

Conversation

@rpavlovs

Copy link
Copy Markdown
Contributor

When an agent answers a Telegram message with an OpenUI block, the reply drops the block. Prose around it is sent without the table, and an answer that is only a block arrives as "The answer is interactive. Open Bloks to see it." Someone who asked from Telegram for a comparison or a list gets none of the data the agent produced.

For a Telegram message that runs as its own turn, the OpenUI blocks in the final answer that the reply already selects are now replaced in place by what they display. Tables go through the existing rich-table reply from #342, so the plain-text fallback keeps every value. Other components become labelled text in their original order: headers, text, callouts, metrics, tags, lists, steps, tabs and accordions, chart labels with their values, code, quotes, image alt text, and sources with their links. Buttons, forms and option choices show their labels with a line saying the controls cannot be used here. Their actions, bindings, state and default values are never sent, and nothing treats a Telegram reply as a choice.

Nothing is silently cut, following #319. When the existing parser rejects or truncates a block, the reply keeps what that block can safely show and adds "Some of this interface could not be displayed here." Values are never guessed, a value that may have been clipped is left out rather than shown as complete, and chart series of different lengths are not paired. Each block is parsed on its own under the existing per-block limits, so one bad block does not hide the others. Newly shown values pass through the same secret redaction as the answer text, and literal pipes and line breaks stay literal.

Only that exact answer is used. Bloks keeps the request and the selected answer when the turn completes and checks both again just before sending. If either changed, was deleted or cannot be confirmed, the reply is sent exactly as before. These also keep their current reply: a message that joins a turn already running, retries, backup-engine handovers and pickups, replies delivered later after a restart, explicit replies to restricted people and groups, components shown separately with show, legacy component blocks, and Signal. Sender rules are unchanged: connection and grant checks, files, plain text only after a definite refusal, and no resend after an uncertain send.

Checked:

  • CI on this exact commit passed on its second attempt: typecheck, 6,530 tests (5 skipped), build and the stray build output check (run). The first attempt failed one test outside this change, custom-endpoint-headers ("headers are saved by name, never sent back, and no route returns a value"): the engine settings response had no custom endpoint rows. It is intermittent without this change too: in local runs it failed once in 10 runs of main's code with only a longer test startup wait, in none of 30 unmodified runs of main, and in 2 of 25 runs of this branch. Its cause is unknown.
  • telegram-openui covers each component family, prose and blocks in order, more than six blocks, rejected, truncated and unresolved values, hidden action data, redaction, literal pipes and blank lines, and the formatter's actual rich and plain parts.
  • telegram-openui-native runs the real server with a fake engine and a fake Telegram transport: a 30-row table alone and with prose for the owner and for a full-access delegate, the selected answer deleted before sending, two queued requests, joined and refused steers, retry and backup handover, a revoked grant, empty and failed turns followed by a later success, and a separate show row that is not collected.
  • telegram-progress covers keeping the request and answer at completion.
  • Changes that pick a neighboring answer, drop the last table row or expose a button action each make the tests fail.

Not checked: how the Telegram app shows the reply on a phone.

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.

1 participant