Skip to content

Wait to parse extra stdin so it doesnt leak - #971

Merged
HalFrgrd merged 2 commits into
masterfrom
wait_to_parse_extra_stdin
Aug 29, 2026
Merged

HalFrgrd merged 2 commits into
masterfrom
wait_to_parse_extra_stdin

Conversation

@HalFrgrd

Copy link
Copy Markdown
Owner

No description provided.

@HalFrgrd
HalFrgrd merged commit dc35966 into master Aug 29, 2026
2 checks passed
HalFrgrd pushed a commit that referenced this pull request Sep 6, 2026
Fixes #984

## Summary

- Restore terminal modes and drain trailing terminal reports while `App`
still owns the terminal and raw mode remains active.
- Remove the `EndState` transport type, since shutdown draining now
happens inside `App::run`.
- Add a deterministic pseudo-terminal regression test to the existing
Bash integration-test images.

## Root cause

The shutdown drain added in #971 runs in `get_command`, after `App::run`
returns. `App::run` consumes `App`, so returning drops its terminal
backend and restores cooked mode with echo before the drain begins. A
FocusIn report arriving in that interval can be echoed as `^[[I`;
consuming it afterward prevents it from becoming input, but cannot undo
the visible output.

This change sends the terminal reset sequences and performs the existing
conditional drain at the end of `App::run`, before `self` is dropped.
The shell still receives the same `ExitState` after the terminal handoff
is complete.

## Regression coverage

The new test runs Flyline as a real Bash loadable builtin behind a
pseudo-terminal, emulates the terminal queries used during startup,
submits an empty command, and injects a FocusIn report at the
focus-tracking shutdown boundary. It fails on the unmodified code with
`^[[I[flyline inserted newline]` and passes when the drain runs before
raw mode is released.

The test is part of the existing Docker Bash integration targets, so CI
will exercise it across the supported Bash versions.

## Verification

- `cargo fmt --all -- --check`
- `cargo clippy --workspace --all-features -- -D warnings`
- `cargo test --workspace --all-features --lib -- --skip
history::tests::test_pipeline_history_entry_formatting` — 1,031 passed,
0 failed, 1 ignored
- `TZ=UTC cargo test -p flyline
history::tests::test_pipeline_history_entry_formatting -- --exact` —
passed; this existing test expects a UTC calendar date and fails under
Europe/Stockholm
- Regression test against unmodified Flyline 1.7.1 — failed as expected
in three of three runs
- Regression test against this branch — passed in three of three runs
- Docker integration targets — passed with Bash 4.4-rc1, 4.4.18, 5.0,
and 5.3

Bash 3.2 could not be built locally because the `config.guess` shipped
with Bash 3.2 does not recognize Docker Desktop's ARM64 platform. The
existing x86 GitHub Actions job will cover that target.
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.

1 participant