fix(server): full-access OpenCode threads no longer ask for approvals #9282
Mergedshivamhwp(GitHub profile, opens in a new tab)merged 9 commits into
main fromrefs/pull/9282/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1634OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1615,3 +1616,19 @@16151616 if (context.pendingPermissions.has(request.id)) {16161617 return;16171618 }1619+ if (context.session.runtimeMode === "full-access") {1620+ // OpenCode still asks in full access when it detects a doom loop1621+ // (evaluated against the agent ruleset only) and inside subagent1622+ // sessions (which drop the parent's wildcard allow). Answer those1623+ // here so the user never sees an approval they already granted.1624+ const replied = yield* runOpenCodeSdk("permission.reply", () =>1625+ context.client.permission.reply({ requestID: request.id, reply: "always" }),1626+ ).pipe(1627+ Effect.as(true),1628+ Effect.orElseSucceed(() => false),1629+ );1630+ if (replied) {1631+ context.resolvedRequestIds.add(request.id);1632+ context.autoRepliedRequestIds.add(request.id);1633+ return;1634+ }
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1645OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1617,0 +1625,21 @@1625+ // Record the ids before awaiting the reply: retry and recovery1626+ // fibers can re-enter this function, and the matching1627+ // `permission.replied` can land, while the SDK call is in flight.1628+ // Marking first makes those paths skip the ask instead of racing1629+ // to emit a duplicate `request.opened` or a stray1630+ // `request.resolved`.1631+ context.resolvedRequestIds.add(request.id);1632+ context.autoRepliedRequestIds.add(request.id);1633+ const replied = yield* runOpenCodeSdk("permission.reply", () =>1634+ context.client.permission.reply({ requestID: request.id, reply: "always" }),1635+ ).pipe(1636+ Effect.as(true),1637+ Effect.orElseSucceed(() => false),1638+ );1639+ if (replied) {1640+ return;1641+ }1642+ // The reply failed, so fall back to surfacing the approval. Undo1643+ // the bookkeeping so the terminal event and any retry treat it as1644+ // a normal pending request.1645+ context.resolvedRequestIds.delete(request.id);
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1646OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1617,0 +1626,21 @@1626+ // fibers can re-enter this function, and the matching1627+ // `permission.replied` can land, while the SDK call is in flight.1628+ // Marking first makes those paths skip the ask instead of racing1629+ // to emit a duplicate `request.opened` or a stray1630+ // `request.resolved`.1631+ context.resolvedRequestIds.add(request.id);1632+ context.autoRepliedRequestIds.add(request.id);1633+ const replied = yield* runOpenCodeSdk("permission.reply", () =>1634+ context.client.permission.reply({ requestID: request.id, reply: "always" }),1635+ ).pipe(1636+ Effect.as(true),1637+ Effect.orElseSucceed(() => false),1638+ );1639+ if (replied) {1640+ return;1641+ }1642+ // The reply failed, so fall back to surfacing the approval. Undo1643+ // the bookkeeping so the terminal event and any retry treat it as1644+ // a normal pending request.1645+ context.resolvedRequestIds.delete(request.id);1646+ context.autoRepliedRequestIds.delete(request.id);
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1675Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1617,0 +1633,21 @@1633+ const replied = yield* runOpenCodeSdk("permission.reply", () =>1634+ context.client.permission.reply({ requestID: request.id, reply: "always" }),1635+ ).pipe(1636+ Effect.as(true),1637+ Effect.orElseSucceed(() => false),1638+ );1639+ if (replied) {1640+ return;1641+ }1642+ // The reply failed, so fall back to surfacing the approval.1643+ context.autoRepliedRequestIds.delete(request.id);1644+ // A terminal `permission.replied` may have landed (and been1645+ // swallowed) while our reply was in flight, e.g. the SDK call timed1646+ // out locally but OpenCode still resolved it. Its terminal slot is1647+ // already consumed, so opening a dialog now would leave a request1648+ // that can never resolve. Keep it marked resolved and return.1649+ if (context.emittedTerminalRequestIds.has(request.id)) {1650+ return;1651+ }1652+ context.resolvedRequestIds.delete(request.id);1653+ }
juliusmarminge merged thisd2b6f3b
juliusmarminge closed this
Sign in to join this conversation.


cursor[bot](GitHub profile, opens in a new tab) reviewed