Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,7 @@ export function PermissionPrompt(props: { request: PermissionRequest }) {
return
}
if (option === "reject") {
if (session()?.parentID) {
setStore("stage", "reject")
return
}
sdk.client.permission.reply({
reply: "reject",
requestID: props.request.id,
})
setStore("stage", "reject")
return
}
sdk.client.permission.reply({
Expand Down
26 changes: 26 additions & 0 deletions packages/opencode/test/permission/next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,32 @@ test("reply - reject throws RejectedError", async () => {
})
})

test("reply - reject with message throws CorrectedError", async () => {
await using tmp = await tmpdir({ git: true })
await Instance.provide({
directory: tmp.path,
fn: async () => {
const askPromise = PermissionNext.ask({
id: "permission_test_corrected",
sessionID: "session_test",
permission: "bash",
patterns: ["ls"],
metadata: {},
always: [],
ruleset: [],
})

await PermissionNext.reply({
requestID: "permission_test_corrected",
reply: "reject",
message: "Use a different approach instead",
})

await expect(askPromise).rejects.toBeInstanceOf(PermissionNext.CorrectedError)
},
})
})

test("reply - always persists approval and resolves", async () => {
await using tmp = await tmpdir({ git: true })
await Instance.provide({
Expand Down
Loading