opencode
opencode copied to clipboard
fix(tui): improve macOS terminal restoration on exit
fixes: #7861
Summary:
Fixes the "dead terminal" issue that occurs when opencode exits on macOS, leaving users with a corrupted terminal state that requires manual reset.
Changes:
- ✅ Enhanced signal handling for SIGINT, SIGHUP, SIGTERM
- ✅ Improved suspend/resume with proper alternate screen buffer management
- ✅ Comprehensive exit cleanup with terminal reset sequences
- ✅ Added macOS terminal detection utility
- ✅ Added test script for validation
- ✅ Integrated tests into CI workflows
Technical Details:
- Uses proper ANSI escape sequences for terminal restoration
- Implements graceful signal cleanup to prevent memory leaks
- Added platform-specific terminal buffer management
- All TypeScript errors resolved
Testing:
- ✅ Manual testing on macOS Terminal and iTerm2
- ✅ Automated test script validates all functionality
- ✅ CI integration ensures future compatibility