Repository navigation
fix(test): stabilize terminal PTY fragments and add timing diagnostics - #746
mergify[bot] merged 2 commits into
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 26d2035 against e86f9bb. No blocking findings.
I read all three changed files and traced the fixture through StartupTerminal::begin, query_startup_attributes, parser framing/deadlines, the pre-handoff Sixel cache observation, and the subsequent input/restoration assertions.
The four fragments concatenate to the original reply and retain the opening-ESC, ST, and RGB splits. Absolute offsets remove accumulated relative-sleep overhead without changing the 300 ms product deadline or the parser's deadlines. Exact bytewise fragmentation is tested directly through Parser::advance, with ordered OSC responses and surrounding keys asserted; PTY write coalescing therefore does not invalidate that coverage.
The delayed-DA1 case still checks a product result (sixel_before == true before TUI/EventStream handoff), in addition to the sender's recorded delay. The explicit negative-response and late-response/unknown cases remain. Moving the reply to 80 ms gives the integration fixture scheduling headroom; it deliberately gives up the former near-deadline timing scenario, as documented. This is not evidence that every response close to the deadline will be accepted under arbitrary scheduling.
I also read the original failing macOS job: it shows the fragmented light/dark mismatch, but does not establish the timing root cause. The PR appropriately treats scheduling as a hypothesis and adds observations without claiming conclusive reproduction. Parent timestamps are observations after spawn, not the child's actual query-start clock.
Validation: local git diff --check passed. Cargo is unavailable here, so I did not locally execute Rust tests or reproduce the original failure. I independently fetched the current GitHub Actions results and logs: Static Checks and Test Suite succeeded; Linux and macOS each ran both reader configurations with 14 PTY tests passing per invocation. The Linux vendor log confirms the new bytewise test ran and both configurations passed 106 tests with 7 ignored; the macOS vendor job also succeeded. No production code, live services, or release artifacts were changed during this review.
The PR head was rechecked immediately before submission and is unchanged.
Merge Queue Status
This pull request spent 12 seconds in the queue, including 1 second running CI. Required conditions to merge
|
Summary
Stabilize the fragmented-response PTY fixture and add useful failure diagnostics after the macOS terminal PTY lane failed on main.
Related issue
Follow-up to #745 and the failing macOS PTY job.
That run passed every other job, including Linux PTY and the previously repaired Docker layout contract. The failure was
pty_detects_light_dark_and_fragmented_responses: thefragmentedcase expected light mode but received dark mode. Accumulated sender scheduling delays are a plausible cause, not proven by the old logs, which did not include timing or the complete probe result. Thirty local repetitions of the old fixture did not reproduce the failure. This change removes the avoidable accumulated-sleep dependency and adds evidence for any remaining failures; it does not claim to have conclusively reproduced the runner's original timing.Change type
User and compatibility impact
None for application behavior, APIs, credentials, or database schemas. Only test fixtures, test diagnostics, a parser unit test, and patch documentation change. Product timeouts and terminal parsing behavior remain unchanged. Diagnostics contain synthetic test-terminal data, not user terminal content.
Architecture and complexity delta
N/A for production architecture.
StartupTerminal::begin,query_startup_attributes, parser escape/response deadlines, PTY sender and assertions, and both CI reader invocations.Verification
Commands and results on local macOS ARM:
cargo test --locked -p astra-cli --lib tui::terminal_startup -- --test-threads=2: 14 passed.cargo test --locked -p astra-cli --lib --features crossterm/use-dev-tty tui::terminal_startup -- --test-threads=2: 14 passed.tui::terminal_startup::pty_tests::pty_detects_light_dark_and_fragmented_responsesdirectly from each freshly built test executable: 50 runs per reader, two concurrent processes, zero failures, with no retries. Each run covers light, fragmented, background-only, and dark cases.cargo test --locked --manifest-path vendor/crossterm/Cargo.toml --lib --features event-stream: 106 passed, 7 ignored.cargo test --locked --manifest-path vendor/crossterm/Cargo.toml --lib --features event-stream,use-dev-tty: 106 passed, 7 ignored.python3 -m unittest discover -s scripts/ci -p 'test_*.py': 77 passed.python3 scripts/ci/validate_repository.py: passed.cargo fmt --all --check: passed.rustfmt --check --edition 2021 vendor/crossterm/src/event/source/unix/parser.rs: passed.git diff --check: passed.Public entrypoint exercised: real CLI startup, terminal guard, event reader, and EventStream through isolated PTYs; no model or service required.
Unhappy paths exercised: existing unsupported/late/malformed responses, timeouts, interrupted startup/handoff, escape/input preservation, and terminal-mode restoration tests remain enabled and passed for both readers.
Database verification: not applicable.
Limits: the original GitHub macOS failure was not reproduced locally; hosted macOS/Linux verification remains for CI. Full workspace Rust suites and release images were not rebuilt for this test-only change. The local CLI links emitted the existing
__eh_framesize warning; selected tests passed.Final checklist