Skip to content

Commit 1c73fa1

Browse files
committed
test(macos): document legacy approval fallback
1 parent 59b80df commit 1c73fa1

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

apps/macos/Sources/OpenClaw/ExecApprovalsSocket.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ struct ExecApprovalPromptRequest: Codable {
6767
}
6868

6969
static func allowedDecisions(forAsk ask: String?) -> [ExecApprovalDecision] {
70+
// Older payloads did not carry ask/allowedDecisions. Preserve their durable
71+
// approval option; explicit ask=always and allowedDecisions payloads are the
72+
// policy-carrying shapes that remove it.
7073
ask == ExecAsk.always.rawValue
7174
? [.allowOnce, .deny]
7275
: [.allowOnce, .allowAlways, .deny]

apps/macos/Tests/OpenClawIPCTests/ExecApprovalPromptLayoutTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ struct ExecApprovalPromptLayoutTests {
5151
#expect(decisions == [.allowOnce, .allowAlways, .deny])
5252
}
5353

54+
@Test func `legacy prompts keep durable approval when policy fields are omitted`() {
55+
let decisions = ExecApprovalsPromptPresenter.allowedPromptDecisions(
56+
ExecApprovalPromptRequest(
57+
command: "/bin/sh -lc pwd",
58+
cwd: "/Users/example/projects/openclaw",
59+
host: "node",
60+
security: "full",
61+
agentId: "main",
62+
resolvedPath: "/bin/sh",
63+
sessionKey: "session-1"))
64+
65+
#expect(decisions == [.allowOnce, .allowAlways, .deny])
66+
}
67+
68+
@Test func `unknown ask prompts keep legacy durable approval when decisions are omitted`() {
69+
let decisions = ExecApprovalsPromptPresenter.allowedPromptDecisions(
70+
ExecApprovalPromptRequest(
71+
command: "/bin/sh -lc pwd",
72+
cwd: "/Users/example/projects/openclaw",
73+
host: "node",
74+
security: "full",
75+
ask: "unexpected",
76+
agentId: "main",
77+
resolvedPath: "/bin/sh",
78+
sessionKey: "session-1"))
79+
80+
#expect(decisions == [.allowOnce, .allowAlways, .deny])
81+
}
82+
5483
@Test func `approval request decodes valid allowed decisions only`() throws {
5584
let data = """
5685
{

0 commit comments

Comments
 (0)