Repository navigation
fix(top): render --snapshot frames to stdout without terminal control - #1575
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 26, 2026 14:35
This was referenced Sep 26, 2026
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 26, 2026
…sts in CI snapshot_h2_120x40 has failed under `cargo test -p sozu --features tui` since #1434, which added the h2.rst_stream_dropped row to the H2 pane's flood table (bin/src/ctl/top/panes/h2.rs) without updating the stored insta snapshot: $ cargo test -p sozu --features tui test ctl::top::snapshot_tests::snapshot_h2_120x40 ... FAILED +││rst_stream_dropped 0 — ││ test result: FAILED. 134 passed; 1 failed [exit 101] The row itself is intended: #1434 gives the RST_STREAM control queue the same drop + metric + log shape h2.window_update_dropped already has, and the pane lists both. Its trend cell is not: it printed `—` where every sibling row draws a sparkline, because #1434 did not add the key to H2_TRACKED_KEYS (bin/src/ctl/top/app.rs), the list App::fold_h2_trends samples, whose own doc-comment says it exists so a key cannot silently lose its sparkline. Accepting the snapshot as rendered would have frozen that gap. The key is now tracked beside WINDOW_UPDATE_DROPPED, and the snapshot is regenerated with INSTA_UPDATE=always to the corrected frame: the new row with a `▁▁` trend, one fewer blank line below it. Seen red with only the H2_TRACKED_KEYS line removed: $ cargo test -p sozu --features tui --lib snapshot_h2 -││rst_stream_dropped 0 ▁▁ ││ +││rst_stream_dropped 0 — ││ test result: FAILED. 0 passed; 1 failed [exit 101] No other snapshot was stale: the full tui suite passes, 135 tests. The drift went unnoticed because no CI cell enables `tui`, so `Test sozu` compiles every `top` unit test out. A new step on the msrv-full cell runs `cargo test -p sozu --features tui --lib`: that cell already resolves the tui dependencies for `cargo doc --all-features`, nothing in `top` varies by crypto provider, and `--lib` bounds the cost to one extra build of the sozu library test binary (41 s locally with warm dependencies). The sozu_top_e2e step proposed separately in #1575 is left to that PR. Closes #1576 Signed-off-by: Florentin Dubois <[email protected]>
`sozu top --snapshot N` is documented as a "test affordance, no terminal
control", but `render::run` installed `RawModeGuard` unconditionally. Its
`enable_raw_mode()` reaches crossterm's `tty_fd()`, which opens /dev/tty
when stdin is not a terminal, so without a controlling terminal (CI, a
pipe, `ssh -T`) the run failed with `ResolvePath("sozu top render loop",
... os error 6)` (ENXIO).
In snapshot mode the renderer now enters neither raw mode nor the
alternate screen, captures no mouse and installs no terminal-restoring
panic hook. It also reads no input, because crossterm's event reader
opens /dev/tty as well: the loop sleeps for its pacing interval instead.
It draws into a fixed 80x24 viewport, which ratatui neither sizes from
nor resizes to the terminal, since a pipe has no size to query. Frames
go to stdout. Interactive mode is unchanged.
`sozu_top_e2e` now passes without a pty, so CI runs it on the
`msrv-full` cell, which already resolves the `tui` feature for
`cargo doc --all-features`.
Closes #1574
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/top-snapshot-no-raw-mode
branch
from
September 26, 2026 16:59
137f0d2 to
1d9c4c5
Compare
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 26, 2026
…sts in CI snapshot_h2_120x40 has failed under `cargo test -p sozu --features tui` since #1434, which added the h2.rst_stream_dropped row to the H2 pane's flood table (bin/src/ctl/top/panes/h2.rs) without updating the stored insta snapshot: $ cargo test -p sozu --features tui test ctl::top::snapshot_tests::snapshot_h2_120x40 ... FAILED +││rst_stream_dropped 0 — ││ test result: FAILED. 134 passed; 1 failed [exit 101] The row itself is intended: #1434 gives the RST_STREAM control queue the same drop + metric + log shape h2.window_update_dropped already has, and the pane lists both. Its trend cell is not: it printed `—` where every sibling row draws a sparkline, because #1434 did not add the key to H2_TRACKED_KEYS (bin/src/ctl/top/app.rs), the list App::fold_h2_trends samples, whose own doc-comment says it exists so a key cannot silently lose its sparkline. Accepting the snapshot as rendered would have frozen that gap. The key is now tracked beside WINDOW_UPDATE_DROPPED, and the snapshot is regenerated with INSTA_UPDATE=always to the corrected frame: the new row with a `▁▁` trend, one fewer blank line below it. Seen red with only the H2_TRACKED_KEYS line removed: $ cargo test -p sozu --features tui --lib snapshot_h2 -││rst_stream_dropped 0 ▁▁ ││ +││rst_stream_dropped 0 — ││ test result: FAILED. 0 passed; 1 failed [exit 101] No other snapshot was stale: the full tui suite passes, 135 tests. The drift went unnoticed because no CI cell enables `tui`, so `Test sozu` compiles every `top` unit test out. A new step on the msrv-full cell runs `cargo test -p sozu --features tui --lib`: that cell already resolves the tui dependencies for `cargo doc --all-features`, nothing in `top` varies by crypto provider, and `--lib` bounds the cost to one extra build of the sozu library test binary (41 s locally with warm dependencies). The sozu_top_e2e step proposed separately in #1575 is left to that PR. Closes #1576 Signed-off-by: Florentin Dubois <[email protected]>
pull Bot
pushed a commit
to jrcribb/sozu
that referenced
this pull request
Sep 26, 2026
…sts in CI (sozu-proxy#1577) `snapshot_h2_120x40` fails on `main` under `cargo test -p sozu --features tui` since sozu-proxy#1434 added the `h2.rst_stream_dropped` row to the H2 pane without updating the stored insta snapshot. ## Why not just accept the snapshot The row is intended: sozu-proxy#1434 gives the RST_STREAM control queue the same drop + metric + log shape as `h2.window_update_dropped`, and the pane lists both. Its trend cell was not: it rendered `—` where every sibling row draws `▁▁`, because `h2.rst_stream_dropped` was never added to `H2_TRACKED_KEYS` (`bin/src/ctl/top/app.rs`), the list `App::fold_h2_trends` samples. That constant's own doc-comment says it exists so a key cannot silently lose its sparkline. Accepting the frame as rendered would have frozen the gap. ## Changes - `bin/src/ctl/top/app.rs`: track `names::h2::RST_STREAM_DROPPED` beside `WINDOW_UPDATE_DROPPED`. - `snapshot_h2_120x40.snap`: regenerated with `INSTA_UPDATE=always`. The new row now has a `▁▁` trend, and the frame has one fewer blank line below it. No other snapshot was stale. - `.github/workflows/ci.yml`: new `msrv-full` step `cargo test -p sozu --locked ${{ matrix.flags }} --features tui --lib`. No cell enabled `tui`, so `Test sozu` compiled every `top` unit test out. That cell already resolves the tui dependencies for `cargo doc --all-features`, and `--lib` keeps the cost to one extra build of the library test binary (41 s locally with warm deps). The `sozu_top_e2e` step stays with sozu-proxy#1575, and this PR does not touch that hunk. - `CHANGELOG.md`: Fixed entry. ## Red, then green Before (origin/main 57c9269): `cargo test -p sozu --features tui`: `134 passed; 1 failed` (exit 101), and the diff shows `+rst_stream_dropped … —`. With only the `H2_TRACKED_KEYS` line removed, `cargo test -p sozu --features tui --lib snapshot_h2` also fails (`-… ▁▁` / `+… —`, exit 101). After: `cargo test -p sozu --features tui` gives `135 passed; 0 failed` (exit 0). Also exit 0: `cargo build --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd`, `cargo +nightly fmt --all -- --check`, `cargo clippy -p sozu --features tui --all-targets -- -D warnings`, `cargo test -p sozu`, the four `check_doc_citations.py` invocations (the broken fixture exits 1 as expected), and `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked`. Closes sozu-proxy#1576 Signed-off-by: Florentin Dubois <[email protected]>
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.
Closes #1574
Cause
sozu top --snapshot Nis documented inbin/src/cli.rsas a "test affordance, no terminal control", butrender::runinstalledRawModeGuardunconditionally (bin/src/ctl/top/render.rs,let _guard = RawModeGuard::install(cfg.mouse)?;). Itsenable_raw_mode()reaches crossterm 0.29'stty_fd(), which opens/dev/ttywhen stdin is not a terminal. Without a controlling terminal that open fails with ENXIO, andctl/top/mod.rswraps it asResolvePath("sozu top render loop", … os error 6).Removing the guard alone would not be enough:
event::polllazily builds crossterm's event source, which callstty_fd()too, andTerminal::new(a fullscreen viewport) asks the backend for the terminal size.Fix
Only when
--snapshotis set,render::runnow:RawModeGuard);poll/read;Viewport::Fixed, which ratatui 0.30 neither sizes from nor resizes to the terminal (Terminal::with_optionsandautoresizeboth skipbackend.size()for a fixed viewport). 80x24 is the smaller of the two sizes theinstatests render every pane at.Frames go to stdout as ANSI escape sequences. Interactive mode and
--tick-onceare unchanged.CI
sozu_top_e2enow passes without a pty, so a new step runs it on themsrv-fullcell only. That cell already resolves thetuifeature forcargo doc --all-features, so the added cost is one build of thesozubinary withtui, once per pipeline. The step also runs the two non-ignoredsozu toptests, which no cell ran before. The.github/workflows/ci.ymlcomment that kept the test out, the test's doc comment, and the last sentence of #1573's CHANGELOG entry now say it runs.Verification
Run outside a pty (
ttyreports "not a tty"):cargo test -p sozu --features tui --test sozu_top_e2e -- --include-ignoredexits 101,sozu_top_tick_once_against_real_masterfails withcould not resolve path for sozu top render loop : No such device or address (os error 6);cargo test -p sozu --locked --features opentelemetry,splice,simd --features tui --test sozu_top_e2e -- --include-ignored, run with stdin at/dev/null: exit 0, 3 passed;cargo build,cargo clippy --all-targets -D warnings(crypto-ring,opentelemetry,splice,simd, and-p sozu --features tui),cargo +nightly fmt --check,cargo test -p sozu(ring features, 226 passed), the three otherbin/tests/*_e2ewith--ignored,cargo test -p sozu-command-lib(184 passed), the fourcheck_doc_citations.pyinvocations andRUSTDOCFLAGS="-D warnings" cargo doc --all-features: all exit 0.Out of scope
cargo test -p sozu --features tuifails onsnapshot_h2_120x40: the H2 pane now listsrst_stream_dropped(since fix(mux-h2): cap enqueue_rst per insert so a mass reap cannot grow the pending RST queue past its bound #1434) but the.snapfile does not. It fails identically with this PR'srender.rsreverted,origin/main's snapshot lacks the row too, and no CI cell runs that suite.Signed-off-by: Florentin Dubois [email protected]