Repository navigation
fix(setup): a key typed after an unfinished sequence isn't swallowed - #131
Merged
Merged
Conversation
Since #120 the menu reads bytes already there even past the 250 ms sequence budget. When this process got to the input late, a Ctrl+C (or Enter) typed after an unfinished escape sequence was then taken into that sequence and lost, and a lone Esc followed by Ctrl+C became one unknown key. A C0 control or DEL can't be part of a sequence: it now ends it and is read as the next key. The PTY test was flaky on macOS runners in two places, both fixed: - the partial `ESC [` then Ctrl+C case hit the bug above; - the fragmented-input case sends one byte every 40 ms and relies on the script itself not stalling past the 250 ms budget. An attempt whose writes took over 200 ms proves nothing and is run again (up to five times). The split-terminal case now waits 8 s for the first frame, like the rest of the script, instead of 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks done
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What and why
The
CI / macoscheck keeps failing on the "Terminal menus (PTY)" step. In the last 40 CI runs, 11 of the 15macosfailures were that step, while the same script never failed on Linux. Every one of them is in one of two cases:tests/terminal.pyESC [ Bsent one byte every 40 ms, expect item 2ESC [, then Ctrl+C after 350 ms, expect cancelThe bug. #120 made the menu read bytes already there even past the 250 ms budget, so a key whose bytes all arrived isn't split when this process is late. The other side of that: when the process got to the input late, a Ctrl+C (or Enter) typed after an unfinished
ESC [was read as part of that sequence and lost; Ctrl+C then did nothing. A lone Esc followed by Ctrl+C likewise became one unknown key. A C0 control or DEL can't be part of an escape sequence, soread_keynow ends the sequence there (Unknown, or Esc after a lone ESC) and queues the byte as the next key. Complete sequences and everything else read as before.The test. The fragmented case now times its own writes. The behaviour is only guaranteed when they span less than the budget, so an attempt whose writes took over 200 ms is run again, up to five times. That makes the case deterministic: the reader's deadline starts no earlier than the first write, and bytes there at the deadline are read (#120). The split-terminal case waits 8 s for the first frame like the rest of the script, instead of 5 (a run under heavy local load timed out there).
A companion PR splits the macOS PTY step out of the required
macoscheck.Tests
1. Unit tests
cargo test --workspace --all-features --locked(462 passed),cargo clippy --workspace --all-targets --all-features --locked -- -D warningsandcargo fmt -p iphone-control -- --checkpass (Rust 1.97.1, macOS).a_control_key_after_an_unfinished_sequence_is_its_own_key:ESC [ ^C,ESC O ^C,ESC [ 1 CR,ESC ^C,ESC ESC, plus completeESC [ B CRandESC [ 5 ~ ^C, all written before the reader looks (the late case). It fails againstmain'sread_key.#[ignore]tests of the changed area run by hand:pty_menu, throughtests/terminal.py.2. Real-device regression
tests/terminal.pyon macOS (Darwin 27, Apple Silicon), with every core kept busy (yes× 2 × cores) to imitate a loaded runner:3. Regression cases (docs/dev/regression-cases.md)
4. Real-device proof of the fix or feature
main, passes here) and the PTY runs.Checklist
🤖 Generated with Claude Code