Skip to content

Commit ad545d0

Browse files
committed
tui: allow auto-accepting only edit permissions instead of all permissions
1 parent ac244b1 commit ad545d0

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

packages/opencode/src/agent/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export namespace Agent {
6363
question: "deny",
6464
plan_enter: "deny",
6565
plan_exit: "deny",
66+
edit: "ask",
6667
// mirrors github.com/github/gitignore Node.gitignore pattern for .env files
6768
read: {
6869
"*": "allow",

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function Prompt(props: PromptProps) {
7474
const renderer = useRenderer()
7575
const { theme, syntax } = useTheme()
7676
const kv = useKV()
77-
const [autoaccept, setAutoaccept] = kv.signal("permission_auto_accept", false)
77+
const [autoaccept, setAutoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
7878

7979
function promptModelWarning() {
8080
toast.show({
@@ -159,13 +159,13 @@ export function Prompt(props: PromptProps) {
159159
command.register(() => {
160160
return [
161161
{
162-
title: autoaccept() ? "Disable permissions" : "Enable permissions",
162+
title: autoaccept() === "none" ? "Enable autoedit" : "Disable autoedit",
163163
value: "permission.auto_accept.toggle",
164164
search: "toggle permissions",
165165
keybind: "permission_auto_accept_toggle",
166166
category: "Agent",
167167
onSelect: (dialog) => {
168-
setAutoaccept(!autoaccept() as any)
168+
setAutoaccept(() => (autoaccept() === "none" ? "edit" : "none"))
169169
dialog.clear()
170170
},
171171
},
@@ -1005,9 +1005,9 @@ export function Prompt(props: PromptProps) {
10051005
</box>
10061006
</Show>
10071007
</box>
1008-
<Show when={autoaccept()}>
1008+
<Show when={autoaccept() === "edit"}>
10091009
<text>
1010-
<span style={{ fg: theme.warning, bold: true }}>auto-accept</span>
1010+
<span style={{ fg: theme.warning, bold: true }}>auto-edit</span>
10111011
</text>
10121012
</Show>
10131013
</box>

packages/opencode/src/cli/cmd/tui/context/sync.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
105105

106106
const sdk = useSDK()
107107
const kv = useKV()
108-
const [autoaccept] = kv.signal("permission_auto_accept", false)
108+
const [autoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
109109

110110
sdk.event.listen((e) => {
111111
const event = e.details
@@ -130,7 +130,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
130130

131131
case "permission.asked": {
132132
const request = event.properties
133-
if (autoaccept()) {
133+
if (autoaccept() === "edit" && request.permission === "edit") {
134134
sdk.client.permission.reply({
135135
reply: "once",
136136
requestID: request.id,

0 commit comments

Comments
 (0)