Skip to content

Conversation

@RandyMcMillan
Copy link

@RandyMcMillan RandyMcMillan commented Jan 11, 2026

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

@github-actions
Copy link
Contributor

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

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

No duplicate PRs found

@@ -1,5 +1,15 @@
import { RGBA } from "@opentui/core"

export function isMacOSTerminal(): boolean {
Copy link
Author

@RandyMcMillan RandyMcMillan Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMacOSTerminal: additional OS tests may be added in a follow up PR to be more cross platform compatible.

Testing for Windows is outside of the scope of this PR.

@RandyMcMillan
Copy link
Author

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

fixes: #7861

Add comprehensive macOS terminal handling to prevent 'dead terminal' issues:

- 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

Ensures terminal is properly restored to usable state when opencode shuts down,
preventing scrambled terminals and requiring manual resets.

00-00000244
Add comprehensive test utility for macOS terminal functionality:

- Tests macOS terminal detection logic
- Validates terminal reset escape sequences  
- Verifies signal handler setup and cleanup
- Mocks renderer for isolated testing

Ensures terminal restoration changes work correctly across different macOS environments.

00-00000232
Add macOS terminal restoration testing to CI workflows:

- Test script runs on macOS runners in nix-desktop workflow
- Test script runs on macOS Tauri builds in publish workflow
- Validates terminal restoration before desktop builds
- Ensures future changes don't break macOS terminal functionality

00-00000fd9
@RandyMcMillan RandyMcMillan force-pushed the 1897/931882/382494/0003587/279cdb2-restore-term branch from 000b3b0 to 000466a Compare January 12, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: Terminal becomes unusable after opencode exits ("dead terminal")

1 participant