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

推荐订阅源

GbyAI
GbyAI
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
小众软件
小众软件
博客园_首页
博客园 - 聂微东
罗磊的独立博客
Recent Announcements
Recent Announcements
U
Unit 42
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
D
DataBreaches.Net
Last Week in AI
Last Week in AI

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(feishu): drop self-authored receive events (#90572) ·...
baskduf · 2026-06-16 · via Recent Commits to openclaw:main
1+

// Feishu tests cover monitor.message handler plugin behavior.

2+

import { describe, expect, it, vi } from "vitest";

3+

import type { ClawdbotConfig, PluginRuntime } from "../runtime-api.js";

4+

import type { FeishuMessageEvent } from "./event-types.js";

5+

import { createFeishuMessageReceiveHandler } from "./monitor.message-handler.js";

6+7+

type MessageReceiveHandlerContext = Parameters<typeof createFeishuMessageReceiveHandler>[0];

8+

type HandleMessageParams = Parameters<MessageReceiveHandlerContext["handleMessage"]>[0];

9+10+

function createTextEvent(params: {

11+

messageId: string;

12+

senderOpenId: string;

13+

senderType: "bot" | "user";

14+

}): FeishuMessageEvent {

15+

return {

16+

sender: {

17+

sender_id: { open_id: params.senderOpenId },

18+

sender_type: params.senderType,

19+

},

20+

message: {

21+

message_id: params.messageId,

22+

chat_id: "oc_chat_1",

23+

chat_type: "p2p",

24+

message_type: "text",

25+

content: JSON.stringify({ text: "hello" }),

26+

},

27+

};

28+

}

29+30+

function createHandler() {

31+

let onFlush: ((entries: FeishuMessageEvent[]) => Promise<void>) | undefined;

32+

const enqueue = vi.fn(async (event: FeishuMessageEvent) => {

33+

await onFlush?.([event]);

34+

});

35+

const channelRuntime = {

36+

commands: {

37+

isControlCommandMessage: () => false,

38+

},

39+

debounce: {

40+

resolveInboundDebounceMs: () => 0,

41+

createInboundDebouncer: vi.fn((params: { onFlush: typeof onFlush }) => {

42+

onFlush = params.onFlush;

43+

return { enqueue };

44+

}),

45+

},

46+

} as unknown as PluginRuntime["channel"];

47+

const handleMessage = vi.fn(async (_params: HandleMessageParams) => {});

48+49+

const handler = createFeishuMessageReceiveHandler({

50+

cfg: {} as ClawdbotConfig,

51+

channelRuntime,

52+

accountId: "default",

53+

chatHistories: new Map(),

54+

handleMessage,

55+

resolveDebounceText: () => "hello",

56+

hasProcessedMessage: vi.fn(async () => false),

57+

recordProcessedMessage: vi.fn(async () => true),

58+

getBotOpenId: () => "ou_bot",

59+

});

60+61+

return { handler, handleMessage, enqueue };

62+

}

63+64+

describe("createFeishuMessageReceiveHandler self-message filtering", () => {

65+

it("drops the current bot before debounce and processing claims", async () => {

66+

const { handler, handleMessage, enqueue } = createHandler();

67+68+

await handler(

69+

createTextEvent({

70+

messageId: "om_reused",

71+

senderOpenId: "ou_bot",

72+

senderType: "bot",

73+

}),

74+

);

75+

await handler(

76+

createTextEvent({

77+

messageId: "om_reused",

78+

senderOpenId: "ou_user",

79+

senderType: "user",

80+

}),

81+

);

82+83+

expect(enqueue).toHaveBeenCalledTimes(1);

84+

expect(handleMessage).toHaveBeenCalledTimes(1);

85+

expect(handleMessage.mock.calls[0]?.[0]?.event.sender.sender_id.open_id).toBe("ou_user");

86+

});

87+88+

it("keeps peer bot and user messages flowing to dispatch", async () => {

89+

const { handler, handleMessage, enqueue } = createHandler();

90+91+

await handler(

92+

createTextEvent({

93+

messageId: "om_other_bot",

94+

senderOpenId: "ou_other_bot",

95+

senderType: "bot",

96+

}),

97+

);

98+

await handler(

99+

createTextEvent({

100+

messageId: "om_user",

101+

senderOpenId: "ou_user",

102+

senderType: "user",

103+

}),

104+

);

105+106+

expect(enqueue).toHaveBeenCalledTimes(2);

107+

expect(handleMessage).toHaveBeenCalledTimes(2);

108+

expect(

109+

handleMessage.mock.calls.map(([params]) => params.event.sender.sender_id.open_id),

110+

).toEqual(["ou_other_bot", "ou_user"]);

111+

});

112+

});