diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f985e4a60..2cad2f5b370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Docs: https://docs.openclaw.ai - Matrix/mentions: keep room mention gating strict while accepting visible `@displayName` Matrix URI labels, so `requireMention` works for non-OpenClaw Matrix clients again. (#64796) Thanks @hclsys. - Doctor: warn when on-disk agent directories still exist under `~/.openclaw/agents//agent` but the matching `agents.list[]` entries are missing from config. (#65113) Thanks @neeravmakwana. +- Telegram: route approval button callback queries onto a separate sequentializer lane so plugin approval clicks can resolve immediately instead of deadlocking behind the blocked agent turn. (#64979) Thanks @nk3750. ## 2026.4.11 diff --git a/extensions/telegram/src/sequential-key.test.ts b/extensions/telegram/src/sequential-key.test.ts index d06e1c547a3..5d15f337577 100644 --- a/extensions/telegram/src/sequential-key.test.ts +++ b/extensions/telegram/src/sequential-key.test.ts @@ -94,6 +94,50 @@ describe("getTelegramSequentialKey", () => { { message: mockMessage({ chat: mockChat({ id: 123 }), text: "halt" }) }, "telegram:123:control", ], + [ + { + update: { + callback_query: { + message: mockMessage({ chat: mockChat({ id: 123 }) }), + data: "/approve plugin:abc123 allow-once", + }, + }, + }, + "telegram:123:approval", + ], + [ + { + update: { + callback_query: { + message: mockMessage({ chat: mockChat({ id: 456 }) }), + data: "/approve exec:def456 deny", + }, + }, + }, + "telegram:456:approval", + ], + [ + { + update: { + callback_query: { + message: mockMessage({ chat: mockChat({ id: 789 }) }), + data: "/approve plugin:ghi789 always", + }, + }, + }, + "telegram:789:approval", + ], + [ + { + update: { + callback_query: { + message: mockMessage({ chat: mockChat({ id: 123 }) }), + data: "some-other-button", + }, + }, + }, + "telegram:123", + ], [{ message: mockMessage({ chat: mockChat({ id: 123 }), text: "/abort" }) }, "telegram:123"], [{ message: mockMessage({ chat: mockChat({ id: 123 }), text: "/abort now" }) }, "telegram:123"], [ diff --git a/extensions/telegram/src/sequential-key.ts b/extensions/telegram/src/sequential-key.ts index 5309a88a32c..4d021b963d7 100644 --- a/extensions/telegram/src/sequential-key.ts +++ b/extensions/telegram/src/sequential-key.ts @@ -1,4 +1,5 @@ import { type Message, type UserFromGetMe } from "@grammyjs/types"; +import { parseExecApprovalCommandText } from "openclaw/plugin-sdk/infra-runtime"; import { isAbortRequestText } from "openclaw/plugin-sdk/reply-runtime"; import { isBtwRequestText } from "openclaw/plugin-sdk/reply-runtime"; import { resolveTelegramForumThreadId } from "./bot/helpers.js"; @@ -14,7 +15,7 @@ export type TelegramSequentialKeyContext = { edited_message?: Message; channel_post?: Message; edited_channel_post?: Message; - callback_query?: { message?: Message }; + callback_query?: { message?: Message; data?: string }; message_reaction?: { chat?: { id?: number } }; }; }; @@ -52,6 +53,13 @@ export function getTelegramSequentialKey(ctx: TelegramSequentialKeyContext): str } return "telegram:btw"; } + const callbackData = ctx.update?.callback_query?.data; + if (callbackData && parseExecApprovalCommandText(callbackData) !== null) { + if (typeof chatId === "number") { + return `telegram:${chatId}:approval`; + } + return "telegram:approval"; + } const isGroup = msg?.chat?.type === "group" || msg?.chat?.type === "supergroup"; const messageThreadId = msg?.message_thread_id; const isForum = msg?.chat?.is_forum;