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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
B
Blog
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
I
InfoQ
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
H
Help Net Security

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): ignore stale exec approval clicks · opencla...
steipete · 2026-04-26 · via Recent Commits to openclaw:main

@@ -87,7 +87,7 @@ describe("discord exec approval monitor helpers", () => {

8787

const interaction = createInteraction();

8888

const button = new ExecApprovalButton({

8989

getApprovers: () => ["123"],

90-

resolveApproval: async () => true,

90+

resolveApproval: async () => ({ ok: true }),

9191

});

92929393

await button.run(interaction, { id: "", action: "" });

@@ -102,7 +102,7 @@ describe("discord exec approval monitor helpers", () => {

102102

const interaction = createInteraction({ userId: "999" });

103103

const button = new ExecApprovalButton({

104104

getApprovers: () => ["123"],

105-

resolveApproval: async () => true,

105+

resolveApproval: async () => ({ ok: true }),

106106

});

107107108108

await button.run(interaction, { id: "abc", action: "allow-once" });

@@ -115,7 +115,7 @@ describe("discord exec approval monitor helpers", () => {

115115116116

it("acknowledges and resolves valid approval clicks", async () => {

117117

const interaction = createInteraction();

118-

const resolveApproval = vi.fn(async () => true);

118+

const resolveApproval = vi.fn(async () => ({ ok: true }) as const);

119119

const button = new ExecApprovalButton({

120120

getApprovers: () => ["123"],

121121

resolveApproval,

@@ -132,7 +132,7 @@ describe("discord exec approval monitor helpers", () => {

132132

const interaction = createInteraction();

133133

const button = new ExecApprovalButton({

134134

getApprovers: () => ["123"],

135-

resolveApproval: async () => false,

135+

resolveApproval: async () => ({ ok: false, reason: "error" }),

136136

});

137137138138

await button.run(interaction, { id: "abc", action: "deny" });

@@ -144,6 +144,19 @@ describe("discord exec approval monitor helpers", () => {

144144

});

145145

});

146146147+

it("keeps already-resolved approval clicks quiet", async () => {

148+

const interaction = createInteraction();

149+

const button = new ExecApprovalButton({

150+

getApprovers: () => ["123"],

151+

resolveApproval: async () => ({ ok: false, reason: "not-found" }),

152+

});

153+154+

await button.run(interaction, { id: "abc", action: "allow-once" });

155+156+

expect(interaction.acknowledge).toHaveBeenCalled();

157+

expect(interaction.followUp).not.toHaveBeenCalled();

158+

});

159+147160

it("builds button context from config and routes resolution over gateway", async () => {

148161

const cfg = buildConfig({ enabled: true, approvers: ["123"] });

149162

resolveApprovalOverGatewayMock.mockResolvedValue(undefined);

@@ -155,7 +168,7 @@ describe("discord exec approval monitor helpers", () => {

155168

});

156169157170

expect(ctx.getApprovers()).toEqual(["123"]);

158-

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toBe(true);

171+

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toEqual({ ok: true });

159172

expect(resolveApprovalOverGatewayMock).toHaveBeenCalledWith({

160173

cfg,

161174

approvalId: "abc",

@@ -173,6 +186,41 @@ describe("discord exec approval monitor helpers", () => {

173186

config: { enabled: true, approvers: ["123"] },

174187

});

175188176-

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toBe(false);

189+

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toEqual({

190+

ok: false,

191+

reason: "error",

192+

});

193+

});

194+195+

it("classifies structured approval-not-found gateway errors as stale clicks", async () => {

196+

const err = Object.assign(new Error("unknown or expired approval id"), {

197+

gatewayCode: "INVALID_REQUEST",

198+

details: { reason: "APPROVAL_NOT_FOUND" },

199+

});

200+

resolveApprovalOverGatewayMock.mockRejectedValue(err);

201+

const ctx = createDiscordExecApprovalButtonContext({

202+

cfg: buildConfig({ enabled: true, approvers: ["123"] }),

203+

accountId: "default",

204+

config: { enabled: true, approvers: ["123"] },

205+

});

206+207+

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toEqual({

208+

ok: false,

209+

reason: "not-found",

210+

});

211+

});

212+213+

it("keeps message-only approval-not-found errors visible", async () => {

214+

resolveApprovalOverGatewayMock.mockRejectedValue(new Error("unknown or expired approval id"));

215+

const ctx = createDiscordExecApprovalButtonContext({

216+

cfg: buildConfig({ enabled: true, approvers: ["123"] }),

217+

accountId: "default",

218+

config: { enabled: true, approvers: ["123"] },

219+

});

220+221+

await expect(ctx.resolveApproval("abc", "allow-once")).resolves.toEqual({

222+

ok: false,

223+

reason: "error",

224+

});

177225

});

178226

});