Skip to content

fix(app): pending permissions are not auto-accepted after page refresh #20998

Closed as not planned

Description

@KingingWang

Bug Description

When the browser page is refreshed or reopened while an AI task is running, pending permission requests that were issued before the refresh are never auto-accepted, even when auto-accept is enabled. The task remains stuck waiting for a response that never comes, and no permission dialog is shown to the user.

Reproduction Steps

  1. Start a conversation with OpenCode in the web UI
  2. Send a message that triggers a permission request (e.g., git commit)
  3. Before the permission dialog appears, close or refresh the browser page
  4. Reopen the page (auto-accept setting is restored from localStorage)
  5. Observe that:
    • The auto-accept toggle shows as "enabled"
    • The AI task is still running but appears stuck
    • No permission dialog is visible
    • The permission request is never auto-accepted

Expected Behavior

After page refresh, the app should:

  1. Query for any pending permission requests from the backend
  2. If auto-accept is enabled for that session/directory, automatically respond to pending permissions
  3. If auto-accept is disabled, show the permission dialog for pending requests

Actual Behavior

The pending permission requests are never processed because:

  1. SSE only delivers real-time events, not historical ones
  2. The permission.asked event was sent before the page reconnected
  3. The auto-accept logic only triggers when receiving new permission.asked events
  4. No code queries for pending permissions on page initialization

Root Cause Analysis

Looking at the code:

// packages/app/src/context/permission.tsx
const unsubscribe = globalSDK.event.listen((e) => {
  const event = e.details
  if (!e.name.startsWith("permission.")) return
  const perm = event.properties
  if (!shouldAutoRespond(perm, e.name)) return
  respondOnce(perm, e.name)
})

The auto-accept only works when the frontend receives a permission.asked event via SSE. However, SSE is a real-time stream - when the page disconnects and reconnects, previously sent events are not replayed.

The enable() function does query for pending permissions:

function enable(sessionID: string, directory: string) {
  setStore(...)
  globalSDK.client.permission
    .list({ directory })
    .then((x) => {
      for (const perm of x.data ?? []) {
        if (shouldAutoRespond(perm, directory)) {
          respondOnce(perm, directory)
        }
      }
    })
}

But this is only called when the user manually toggles auto-accept. There's no equivalent logic on page initialization.

Proposed Fix

On page initialization (in permission.tsx), after the store is ready, query for pending permissions and process them according to the current auto-accept settings:

// In permission.tsx, after persisted store is ready
createEffect(() => {
  if (!ready()) return
  const directory = decode64(params.dir)
  if (!directory) return
  
  // Query and process pending permissions
  globalSDK.client.permission
    .list({ directory })
    .then((x) => {
      for (const perm of x.data ?? []) {
        if (shouldAutoRespond(perm, directory)) {
          respondOnce(perm, directory)
        }
      }
    })
})

Environment

  • OpenCode version: Latest dev branch
  • Browser: Any (Chrome, Safari, Firefox)
  • OS: Any (macOS, Linux, Windows)
  • UI: Web interface (packages/app)

Activity

  1. removed
    webRelates to opencode on web / desktop
    on May 3, 2026
  2. hueyexe commented on Jun 17, 2026

    @hueyexe

    I am encountering this too. My set up is an opencode web server at home over a Tailscale VPN. I have the session open on my phone away from home, with auto accept permissions enabled. It runs fine until I change apps, my phone locks, and I assume the browser is put to sleep. When I come back to the page the session seems to be frozen on shell commands, but no pop up visible. Turing auto accept permissions off/on resumes the session again. Keeping the window open also seems to prevent it.

  3. github-actions commented on Aug 16, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions