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

推荐订阅源

小众软件
小众软件
博客园_首页
博客园 - 聂微东
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
D
Docker
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Jina AI
Jina AI
博客园 - Franky
D
DataBreaches.Net

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): include component text in reply context · o...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -1,4 +1,9 @@

1-

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

1+

import {

2+

ComponentType,

3+

MessageFlags,

4+

MessageReferenceType,

5+

StickerFormatType,

6+

} from "discord-api-types/v10";

27

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

38

import { ChannelType, type Client, type Message } from "../internal/discord.js";

49

@@ -137,6 +142,7 @@ function asForwardedSnapshotMessage(params: {

137142138143

function asReferencedForwardMessage(params: {

139144

content?: string;

145+

components?: Array<Record<string, unknown>>;

140146

embeds?: Array<{ title?: string; description?: string }>;

141147

attachments?: Array<Record<string, unknown>>;

142148

messageReferenceType?: MessageReferenceType;

@@ -152,8 +158,10 @@ function asReferencedForwardMessage(params: {

152158

id: "m0",

153159

channelId: "c1",

154160

content: params.content ?? "",

161+

components: params.components ?? [],

155162

attachments: params.attachments ?? [],

156163

embeds: params.embeds ?? [],

164+

flags: params.components ? MessageFlags.IsComponentsV2 : 0,

157165

stickers: [],

158166

author: {

159167

id: "u2",

@@ -980,6 +988,46 @@ describe("resolveDiscordMessageText", () => {

980988

expect(text).toBe("Breaking");

981989

});

982990991+

it("uses Components v2 text display content when normal message text is empty", () => {

992+

const text = resolveDiscordMessageText(

993+

asMessage({

994+

content: "",

995+

flags: MessageFlags.IsComponentsV2,

996+

components: [

997+

{

998+

type: ComponentType.Container,

999+

components: [

1000+

{ type: ComponentType.TextDisplay, content: "Component headline" },

1001+

{

1002+

type: ComponentType.Section,

1003+

components: [{ type: ComponentType.TextDisplay, content: "Component body" }],

1004+

accessory: { type: ComponentType.Thumbnail, media: { url: "attachment://x.png" } },

1005+

},

1006+

],

1007+

},

1008+

],

1009+

}),

1010+

);

1011+1012+

expect(text).toBe("Component headline\nComponent body");

1013+

});

1014+1015+

it("uses Components v2 text display content from referenced reply messages", () => {

1016+

const text = resolveDiscordMessageText(

1017+

asReferencedForwardMessage({

1018+

components: [

1019+

{

1020+

type: ComponentType.Container,

1021+

components: [{ type: ComponentType.TextDisplay, content: "Referenced component text" }],

1022+

},

1023+

],

1024+

messageReferenceType: MessageReferenceType.Default,

1025+

}).referencedMessage!,

1026+

);

1027+1028+

expect(text).toBe("Referenced component text");

1029+

});

1030+9831031

it("uses embed description when content is empty", () => {

9841032

const text = resolveDiscordMessageText(

9851033

asMessage({

@@ -1025,6 +1073,42 @@ describe("resolveDiscordMessageText", () => {

10251073

expect(text).toContain("[Forwarded message from @Bob]");

10261074

expect(text).toContain("Forwarded title\nForwarded details");

10271075

});

1076+1077+

it("includes Components v2 text display content from forwarded snapshots", () => {

1078+

const text = resolveDiscordMessageText(

1079+

asMessage({

1080+

content: "",

1081+

rawData: {

1082+

message_snapshots: [

1083+

{

1084+

message: {

1085+

content: "",

1086+

embeds: [],

1087+

attachments: [],

1088+

components: [

1089+

{

1090+

type: ComponentType.Container,

1091+

components: [

1092+

{ type: ComponentType.TextDisplay, content: "Forwarded component text" },

1093+

],

1094+

},

1095+

],

1096+

author: {

1097+

id: "u2",

1098+

username: "Bob",

1099+

discriminator: "0",

1100+

},

1101+

},

1102+

},

1103+

],

1104+

},

1105+

}),

1106+

{ includeForwarded: true },

1107+

);

1108+1109+

expect(text).toContain("[Forwarded message from @Bob]");

1110+

expect(text).toContain("Forwarded component text");

1111+

});

10281112

});

1029111310301114

describe("resolveDiscordChannelInfo", () => {