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

推荐订阅源

腾讯CDC
The Cloudflare Blog
IT之家
IT之家
V
V2EX
雷峰网
雷峰网
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
A
About on SuperTechFans
B
Blog
月光博客
月光博客
宝玉的分享
宝玉的分享
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(discord): allow component registry ttl override · ope...
100menotu001 · 2026-05-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -400,6 +400,35 @@ describe("discord config schema", () => {

400400

expect(res.success).toBe(true);

401401

});

402402
403+

it("accepts agentComponents.ttlMs at channel and account scope", () => {

404+

const res = DiscordConfigSchema.safeParse({

405+

agentComponents: {

406+

ttlMs: 86_400_000,

407+

},

408+

accounts: {

409+

work: {

410+

agentComponents: {

411+

ttlMs: 120_000,

412+

},

413+

},

414+

},

415+

});

416+
417+

expect(res.success).toBe(true);

418+

});

419+
420+

it("rejects invalid agentComponents.ttlMs values", () => {

421+

for (const ttlMs of [0, -1, 1.5, 604_800_001]) {

422+

const res = DiscordConfigSchema.safeParse({

423+

agentComponents: {

424+

ttlMs,

425+

},

426+

});

427+
428+

expect(res.success).toBe(false);

429+

}

430+

});

431+
403432

it("accepts agentComponents.enabled at account scope", () => {

404433

const res = DiscordConfigSchema.safeParse({

405434

accounts: {

Original file line numberDiff line numberDiff line change

@@ -157,6 +157,10 @@ export const discordChannelConfigUiHints = {

157157

label: "Discord Component Accent Color",

158158

help: "Accent color for Discord component containers (hex). Set per account via channels.discord.accounts.<id>.ui.components.accentColor.",

159159

},

160+

"agentComponents.ttlMs": {

161+

label: "Discord Component TTL (ms)",

162+

help: "How long sent Discord component callbacks remain registered. Default is 1800000 (30 minutes); maximum is 604800000 (7 days).",

163+

},

160164

"intents.presence": {

161165

label: "Discord Presence Intent",

162166

help: "Enable the Guild Presences privileged intent. Must also be enabled in the Discord Developer Portal. Allows tracking user activities (e.g. Spotify). Default: false.",

Original file line numberDiff line numberDiff line change

@@ -173,6 +173,7 @@ describe("sendDiscordComponentMessage", () => {

173173

it("registers a prebuilt component message against an edited message id", () => {

174174

registerBuiltDiscordComponentMessage({

175175

messageId: "msg1",

176+

ttlMs: 120_000,

176177

buildResult: {

177178

components: [],

178179

entries: [{ id: "entry-1", kind: "button", label: "Tap" }],

@@ -184,8 +185,45 @@ describe("sendDiscordComponentMessage", () => {

184185

entries: [{ id: "entry-1", kind: "button", label: "Tap" }],

185186

modals: [{ id: "modal-1", title: "Modal", fields: [] }],

186187

messageId: "msg1",

188+

ttlMs: 120_000,

187189

});

188190

});

191+
192+

it("passes configured component TTL when registering sent entries", async () => {

193+

const { rest, postMock, getMock } = makeDiscordRest();

194+

getMock.mockResolvedValueOnce({

195+

type: ChannelType.DM,

196+

recipients: [{ id: "user-1" }],

197+

});

198+

postMock.mockResolvedValueOnce({ id: "msg1", channel_id: "dm-1" });

199+
200+

await sendDiscordComponentMessage(

201+

"channel:dm-1",

202+

{

203+

blocks: [{ type: "actions", buttons: [{ label: "Tap" }] }],

204+

},

205+

{

206+

cfg: {

207+

channels: {

208+

discord: {

209+

agentComponents: {

210+

ttlMs: 120_000,

211+

},

212+

accounts: {

213+

default: {},

214+

},

215+

},

216+

},

217+

session: { dmScope: "main" },

218+

},

219+

rest,

220+

token: "t",

221+

},

222+

);

223+
224+

expect(registerMock).toHaveBeenCalledTimes(1);

225+

expect(readRecordArg(registerMock, 0, 0).ttlMs).toBe(120_000);

226+

});

189227

});

190228
191229

describe("sendDiscordComponentMessage classic message downgrade", () => {

Original file line numberDiff line numberDiff line change

@@ -170,14 +170,25 @@ type DiscordComponentSendOpts = {

170170

export function registerBuiltDiscordComponentMessage(params: {

171171

buildResult: DiscordComponentBuildResult;

172172

messageId: string;

173+

ttlMs?: number;

173174

}): void {

174175

registerDiscordComponentEntries({

175176

entries: params.buildResult.entries,

176177

modals: params.buildResult.modals,

177178

messageId: params.messageId,

179+

ttlMs: params.ttlMs,

178180

});

179181

}

180182
183+

function resolveDiscordComponentRegistryTtlMs(

184+

accountConfig: { agentComponents?: { ttlMs?: number } } | undefined,

185+

): number | undefined {

186+

const ttlMs = accountConfig?.agentComponents?.ttlMs;

187+

return typeof ttlMs === "number" && Number.isFinite(ttlMs) && ttlMs > 0

188+

? Math.floor(ttlMs)

189+

: undefined;

190+

}

191+
181192

async function buildDiscordComponentPayload(params: {

182193

spec: DiscordComponentMessageSpec;

183194

opts: DiscordComponentSendOpts;

@@ -316,6 +327,7 @@ export async function sendDiscordComponentMessage(

316327

registerBuiltDiscordComponentMessage({

317328

buildResult,

318329

messageId: result.id,

330+

ttlMs: resolveDiscordComponentRegistryTtlMs(accountInfo.config),

319331

});

320332
321333

recordChannelActivity({

@@ -371,6 +383,7 @@ export async function editDiscordComponentMessage(

371383

registerBuiltDiscordComponentMessage({

372384

buildResult,

373385

messageId: result.id ?? messageId,

386+

ttlMs: resolveDiscordComponentRegistryTtlMs(accountInfo.config),

374387

});

375388
376389

recordChannelActivity({

Original file line numberDiff line numberDiff line change

@@ -229,6 +229,8 @@ export type DiscordExecApprovalConfig = {

229229

export type DiscordAgentComponentsConfig = {

230230

/** Enable agent-controlled interactive components (buttons, select menus). Default: true. */

231231

enabled?: boolean;

232+

/** Time in milliseconds before sent Discord component callbacks expire. Default: 1800000. */

233+

ttlMs?: number;

232234

};

233235
234236

export type DiscordUiComponentsConfig = {

Original file line numberDiff line numberDiff line change

@@ -702,6 +702,12 @@ export const DiscordAccountSchema = z

702702

agentComponents: z

703703

.object({

704704

enabled: z.boolean().optional(),

705+

ttlMs: z

706+

.number()

707+

.int()

708+

.positive()

709+

.max(7 * 24 * 60 * 60 * 1000)

710+

.optional(),

705711

})

706712

.strict()

707713

.optional(),