惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Martin Fowler
Martin Fowler
T
Tailwind CSS Blog
B
Blog RSS Feed
Vercel News
Vercel News
博客园 - 聂微东
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
GbyAI
GbyAI
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(telegram): register commands for group scope + preser...
dae-sun · 2026-05-02 · via Recent Commits to openclaw:main

@@ -152,12 +152,14 @@ describe("bot-native-command-menu", () => {

152152153153

it("deletes stale commands before setting new menu", async () => {

154154

const callOrder: string[] = [];

155-

const deleteMyCommands = vi.fn(async () => {

156-

callOrder.push("delete");

157-

});

158-

const setMyCommands = vi.fn(async () => {

159-

callOrder.push("set");

155+

const deleteMyCommands = vi.fn(async (options?: { scope?: { type?: string } }) => {

156+

callOrder.push(options?.scope?.type ? `delete:${options.scope.type}` : "delete:default");

160157

});

158+

const setMyCommands = vi.fn(

159+

async (_commands: unknown, options?: { scope?: { type?: string } }) => {

160+

callOrder.push(options?.scope?.type ? `set:${options.scope.type}` : "set:default");

161+

},

162+

);

161163162164

syncMenuCommandsWithMocks({

163165

deleteMyCommands,

@@ -171,7 +173,35 @@ describe("bot-native-command-menu", () => {

171173

expect(setMyCommands).toHaveBeenCalled();

172174

});

173175174-

expect(callOrder).toEqual(["delete", "set"]);

176+

expect(callOrder).toEqual([

177+

"delete:default",

178+

"delete:all_group_chats",

179+

"set:default",

180+

"set:all_group_chats",

181+

]);

182+

});

183+184+

it("registers the menu in default and group chat scopes", async () => {

185+

const deleteMyCommands = vi.fn(async () => undefined);

186+

const setMyCommands = vi.fn(async () => undefined);

187+

const commands = [{ command: "cmd", description: "Command" }];

188+189+

syncMenuCommandsWithMocks({

190+

deleteMyCommands,

191+

setMyCommands,

192+

commandsToRegister: commands,

193+

accountId: `test-scopes-${Date.now()}`,

194+

botIdentity: "bot-a",

195+

});

196+197+

await vi.waitFor(() => {

198+

expect(setMyCommands).toHaveBeenCalledTimes(2);

199+

});

200+201+

expect(setMyCommands).toHaveBeenCalledWith(commands);

202+

expect(setMyCommands).toHaveBeenCalledWith(commands, {

203+

scope: { type: "all_group_chats" },

204+

});

175205

});

176206177207

it("produces a stable hash regardless of command order (#32017)", () => {

@@ -209,7 +239,7 @@ describe("bot-native-command-menu", () => {

209239

});

210240211241

await vi.waitFor(() => {

212-

expect(setMyCommands).toHaveBeenCalledTimes(1);

242+

expect(setMyCommands).toHaveBeenCalledTimes(2);

213243

});

214244215245

// Second sync with the same commands — hash is cached, should skip.

@@ -222,8 +252,8 @@ describe("bot-native-command-menu", () => {

222252

botIdentity: "bot-a",

223253

});

224254225-

// setMyCommands should NOT have been called a second time.

226-

expect(setMyCommands).toHaveBeenCalledTimes(1);

255+

// setMyCommands should NOT have been called again for either scope.

256+

expect(setMyCommands).toHaveBeenCalledTimes(2);

227257

});

228258229259

it("does not reuse cached hash across different bot identities", async () => {

@@ -241,7 +271,7 @@ describe("bot-native-command-menu", () => {

241271

accountId,

242272

botIdentity: "token-bot-a",

243273

});

244-

await vi.waitFor(() => expect(setMyCommands).toHaveBeenCalledTimes(1));

274+

await vi.waitFor(() => expect(setMyCommands).toHaveBeenCalledTimes(2));

245275246276

syncMenuCommandsWithMocks({

247277

deleteMyCommands,

@@ -251,7 +281,7 @@ describe("bot-native-command-menu", () => {

251281

accountId,

252282

botIdentity: "token-bot-b",

253283

});

254-

await vi.waitFor(() => expect(setMyCommands).toHaveBeenCalledTimes(2));

284+

await vi.waitFor(() => expect(setMyCommands).toHaveBeenCalledTimes(4));

255285

});

256286257287

it("does not cache empty-menu hash when deleteMyCommands fails", async () => {

@@ -271,7 +301,7 @@ describe("bot-native-command-menu", () => {

271301

accountId,

272302

botIdentity: "bot-a",

273303

});

274-

await vi.waitFor(() => expect(deleteMyCommands).toHaveBeenCalledTimes(1));

304+

await vi.waitFor(() => expect(deleteMyCommands).toHaveBeenCalledTimes(2));

275305276306

syncMenuCommandsWithMocks({

277307

deleteMyCommands,

@@ -281,7 +311,7 @@ describe("bot-native-command-menu", () => {

281311

accountId,

282312

botIdentity: "bot-a",

283313

});

284-

await vi.waitFor(() => expect(deleteMyCommands).toHaveBeenCalledTimes(2));

314+

await vi.waitFor(() => expect(deleteMyCommands).toHaveBeenCalledTimes(4));

285315

});

286316287317

it("retries with fewer commands on BOT_COMMANDS_TOO_MUCH", async () => {

@@ -307,12 +337,15 @@ describe("bot-native-command-menu", () => {

307337

});

308338309339

await vi.waitFor(() => {

310-

expect(setMyCommands).toHaveBeenCalledTimes(2);

340+

expect(setMyCommands).toHaveBeenCalledTimes(3);

311341

});

312342

const firstPayload = setMyCommands.mock.calls[0]?.[0] as Array<unknown>;

313343

const secondPayload = setMyCommands.mock.calls[1]?.[0] as Array<unknown>;

344+

const thirdPayload = setMyCommands.mock.calls[2]?.[0] as Array<unknown>;

314345

expect(firstPayload).toHaveLength(100);

315346

expect(secondPayload).toHaveLength(80);

347+

expect(thirdPayload).toHaveLength(80);

348+

expect(setMyCommands.mock.calls[2]?.[1]).toEqual({ scope: { type: "all_group_chats" } });

316349

expect(runtimeLog).toHaveBeenCalledWith(

317350

"Telegram rejected 100 commands (BOT_COMMANDS_TOO_MUCH); retrying with 80.",

318351

);

@@ -343,7 +376,7 @@ describe("bot-native-command-menu", () => {

343376

});

344377345378

await vi.waitFor(() => {

346-

expect(setMyCommands).toHaveBeenCalledTimes(2);

379+

expect(setMyCommands).toHaveBeenCalledTimes(3);

347380

});

348381

expect(runtimeLog).toHaveBeenCalledWith(

349382

"Telegram rejected 10 commands (BOT_COMMANDS_TOO_MUCH); retrying with 8.",