Description
The Electron desktop app becomes unresponsive on startup when a project with a large number of .gitignored files is in the saved project list. The sidecar process (opencode-cli serve) pegs at ~100% CPU indefinitely, making the app unusable.
Environment
- opencode version: 1.3.13 (Electron AppImage, Linux x86_64)
- OS: CachyOS (Arch-based), kernel 6.19.11-1-cachyos
- Display: Wayland
Steps to Reproduce
- Open a project with a large number of files that are excluded via
.gitignore (e.g. 213GB, ~514K files — most gitignored build artifacts/data)
- Close the app
- Reopen the app — the project is restored from saved state
Observed Behavior
- Sidecar process (
opencode-cli serve) immediately goes to ~98-100% CPU
- CPU usage never settles (tested up to 45+ seconds)
- The renderer process also spikes (~136% CPU initially)
- The app window appears but is unresponsive
- The sidecar health endpoint (
/global/health) responds, so the HTTP server itself is running — the CPU is consumed by file watching/indexing
Expected Behavior
The experimental file watcher (OPENCODE_EXPERIMENTAL_FILEWATCHER=true, set by the Electron app) should respect .gitignore and skip ignored files/directories. Large gitignored directories (build outputs, data files, etc.) should not cause the sidecar to spin.
Root Cause Analysis
The Electron app sets OPENCODE_EXPERIMENTAL_FILEWATCHER=true in the sidecar environment. When the sidecar initializes a workspace for a project with hundreds of thousands of gitignored files, it appears to perform a naive recursive scan before (or without) applying .gitignore filters, causing an epoll busy-spin.
Evidence:
- Running
opencode-cli serve directly (without the experimental file watcher env var) uses 0% CPU at idle
- Running with
OPENCODE_EXPERIMENTAL_FILEWATCHER=true but without a client connecting also uses 0% CPU — the issue triggers when the renderer connects and the workspace is initialized
- Clearing the project from the app's saved state (
opencode.global.dat) resolves the issue immediately — sidecar drops to ~15% CPU on startup and settles to idle
Workaround
Clear the large project from ~/.config/ai.opencode.desktop/opencode.global.dat by resetting the server.projects field.
Description
The Electron desktop app becomes unresponsive on startup when a project with a large number of
.gitignoredfiles is in the saved project list. The sidecar process (opencode-cli serve) pegs at ~100% CPU indefinitely, making the app unusable.Environment
Steps to Reproduce
.gitignore(e.g. 213GB, ~514K files — most gitignored build artifacts/data)Observed Behavior
opencode-cli serve) immediately goes to ~98-100% CPU/global/health) responds, so the HTTP server itself is running — the CPU is consumed by file watching/indexingExpected Behavior
The experimental file watcher (
OPENCODE_EXPERIMENTAL_FILEWATCHER=true, set by the Electron app) should respect.gitignoreand skip ignored files/directories. Large gitignored directories (build outputs, data files, etc.) should not cause the sidecar to spin.Root Cause Analysis
The Electron app sets
OPENCODE_EXPERIMENTAL_FILEWATCHER=truein the sidecar environment. When the sidecar initializes a workspace for a project with hundreds of thousands of gitignored files, it appears to perform a naive recursive scan before (or without) applying.gitignorefilters, causing an epoll busy-spin.Evidence:
opencode-cli servedirectly (without the experimental file watcher env var) uses 0% CPU at idleOPENCODE_EXPERIMENTAL_FILEWATCHER=truebut without a client connecting also uses 0% CPU — the issue triggers when the renderer connects and the workspace is initializedopencode.global.dat) resolves the issue immediately — sidecar drops to ~15% CPU on startup and settles to idleWorkaround
Clear the large project from
~/.config/ai.opencode.desktop/opencode.global.datby resetting theserver.projectsfield.