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

推荐订阅源

腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
L
LangChain Blog
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
量子位
A
About on SuperTechFans
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
V
Visual Studio Blog
Vercel News
Vercel News
B
Blog
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
U
Unit 42

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(discord): hydrate reply context metadata · openclaw/o...
fuller-stack · 2026-06-10 · via Recent Commits to openclaw:main
11

// Discord tests cover message handler.hydration plugin behavior.

2+

import { MessageReferenceType, MessageType } from "discord-api-types/v10";

23

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

34

import { Message } from "../internal/discord.js";

45

import {

@@ -78,4 +79,150 @@ describe("hydrateDiscordMessageIfNeeded", () => {

7879

expect(hydrated.mentionedRoles).toEqual(["role1"]);

7980

expect(hydrated.referencedMessage?.content).toBe("earlier");

8081

});

82+83+

it("hydrates reply references when Discord omits referenced_message", async () => {

84+

const client = createInternalTestClient();

85+

const rest = createFakeRestClient([

86+

{

87+

id: "m1",

88+

channel_id: "c1",

89+

content: "what did this mean?",

90+

attachments: [],

91+

embeds: [],

92+

mentions: [],

93+

mention_roles: [],

94+

mention_everyone: false,

95+

timestamp: new Date().toISOString(),

96+

author: {

97+

id: "u1",

98+

username: "alice",

99+

discriminator: "0",

100+

avatar: null,

101+

},

102+

message_reference: {

103+

type: MessageReferenceType.Default,

104+

message_id: "m0",

105+

channel_id: "c1",

106+

},

107+

referenced_message: {

108+

id: "m0",

109+

channel_id: "c1",

110+

content: "the replied-to message",

111+

attachments: [],

112+

embeds: [],

113+

mentions: [],

114+

mention_roles: [],

115+

mention_everyone: false,

116+

timestamp: new Date().toISOString(),

117+

author: {

118+

id: "u2",

119+

username: "bob",

120+

discriminator: "0",

121+

avatar: null,

122+

},

123+

type: MessageType.Default,

124+

tts: false,

125+

pinned: false,

126+

flags: 0,

127+

},

128+

type: MessageType.Reply,

129+

tts: false,

130+

pinned: false,

131+

flags: 0,

132+

},

133+

]);

134+

const message = new Message(client, {

135+

id: "m1",

136+

channel_id: "c1",

137+

content: "what did this mean?",

138+

attachments: [],

139+

embeds: [],

140+

mentions: [],

141+

mention_roles: [],

142+

mention_everyone: false,

143+

timestamp: new Date().toISOString(),

144+

author: {

145+

id: "u1",

146+

username: "alice",

147+

global_name: null,

148+

discriminator: "0",

149+

avatar: null,

150+

},

151+

message_reference: {

152+

type: MessageReferenceType.Default,

153+

message_id: "m0",

154+

channel_id: "c1",

155+

},

156+

type: MessageType.Reply,

157+

tts: false,

158+

pinned: false,

159+

});

160+161+

const hydrated = await hydrateDiscordMessageIfNeeded({

162+

client: { rest },

163+

message,

164+

messageChannelId: "c1",

165+

});

166+167+

expect(rest.calls).toHaveLength(1);

168+

expect(hydrated.referencedMessage?.content).toBe("the replied-to message");

169+

});

170+171+

it("does not hydrate known-deleted or forwarded references", async () => {

172+

const client = createInternalTestClient();

173+

const rest = createFakeRestClient();

174+

const baseMessage = {

175+

id: "m1",

176+

channel_id: "c1",

177+

content: "what did this mean?",

178+

attachments: [],

179+

embeds: [],

180+

mentions: [],

181+

mention_roles: [],

182+

mention_everyone: false,

183+

timestamp: new Date().toISOString(),

184+

author: {

185+

id: "u1",

186+

username: "alice",

187+

global_name: null,

188+

discriminator: "0",

189+

avatar: null,

190+

},

191+

tts: false,

192+

pinned: false,

193+

};

194+195+

const deletedReply = new Message(client, {

196+

...baseMessage,

197+

message_reference: {

198+

type: MessageReferenceType.Default,

199+

message_id: "m0",

200+

channel_id: "c1",

201+

},

202+

referenced_message: null,

203+

type: MessageType.Reply,

204+

});

205+

const forwardedMessage = new Message(client, {

206+

...baseMessage,

207+

message_reference: {

208+

type: MessageReferenceType.Forward,

209+

message_id: "m0",

210+

channel_id: "c1",

211+

},

212+

type: MessageType.Default,

213+

});

214+215+

await hydrateDiscordMessageIfNeeded({

216+

client: { rest },

217+

message: deletedReply,

218+

messageChannelId: "c1",

219+

});

220+

await hydrateDiscordMessageIfNeeded({

221+

client: { rest },

222+

message: forwardedMessage,

223+

messageChannelId: "c1",

224+

});

225+226+

expect(rest.calls).toHaveLength(0);

227+

});

81228

});