anomalyco / anomalyco/opencode
[Bug] Desktop: agent stalls when window is hidden/occluded/display off - permission auto-accept is renderer-side and gets throttled
@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:
- 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".
- 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.ts→Server.listen. When a tool hits a non-allowpermission rule, the loop blocks onyield* permission.ask(...)(packages/opencode/src/session/processor.ts:372) until a client sendspermission.reply. - The only thing that sends that reply is the renderer:
packages/app/src/context/permission.tsx:334-348listens for the SSEpermission.askedevent and callssdk.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 istrue). 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.askedevents 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
- OpenCode Desktop on Windows.
- Start a task that will hit an
askpermission (e.g.bashorexternal_directorywith default rules) after a delay. - Either lock the screen / turn off the display, or cover the OpenCode window entirely with another app for several minutes.
- 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
- Quick: set
backgroundThrottling: falseinwebPreferencesinpackages/desktop/src/main/windows.ts, and addapp.commandLine.appendSwitch("disable-backgrounding-occluded-windows")so covered windows are not treated as hidden. - Correct: move permission auto-accept out of the renderer — subscribe to
permission.askedand 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.