Skip to content

Conversation

@coleleavitt
Copy link
Contributor

Summary

  • Replace Bun.$ with node:child_process in 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

  1. clipboard.ts: Replaced all Bun.$ usage with Node.js child_process (spawn, execSync) which doesn't have this issue
  2. app.tsx: Added debouncedCopy() function wrapping all 4 clipboard copy calls with 100ms debounce
  3. 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

- Replace Bun.$ with node:child_process in clipboard.ts to avoid GC crashes
- Add debouncing to clipboard copy operations (100ms)
- Add yield point in SDK event loop to prevent render thread starvation

Addresses Bun shell GC bug: oven-sh/bun#23177
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant