Skip to content

Conversation

sarub0b0
Copy link
Owner

@sarub0b0 sarub0b0 commented Mar 9, 2025

Replace thread joins with asynchronous execution to ensure proper event processing before raw mode cleanup. This prevents unwanted terminal output during shutdown. Add error logging for worker threads.

@sarub0b0 sarub0b0 linked an issue Mar 9, 2025 that may be closed by this pull request
@sarub0b0 sarub0b0 force-pushed the 712-terminal-fills-with-nonsense-when-quitting branch from 9ae6efb to e89ac85 Compare March 10, 2025 16:40
- Replace thread::scope with detached threads to improve shutdown sequence
- Add polling loop in main thread to monitor termination status
- Change user input thread to use infinite loop pattern
- Implement error logging instead of error propagation

The terminal was being filled with unwanted characters on exit because
the user input thread was terminating before raw mode could be disabled.
Input events like mouse movements that accumulated in the buffer between
the user input thread termination and raw mode disabling were being
output to the terminal after raw mode was disabled.

By changing to detached threads that terminate simultaneously with the
main thread, we ensure that raw mode is disabled before the user input
thread terminates, resolving the issue.
- Replace AtomicBool flags with channels for thread termination
- Simplify inter-thread communication during shutdown
- Implement consistent error handling across worker threads
- Remove unnecessary error propagation to main thread
- Make worker loops more straightforward with infinite loops

This change improves the reliability and clarity of the application's
shutdown process by using explicit signaling through channels rather
than polling termination flags. Worker threads now log errors locally
and trigger shutdown signals rather than propagating errors upward.
@sarub0b0 sarub0b0 force-pushed the 712-terminal-fills-with-nonsense-when-quitting branch from e89ac85 to 316b91b Compare March 10, 2025 16:56
@sarub0b0 sarub0b0 merged commit f0fd5b1 into main Mar 10, 2025
1 check passed
@sarub0b0 sarub0b0 deleted the 712-terminal-fills-with-nonsense-when-quitting branch March 10, 2025 16:59
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 fills with nonsense when quitting
1 participant