opencode
opencode copied to clipboard
fix(tui): prevent UI freezes from clipboard operations and event loop
Summary
- Replace
Bun.$withnode:child_processin clipboard.ts to avoid GC crashes caused by Bun shell interpreter bug - Add debouncing to clipboard copy operations (100ms) to prevent rapid-fire clipboard access
- Add yield point in SDK event loop to prevent render thread starvation
Problem
TUI would intermittently freeze, especially when clipboard operations were triggered. Root cause traced to Bun shell interpreter GC bug (oven-sh/bun#23177) where the shell interpreter is freed while still in use.
Solution
-
clipboard.ts: Replaced all
Bun.$usage with Node.jschild_process(spawn, execSync) which doesn't have this issue -
app.tsx: Added
debouncedCopy()function wrapping all 4 clipboard copy calls with 100ms debounce -
sdk.tsx: Added
await new Promise((r) => setTimeout(r, 0))after flush to yield to render thread
Testing
Manual testing confirms UI no longer freezes during clipboard operations.
Related
- Bun bug: oven-sh/bun#23177
- Fix PR to Bun: oven-sh/bun#25916