feat: enhance Termux compatibility with centralized utility module #1719
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhanced Termux Compatibility for Cursor Position Timeout Errors
🎯 Problem Statement
Termux (Android terminal emulator) users frequently encounter "cursor position could not be read within a normal duration" errors, especially during screen sleep/wake cycles and terminal resizing. This issue makes the application nearly unusable on mobile devices.
🔧 Solution Overview
This PR introduces comprehensive Termux compatibility improvements with a centralized utility module that handles platform-specific behaviors gracefully.
✨ Key Improvements
1. Centralized Termux Detection & Configuration
TermuxCompat
utility module for all Termux-specific logicTERMUX_VERSION
andPREFIX
environment variables2. Adaptive Timeout Management
3. Terminal Resize Stabilization
4. Improved Error Handling
5. Bracketed Paste Mode Compatibility
📁 Files Changed
tui/src/termux_compat.rs
(new): Centralized Termux compatibility utilitiestui/src/app.rs
: Updated event polling with adaptive timeouts and error handlingtui/src/tui.rs
: Conditional bracketed paste mode handlingtui/src/lib.rs
: Added module import🧪 Testing
✅ Build verification:
cargo check --package codex-tui
passes without errors✅ Code cleanup: Eliminated duplicate Termux detection logic
✅ Abstraction quality: All platform logic centralized in
TermuxCompat
🎉 Expected Impact
🔍 Implementation Details
TermuxCompat API
Before/After Comparison
This enhancement makes Codex significantly more reliable and user-friendly on Android devices while maintaining excellent performance on desktop terminals.