opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[Feature]: Runtime Permission Mode Toggle (like Claude Code's Shift+Tab)

Open LEON-gittech opened this issue 5 days ago • 2 comments

Feature Request: Runtime Permission Mode Toggle

Problem

Currently, OpenCode defaults to auto-edit mode where all file edits execute immediately without confirmation. This is too aggressive for many workflows and can lead to unintended changes.

While permissions can be configured statically in opencode.json, there is no way to toggle between permission modes at runtime without switching agents.

Claude Code solves this elegantly with Shift+Tab cycling through three modes:

  1. Normal - Edits require confirmation
  2. Plan - Read-only analysis, no edits allowed
  3. Auto - Edits execute automatically

Proposed Solution

Add a dedicated keybind (suggest Shift+Tab or configurable) that cycles through permission modes within the current agent:

[Normal Mode] ──Shift+Tab──▶ [Plan Mode] ──Shift+Tab──▶ [Auto Mode]
      ▲                                                      │
      └──────────────────────Shift+Tab───────────────────────┘

Mode behaviors:

Mode edit write bash
Normal ask ask ask (except safe commands)
Plan deny deny deny (read-only commands allowed)
Auto allow allow allow

Current Workaround

Users can create multiple agents with different permissions and use Tab to switch between them:

{
  "agent": {
    "build": {
      "permission": { "edit": "ask" }
    }
  }
}
<!-- ~/.config/opencode/agent/auto.md -->
---
permission:
  edit: allow
  write: allow
---

Problems with this workaround:

  1. Agents have separate conversation contexts
  2. Switching agents feels like starting over
  3. Not intuitive for new users expecting Claude Code behavior
  4. Requires manual configuration

Why This Matters

  1. Safety by Default - New users should not accidentally overwrite files
  2. Workflow Flexibility - Sometimes you want to review changes, sometimes you trust the AI
  3. User Expectations - Claude Code has set the standard for this interaction pattern
  4. Reduced Anxiety - Users can confidently explore knowing they have control

Implementation Suggestion

  1. Add a session-level permission override state
  2. Add keybind permission_mode_cycle (default: shift+tab if not conflicting)
  3. Show current mode in status bar or input area (e.g., [Normal], [Plan], [Auto])
  4. Persist mode preference per session or globally

Visual Indicator

Show the current mode near the input area:

┌─────────────────────────────────────────┐
│ [Normal] │ Type your message...         │
└─────────────────────────────────────────┘

Or in a status line:

build │ claude-sonnet │ Normal Mode

Configuration

Allow users to customize the default mode:

{
  "permission": {
    "defaultMode": "normal"  // "normal" | "plan" | "auto"
  }
}

Related

  • Current workaround uses agent switching via Tab / Shift+Tab (agent_cycle keybinds)
  • Permission system: packages/opencode/src/permission/
  • Claude Code reference: https://docs.anthropic.com/en/docs/claude-code

Note

This is different from the existing agent-switching mechanism. The goal is to change permission behavior within the same agent/session without losing conversation context.

LEON-gittech avatar Jan 12 '26 06:01 LEON-gittech