diff --git a/crates/axe-telegram/src/telegram.rs b/crates/axe-telegram/src/telegram.rs index 6caa88d..54e914e 100644 --- a/crates/axe-telegram/src/telegram.rs +++ b/crates/axe-telegram/src/telegram.rs @@ -54,10 +54,12 @@ const TYPING_REFRESH: Duration = Duration::from_secs(4); /// `[telegram] thinking_status`: the `sendRichMessageDraft` id of the /// status line (non-zero; one per chat, so a change of text is animated). const THINKING_DRAFT: i64 = 1; -/// The status line from an accepted owner message until its run starts. -pub const THINKING_WAKING: &str = "Waking up…"; -/// The status line while the woken run is live and has not answered. -pub const THINKING_WORKING: &str = "Working…"; +/// The status line (rich HTML) from an accepted owner message until its run +/// starts: a plain loading line, no words (owner msg #6879). +pub const THINKING_WAKING: &str = "…"; +/// The status line (rich HTML) while the woken run is live and has not +/// answered: a `` block, drawn with a shimmer. +pub const THINKING_WORKING: &str = "Working…"; /// Reaction set on every accepted owner message, unless `[telegram] /// thinking_status` is on. pub const ACK_EMOJI: &str = "👀"; @@ -3121,10 +3123,9 @@ impl Gateway { } } -/// The `sendRichMessageDraft` parameters of the status line `text` (plain -/// text, escaped here) in `chat`. -pub fn thinking_draft(chat: i64, text: &str) -> Value { - let html = format!("{}", html_escape(text)); +/// The `sendRichMessageDraft` parameters of the status line `html` +/// ([`THINKING_WAKING`] or [`THINKING_WORKING`]) in `chat`. +pub fn thinking_draft(chat: i64, html: &str) -> Value { json!({"chat_id": chat, "draft_id": THINKING_DRAFT, "rich_message": {"html": html}}) } @@ -3970,9 +3971,9 @@ impl TgBot { /// The status line: a `sendRichMessageDraft` (private chats only, a /// 30-second preview Telegram clears when the bot sends a message) of - /// one `` block, best effort. `text` is plain (no markup). - fn thinking(&self, chat: i64, thread: Option, text: &str) { - let mut p = thinking_draft(chat, text); + /// `html`, best effort. + fn thinking(&self, chat: i64, thread: Option, html: &str) { + let mut p = thinking_draft(chat, html); if let Some(t) = thread { p["message_thread_id"] = json!(t); } diff --git a/crates/axe/tests/telegram.rs b/crates/axe/tests/telegram.rs index 269e074..261a5a4 100644 --- a/crates/axe/tests/telegram.rs +++ b/crates/axe/tests/telegram.rs @@ -1010,22 +1010,21 @@ fn thinking_status_off_sends_typing_only() { fn thinking_status_on_streams_a_thinking_draft_until_the_bot_replies() { let rig = Rig::with("thinking_status = true"); let drafts = || rig.stub.calls("sendRichMessageDraft"); - let draft = |text: &str| { - json!({"chat_id": OWNER, "draft_id": 1, - "rich_message": {"html": format!("{text}")}}) - }; - // Accepted: typing as before, plus the waking status line. + let draft = + |html: &str| json!({"chat_id": OWNER, "draft_id": 1, "rich_message": {"html": html}}); + // Accepted: typing as before, plus the waking status line: a plain + // loading line, no words (owner msg #6879). rig.stub.push(text_msg(30, 50, OWNER, OWNER, "hello")); rig.stub.wait_confirmed(30); wait_for("waking draft", 20, || drafts().len() == 1); - assert_eq!(drafts()[0].params, draft("Waking up…")); + assert_eq!(drafts()[0].params, draft("…")); assert_eq!(rig.stub.calls("sendChatAction").len(), 1); // The live run: each typing refresh also streams the working line. let (conn, run) = start_run(&rig); wait_for("working drafts", 30, || drafts().len() >= 3); for c in &drafts()[1..] { - assert_eq!(c.params, draft("Working…")); + assert_eq!(c.params, draft("Working…")); } for c in rig.stub.calls("sendChatAction") { assert_eq!(c.params, json!({"chat_id": OWNER, "action": "typing"})); diff --git a/docs/design/bots.md b/docs/design/bots.md index 50663d7..09a0eee 100644 --- a/docs/design/bots.md +++ b/docs/design/bots.md @@ -216,9 +216,9 @@ and schedules stay in that bot's `/status`, so the two never repeat. `/web` replies in the owner's private chat with a one-time web login link, only with `[telegram] web_login = true` (off by default, for Telegram-only installs; `Gateway::web_reply` in `telegram.rs`, the key in `config.rs`). The same key gates every other portal link Telegram shows (view links, board goal and task links, a form's task): `Gateway::new` drops the public URL when it is off. `[telegram] thinking_status = true` (off by default, task 2528, store doc `harvis/research/20261203-telegram-rich-entities.md`) adds a status line next to -`typing`. In a private chat it is a `sendRichMessageDraft` with one -`` block, "Waking up…" on accept and "Working…" on each typing -refresh. It stops once the bot sends to that chat (`TgBot::awaits_reply`); +`typing`. In a private chat it is a `sendRichMessageDraft` (one draft id, so +changes animate): plain "…" on accept (no words, owner msg #6879) and a +`Working…` block on each typing refresh. It stops once the bot sends to that chat (`TgBot::awaits_reply`); Telegram clears the draft then, or after 30 s. The server adds it, so the model writes no markup. With the flag on the server sets no 👀 ack reaction in any chat (task 2535): the status line is the ack, and emoji reactions are diff --git a/docs/user/primitives/bot.md b/docs/user/primitives/bot.md index 3236b29..c6185f5 100644 --- a/docs/user/primitives/bot.md +++ b/docs/user/primitives/bot.md @@ -42,7 +42,8 @@ links. One gate: `Gateway::new` in `crates/axe-telegram/src/telegram.rs`. The server acknowledges each accepted owner message with a 👀 reaction, and while a bot works on it the chat shows Telegram's `typing` status. With `[telegram] thinking_status = true` (off by default), the owner's private -chat also shows an animated status line, "Waking up…" and then "Working…", +chat also shows an animated status line: a plain "…" until the bot's run +starts, then a shimmering "Working…", until the bot's next message there, and the server adds no 👀 reaction in any chat. Groups get `typing` only, and a client without draft support shows `typing` only. See `TgBot::accepted` and `typing_loop` in