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

推荐订阅源

MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
V
Visual Studio Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
L
LangChain Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
P
Proofpoint News Feed
博客园_首页
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog

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 stale approval prompts in Control UI (#86270) · openc...
jesse-merhi · 2026-05-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,113 @@

1+

/* @vitest-environment jsdom */

2+3+

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

4+

import { createStorageMock } from "../test-helpers/storage.ts";

5+

import type { ExecApprovalRequest } from "./controllers/exec-approval.ts";

6+7+

type RequestFn = (method: string, params?: unknown) => Promise<unknown>;

8+9+

function createExecApproval(overrides: Partial<ExecApprovalRequest> = {}): ExecApprovalRequest {

10+

return {

11+

id: "approval-1",

12+

kind: "exec",

13+

request: { command: "echo hello" },

14+

createdAtMs: 1000,

15+

expiresAtMs: Date.now() + 60_000,

16+

...overrides,

17+

};

18+

}

19+20+

function createGatewayError(message: string, details?: unknown): Error {

21+

const err = new Error(message);

22+

Object.defineProperty(err, "gatewayCode", {

23+

value: "INVALID_REQUEST",

24+

enumerable: true,

25+

});

26+

Object.defineProperty(err, "details", {

27+

value: details,

28+

enumerable: true,

29+

});

30+

return err;

31+

}

32+33+

async function createApp(

34+

request: RequestFn,

35+

queue: ExecApprovalRequest[] = [createExecApproval()],

36+

) {

37+

const { OpenClawApp } = await import("./app.ts");

38+

const app = new OpenClawApp();

39+

Object.defineProperty(app, "client", {

40+

value: { request },

41+

writable: true,

42+

});

43+

app.execApprovalQueue = queue;

44+

app.execApprovalBusy = false;

45+

app.execApprovalError = null;

46+

return app;

47+

}

48+49+

describe("OpenClawApp exec approval decisions", () => {

50+

beforeEach(() => {

51+

vi.stubGlobal("localStorage", createStorageMock());

52+

});

53+54+

afterEach(() => {

55+

vi.unstubAllGlobals();

56+

vi.restoreAllMocks();

57+

});

58+59+

it("dismisses the active approval after same-decision idempotent success", async () => {

60+

const request = vi.fn<RequestFn>(async () => ({ ok: true }));

61+

const app = await createApp(request);

62+63+

await app.handleExecApprovalDecision("allow-once");

64+65+

expect(request).toHaveBeenCalledWith("exec.approval.resolve", {

66+

id: "approval-1",

67+

decision: "allow-once",

68+

});

69+

expect(app.execApprovalQueue).toEqual([]);

70+

expect(app.execApprovalError).toBeNull();

71+

expect(app.execApprovalBusy).toBe(false);

72+

});

73+74+

it("dismisses and refreshes when the backend reports an already resolved approval", async () => {

75+

const request = vi.fn<RequestFn>(async (method) => {

76+

if (method === "exec.approval.resolve") {

77+

throw createGatewayError("approval already resolved", {

78+

reason: "APPROVAL_ALREADY_RESOLVED",

79+

});

80+

}

81+

if (method === "exec.approval.list") {

82+

return [];

83+

}

84+

if (method === "plugin.approval.list") {

85+

return [];

86+

}

87+

return {};

88+

});

89+

const app = await createApp(request);

90+91+

await app.handleExecApprovalDecision("deny");

92+93+

expect(app.execApprovalQueue).toEqual([]);

94+

expect(app.execApprovalError).toBeNull();

95+

expect(app.execApprovalBusy).toBe(false);

96+

expect(request).toHaveBeenCalledWith("exec.approval.list", {});

97+

expect(request).toHaveBeenCalledWith("plugin.approval.list", {});

98+

});

99+100+

it("keeps the active approval open for unrelated errors", async () => {

101+

const request = vi.fn<RequestFn>(async () => {

102+

throw createGatewayError("gateway unavailable");

103+

});

104+

const active = createExecApproval();

105+

const app = await createApp(request, [active]);

106+107+

await app.handleExecApprovalDecision("deny");

108+109+

expect(app.execApprovalQueue).toEqual([active]);

110+

expect(app.execApprovalError).toBe("Approval failed: Error: gateway unavailable");

111+

expect(app.execApprovalBusy).toBe(false);

112+

});

113+

});