Conversation
…ERM (e.g., kill <pid> from another terminal), the signal handler: 1. Restores the terminal to its original state 2. Re-raises the signal with the default handler (so the process exits with the correct status code) This matches how vim, less, and other terminal apps behave. Users won't need to run reset if they kill a seq program that's in raw mode.
…ERM (e.g., kill <pid> from another terminal), the signal handler: 1. Restores the terminal to its original state 2. Re-raises the signal with the default handler (so the process exits with the correct status code) This matches how vim, less, and other terminal apps behave. Users won't need to run reset if they kill a seq program that's in raw mode.
PR Review: Terminal Builtins for Raw Input ModeSummaryThis PR adds terminal control builtins to enable interactive TUI applications in Seq. The implementation is well-structured and follows the codebase patterns. Below are my findings across code quality, potential issues, performance, security, and testing. ✅ Code Quality & Best PracticesStrengths:
Areas for improvement:
|
🔴 Critical fixes: 1. fsync → flush: Changed libc::fsync(1) to std::io::stdout().flush() - fsync is for files, not stdout 2. Non-blocking mode leak: Added check for fcntl failure before attempting read, always restores flags 🟡 Improvements: 3. isatty() checks: Added in enable_raw_mode() and get_terminal_size() - gracefully handles non-TTY 4. STDIN_FILENO/STDOUT_FILENO: Replaced magic numbers 0/1 with named constants 5. Thread-safety docs: Added clear documentation that terminal ops are main-thread only (standard for TUI) 6. Signal handler docs: Added note about async-signal-safe functions The implementation now handles edge cases better (piped input, non-TTY usage) and follows best practices for terminal handling.
Pull Request Review: Terminal Builtins ImplementationThank you for this implementation! This is a solid addition that enables interactive TUI applications in Seq. Below is my detailed review covering code quality, potential issues, and suggestions. ✅ StrengthsCode Quality
Safety & Robustness
🔍 Issues & Concerns1. CRITICAL: Unsafe static mutable globals (
|
Pull Request Review: Terminal Operations (PR #277)SummaryThis PR adds terminal control builtins to the Seq runtime, enabling raw terminal mode and character-level input for building TUI applications. The implementation adds 6 new builtin functions ( Overall AssessmentStatus: Approved with minor suggestions ✓ This is a well-implemented feature with good documentation and sensible design choices. The code quality is high and follows existing patterns in the codebase. Code Quality & Best PracticesStrengths ✓
Minor Suggestions
Potential Bugs & IssuesCritical: Mutable Static Safety
|
| Aspect | terminal.rs | time_ops.rs | io.rs |
|---|---|---|---|
| Doc quality | Excellent | Excellent | Excellent |
| Safety annotations | Consistent | Consistent | Consistent |
| Error handling | Graceful | Graceful | Graceful |
| Test coverage | Basic | Basic | Basic |
Recommendations Summary
Must Fix (before merge)
None - the code is functional and safe for its documented use case.
Should Fix (minor improvements)
- Add explicit comment about signal handler interaction with mutable statics
- Add test for
terminal_read_char_nonblock - Consider integration test that compiles the example
Nice to Have (future work)
- Windows support (probably via crossterm crate)
- Cached terminal dimensions with SIGWINCH handler
- Return error codes instead of silent failures
- Replace
std::mem::zeroed()withMaybeUninit
Conclusion
This is a solid implementation that adds valuable functionality to Seq. The code is well-documented, follows existing patterns, and handles edge cases thoughtfully. The identified issues are minor and don't block merging.
Approved with minor suggestions. ✓
Great work! The signal handler design is particularly well-thought-out, and the graceful degradation for non-TTY environments shows good defensive programming.
#276