Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(server): honor auto-accept edits for the OpenCode provider (#7100)

Rishet1104df98db4c90
diff --git a/apps/server/src/provider/opencodeRuntime.permissions.test.ts b/apps/server/src/provider/opencodeRuntime.permissions.test.ts
new file mode 100644
index 000000000..ad95e38d1
--- /dev/null
+++ b/apps/server/src/provider/opencodeRuntime.permissions.test.ts
@@ -0,0 +1,44 @@
+import * as NodeAssert from "node:assert/strict";
+
+import { describe, it } from "vite-plus/test";
+
+import { buildOpenCodePermissionRules } from "./opencodeRuntime.ts";
+
+function actionFor(
+ runtimeMode: Parameters<typeof buildOpenCodePermissionRules>[0],
+ permission: string,
+) {
+ return buildOpenCodePermissionRules(runtimeMode).find((rule) => rule.permission === permission)
+ ?.action;
+}
+
+describe("buildOpenCodePermissionRules", () => {
+ it("pre-approves edits once the user has chosen to auto-accept them", () => {
+ NodeAssert.equal(actionFor("auto-accept-edits", "edit"), "allow");
+ });
+
+ it("still asks before editing when approval is required", () => {
+ NodeAssert.equal(actionFor("approval-required", "edit"), "ask");
+ });
+
+ // Documented in docs/user/permission-modes.md: providers without an AI
+ // reviewer, OpenCode among them, fall back to Supervised for "auto".
+ it("leaves auto asking, as the docs say it does without a reviewer", () => {
+ NodeAssert.equal(actionFor("auto", "edit"), "ask");
+ });
+
+ it("keeps asking for everything else in the auto modes", () => {
+ for (const runtimeMode of ["auto-accept-edits", "auto"] as const) {
+ NodeAssert.equal(actionFor(runtimeMode, "bash"), "ask");
+ NodeAssert.equal(actionFor(runtimeMode, "webfetch"), "ask");
+ NodeAssert.equal(actionFor(runtimeMode, "external_directory"), "ask");
+ NodeAssert.equal(actionFor(runtimeMode, "*"), "ask");
+ }
+ });
+
+ it("allows everything only under full access", () => {
+ NodeAssert.deepEqual(buildOpenCodePermissionRules("full-access"), [
+ { permission: "*", pattern: "*", action: "allow" },
+ ]);
+ });
+});
diff --git a/apps/server/src/provider/opencodeRuntime.ts b/apps/server/src/provider/opencodeRuntime.ts
index 6d2436ca2..80329a679 100644
--- a/apps/server/src/provider/opencodeRuntime.ts
+++ b/apps/server/src/provider/opencodeRuntime.ts
@@ -373,10 +373,16 @@ export function buildOpenCodePermissionRules(runtimeMode: RuntimeMode): Permissi
return [{ permission: "*", pattern: "*", action: "allow" }];
}
+ // "Auto-accept edits" is documented as "auto-approve edits, ask before other
+ // actions", so prompting for every edit ignores the mode the user picked.
+ // "auto" is left asking on purpose: the docs say providers without an AI
+ // reviewer, OpenCode among them, fall back to Supervised for that mode.
+ const editAction = runtimeMode === "auto-accept-edits" ? "allow" : "ask";
+
return [
{ permission: "*", pattern: "*", action: "ask" },
{ permission: "bash", pattern: "*", action: "ask" },
- { permission: "edit", pattern: "*", action: "ask" },
+ { permission: "edit", pattern: "*", action: editAction },
{ permission: "webfetch", pattern: "*", action: "ask" },
{ permission: "websearch", pattern: "*", action: "ask" },
{ permission: "codesearch", pattern: "*", action: "ask" },