anomalyco / anomalyco/opencode

[Bug] Desktop: agent stalls when window is hidden/occluded/display off - permission auto-accept is renderer-side and gets throttled

Open
#41,675 0 comments 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 11, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

On OpenCode Desktop (Windows), long-running agent tasks stall whenever the window goes into the background, and resume only when the window is focused again:

  1. Display off: power settings turn off the display after a few minutes of idle. A task submitted beforehand stops progressing a few minutes after the screen turns off. The UI still shows the session as "running".
  2. Window covered by another app: with another app keeping the active window, the task stops after a while. Focusing the OpenCode window immediately resumes it.

In both cases the session UI keeps showing the task as in-progress, but no actual work happens during the stall.

Root cause (from source analysis)

The permission auto-accept flow is implemented entirely in the renderer process, and Chromium throttles hidden renderer pages.

  • The agent loop runs in the sidecar (server) process: packages/desktop/src/main/sidecar.tsServer.listen. When a tool hits a non-allow permission rule, the loop blocks on yield* permission.ask(...) (packages/opencode/src/session/processor.ts:372) until a client sends permission.reply.
  • The only thing that sends that reply is the renderer: packages/app/src/context/permission.tsx:334-348 listens for the SSE permission.asked event and calls sdk.api.permission.reply(...) when auto-accept applies. If the renderer never processes the event, the server blocks forever with no timeout.
  • The desktop BrowserWindow is created without backgroundThrottling: false (packages/desktop/src/main/windows.ts:199-204; Electron default is true). When the page becomes hidden — fully occluded by other windows (Windows occlusion tracking), screen locked, or display powered off — Chromium throttles the hidden page: timers and task-queue wake-ups drop to ~1/min after a few minutes of being hidden (intensive wake-up throttling). That matches the "stops a few minutes after the screen goes off" observation.
  • When the window is focused again, throttling is removed, the queued permission.asked events are processed, auto-accept replies, and the agent resumes within ~1-2 seconds.

This is the same family as #41374 (agent stalls on ask while the Windows session is locked; backend stays alive; resumes immediately on unlock).

Steps to reproduce
  1. OpenCode Desktop on Windows.
  2. Start a task that will hit an ask permission (e.g. bash or external_directory with default rules) after a delay.
  3. Either lock the screen / turn off the display, or cover the OpenCode window entirely with another app for several minutes.
  4. Return and focus the window.
Expected behavior

Agents should continue executing unattended regardless of window visibility, as long as the machine is awake.

Suggested fixes
  1. Quick: set backgroundThrottling: false in webPreferences in packages/desktop/src/main/windows.ts, and add app.commandLine.appendSwitch("disable-backgrounding-occluded-windows") so covered windows are not treated as hidden.
  2. Correct: move permission auto-accept out of the renderer — subscribe to permission.asked and reply from the main process or the sidecar itself, so permission resolution no longer depends on renderer visibility. The renderer should only be involved when interactive approval is actually needed.
Plugins

None

OpenCode version

Desktop, latest

Operating System

Windows 11

Terminal

Desktop app

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.