Skip to content

fix: resolve hanging permission prompts in headless mode - #3522

Merged
rekram1-node merged 4 commits into
anomalyco:devfrom
ritoban23:fix/3503-permission-hang
Oct 30, 2025
Merged

rekram1-node merged 4 commits into
anomalyco:devfrom
ritoban23:fix/3503-permission-hang

Conversation

@ritoban23

Copy link
Copy Markdown
Contributor

Fix: Resolve Hanging Permission Prompts in Headless Mode

Problem

When "permissions": { "bash": "ask" } is set in opencode.json and OpenCode is run in headless mode (e.g., opencode run), the application hangs silently when a bash command is requested. This happens because there is no handler to respond to the permission.ask hook, so the process waits forever for user input that never arrives.

Solution

This PR adds a built-in CLI permission handler that uses @clack/prompts to interactively prompt the user for permission in headless and run modes. The handler is always loaded as part of the plugin system, ensuring permissions can be confirmed or denied in all environments.

Key Changes

  • New: src/cli/permission-handler.ts

    • Implements createCliPermissionHandler using @clack/prompts
    • Handles permission.ask by showing a confirmation dialog and returning "allow" or "deny" based on user input
  • Modified: src/plugin/index.ts

    • Integrates the CLI permission handler into the plugin system so it is always available
  • New: test/cli/permission-handler.test.ts

    • Adds unit tests to verify the handler's structure and basic behavior

How It Works

  1. When a tool requests permission (e.g., for bash), the permission system triggers the permission.ask hook.
  2. The CLI handler prompts the user in the terminal with a clear message.
  3. The user can confirm or deny the request.
  4. The handler responds with "allow" or "deny", unblocking the process.

Closes #3503

@rekram1-node

Copy link
Copy Markdown
Collaborator

Going to check this out tmr

@rekram1-node

Copy link
Copy Markdown
Collaborator

This isn't quite the right approach, you wanna subscribe to the bus in the run command directly otherwise this will corrupt the tui.

I will make the tweaks to get it working

@rekram1-node
rekram1-node merged commit a3ba740 into anomalyco:dev Oct 30, 2025
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In opencode run mode, "permissions":{"bash": "ask"} hangs silently.

2 participants