From b4b1cc5556049986af10a4c5c4ec0d65b97bc268 Mon Sep 17 00:00:00 2001 From: haojr Date: Thu, 3 Dec 2026 00:21:42 +0000 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20no=20=F0=9F=91=80=20ack=20reaction?= =?UTF-8?q?=20with=20[telegram]=20thinking=5Fstatus=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the flag on, the thinking status line is the ack: the server sets no eyes reaction in any chat, including groups and a failed draft call (owner msgs #6867, #6871). Flag off is unchanged. Co-Authored-By: Claude Opus 5.5 --- crates/axe-core/src/config.rs | 3 ++- crates/axe-telegram/src/telegram.rs | 11 +++++++--- crates/axe/tests/telegram.rs | 34 +++++++++++++++++++++++++++++ docs/design/bots.md | 4 +++- docs/user/primitives/bot.md | 14 +++++++----- docs/user/reference/config.md | 3 ++- 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/crates/axe-core/src/config.rs b/crates/axe-core/src/config.rs index 1595b21..78e3245 100644 --- a/crates/axe-core/src/config.rs +++ b/crates/axe-core/src/config.rs @@ -840,7 +840,8 @@ pub struct Telegram { /// A "thinking" status in the owner's private chats: while a woken bot /// has not yet answered, it also streams a `sendRichMessageDraft` with a /// `` block (Bot API 10.1), shown as an animated status - /// line. Off (the default): `typing` only, as before. + /// line, and the server sets no 👀 ack reaction in any chat. Off (the + /// default): `typing` and the reaction, as before. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub thinking_status: bool, } diff --git a/crates/axe-telegram/src/telegram.rs b/crates/axe-telegram/src/telegram.rs index 195fe57..bee8fe4 100644 --- a/crates/axe-telegram/src/telegram.rs +++ b/crates/axe-telegram/src/telegram.rs @@ -58,7 +58,8 @@ const THINKING_DRAFT: i64 = 1; 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…"; -/// Reaction set on every accepted owner message. +/// Reaction set on every accepted owner message, unless `[telegram] +/// thinking_status` is on. pub const ACK_EMOJI: &str = "👀"; /// About one message per second per chat. const SEND_INTERVAL: Duration = Duration::from_secs(1); @@ -1520,8 +1521,10 @@ impl Gateway { }, )?; if !dup { - // Acknowledge: the owner sees the message arrived. - if !edit { + // Acknowledge: the owner sees the message arrived. With + // `[telegram] thinking_status` the status line replaces the + // emoji, in every chat (emoji reactions are for real replies). + if !edit && !b.thinking { let r = b.api.call( "setMessageReaction", &json!({"chat_id":chat,"message_id":tg_id,"reaction":[{"type":"emoji","emoji":ACK_EMOJI}]}), @@ -1529,6 +1532,8 @@ impl Gateway { if let Err(e) = r { eprintln!("telegram: bot {}: ack #{msg}: {e}", b.name()); } + } + if !edit { if voice { voice_ack(b, store, chat, m["message_thread_id"].as_i64(), tg_id, msg); } diff --git a/crates/axe/tests/telegram.rs b/crates/axe/tests/telegram.rs index 4b80614..269e074 100644 --- a/crates/axe/tests/telegram.rs +++ b/crates/axe/tests/telegram.rs @@ -997,6 +997,13 @@ fn thinking_status_off_sends_typing_only() { } assert!(rig.stub.calls("sendRichMessageDraft").is_empty()); assert!(rig.stub.calls("sendMessageDraft").is_empty()); + // The 👀 ack, as today. + let acks = rig.stub.calls("setMessageReaction"); + assert_eq!(acks.len(), 1); + assert_eq!( + acks[0].params, + json!({"chat_id": OWNER, "message_id": 50, "reaction": [{"type":"emoji","emoji":"👀"}]}) + ); } #[test] @@ -1045,6 +1052,8 @@ fn thinking_status_on_streams_a_thinking_draft_until_the_bot_replies() { .any(|c| c.params["chat_id"] == GROUP) }); assert!(drafts().iter().all(|c| c.params["chat_id"] == OWNER)); + // The status line replaces the 👀 ack, in every chat (task 2535). + assert!(rig.stub.calls("setMessageReaction").is_empty()); bot::finish( &conn, run, @@ -1057,6 +1066,31 @@ fn thinking_status_on_streams_a_thinking_draft_until_the_bot_replies() { .unwrap(); } +#[test] +fn thinking_status_on_adds_no_ack_even_when_the_draft_fails() { + let rig = Rig::with("thinking_status = true"); + rig.send_faults("sendRichMessageDraft", &[SendFault::Status(400)]); + rig.stub.push(text_msg(30, 50, OWNER, OWNER, "hello")); + rig.stub.wait_confirmed(30); + wait_for("typing", 20, || { + !rig.stub.calls("sendChatAction").is_empty() + }); + wait_for("failed draft", 20, || { + !rig.stub.calls("sendRichMessageDraft").is_empty() + }); + // A group message too: no draft there, and no emoji either. + rig.stub + .push(text_msg(31, 51, OWNER, GROUP, "in the group")); + rig.stub.wait_confirmed(31); + wait_for("group typing", 20, || { + rig.stub + .calls("sendChatAction") + .iter() + .any(|c| c.params["chat_id"] == GROUP) + }); + assert!(rig.stub.calls("setMessageReaction").is_empty()); +} + #[test] fn unauthorized_group_membership_makes_the_bot_leave() { let rig = Rig::new(); diff --git a/docs/design/bots.md b/docs/design/bots.md index dfbfbe6..50663d7 100644 --- a/docs/design/bots.md +++ b/docs/design/bots.md @@ -220,7 +220,9 @@ and schedules stay in that bot's `/status`, so the two never repeat. `` block, "Waking up…" on accept and "Working…" 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. +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 +left for the bot's real replies. ### Board diff --git a/docs/user/primitives/bot.md b/docs/user/primitives/bot.md index 7efe41b..3236b29 100644 --- a/docs/user/primitives/bot.md +++ b/docs/user/primitives/bot.md @@ -39,12 +39,14 @@ Links to the web portal in Telegram (command replies, goal and task links on the board pin, a form's task) appear only with `[telegram] web_login` on; off, the default, none do. Blob links and sealed form buttons are not portal links. One gate: `Gateway::new` in `crates/axe-telegram/src/telegram.rs`. -While a bot works on the owner's message, 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…", until the bot's next message there. Groups get `typing` -only, and a client without draft support shows `typing` only. See -`TgBot::accepted` and `typing_loop` 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…", +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 +`crates/axe-telegram/src/telegram.rs`. The bot protocol (runs, wakes, memory, authority, Telegram) is built in; bundles in the [store](store.md) only add opinions. diff --git a/docs/user/reference/config.md b/docs/user/reference/config.md index 81eb835..c0c5ec5 100644 --- a/docs/user/reference/config.md +++ b/docs/user/reference/config.md @@ -16,7 +16,8 @@ Opt-in `[telegram]` switches, all off by default: `web_login` (the `/web` command and every portal link in Telegram) and `thinking_status` (an animated "Working…" status line in the owner's private chat while a woken bot has not answered yet, made with `sendRichMessageDraft`, Bot API 10.1; -see [bots](../primitives/bot.md)). +it replaces the server's 👀 ack reaction, which is then never added; see +[bots](../primitives/bot.md)). `crates/axe-core/src/config.rs` defines every table, default and check; `axe config` validates and prints the resolved file, including the built-in agents. From 0ba890c5ff337f58d5f2208e97c23b6dfd6dd820 Mon Sep 17 00:00:00 2001 From: haojr Date: Thu, 3 Dec 2026 00:28:11 +0000 Subject: [PATCH 2/2] fix: collapse the voice ack if (clippy) Co-Authored-By: Claude Opus 5.5 --- crates/axe-telegram/src/telegram.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/axe-telegram/src/telegram.rs b/crates/axe-telegram/src/telegram.rs index bee8fe4..6caa88d 100644 --- a/crates/axe-telegram/src/telegram.rs +++ b/crates/axe-telegram/src/telegram.rs @@ -1533,10 +1533,8 @@ impl Gateway { eprintln!("telegram: bot {}: ack #{msg}: {e}", b.name()); } } - if !edit { - if voice { - voice_ack(b, store, chat, m["message_thread_id"].as_i64(), tg_id, msg); - } + if !edit && voice { + voice_ack(b, store, chat, m["message_thread_id"].as_i64(), tg_id, msg); } b.accepted(store, chat, m["message_thread_id"].as_i64()); }