Repository navigation
feat(cli): show progress on a terminal, and leave the outline from view (#63 part 1) - #84
Merged
Merged
Conversation
Part 1 of #63. When stderr is a terminal, the run is streamed and one line there is redrawn in place: the part count (at once from a cached outline artifact), then the transfer and mesh percentages, erased when the run ends. A pipe gets nothing, and stdout's JSON line is unchanged. `stepv view` now streams its load like a cached CLI run and writes the outline artifact under the pre-run FileId, so a viewer killed after the outline leaves the tree for the next preview. The viewer's own outline-first window is part 2. Refs: #63
This was referenced Oct 12, 2026
The pty test's master and slave came from openpty without close-on-exec, so a parallel test's stepv (and its kernel) could inherit the other terminal's slave and hold it open. They are now close-on-exec from the moment they exist (posix_openpt with O_CLOEXEC, the slave opened by std), and the tests assert it. Every view test goes through Home::view: the kernel under --memory-mb, the screenshot hook set, and the viewer's own footprint polled and failed past 2 GiB or 120 s (#86). New tests cover view --no-cache leaving no artifact and a complete view adding the box. plan.md now says what Ctrl-C leaves on the progress line, and points the viewer's remaining work at #85. Refs: #63
Home::view spawns stepv in its own process group. Past its footprint cap or deadline the watchdog SIGKILLs the group: the kernel's caps are stepv's own sampler, so killing stepv alone orphaned an uncapped kernel. However a run ends, no member of its group may outlive it. stepv gets --timeout 30 by default, so its own timeout fires before the 120 s watchdog, and the watchdog's panic names the limit that fired. A new test runs a kernel that never finishes under a 2 s deadline and checks that the kernel dies with stepv. Refs: #63
In a process with no window-server session (nix's macOS builder runs as _nixbld with none), stepv view ran the whole kernel and then died inside the window layer, which aborts outright, so stdout's report was lost. view::session now asks first (macOS: CGSessionCopyCurrentDictionary; elsewhere on Unix: DISPLAY or WAYLAND_DISPLAY) and fails at once with "no window session: ...", the reason and the header metadata. The four tests/cache.rs tests that start view past the check need a session: they are ignored in nix's sandbox and run by scripts/test-window-tests.sh, which fails unless all of them ran and passed, from just view-test (the macOS runner) and under Xvfb in the Linux viewer job. A new nextest test covers the early failure. Refs: #63
The terminal test forbade any newline and required the run's output to end with the erase. In nix's macOS sandbox the kernel's sandbox cannot nest (macos-outer), and stepv rightly warns about it on stderr, after erasing the line: the documented rule. The test now checks exactly that rule: no newline while redrawing, the erase right after the last redraw, and no progress after it. Refs: #63
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
…se (#85) (#93) Closes #85 ## What `stepv view` opens its window **at once** and runs the kernel on a thread of its own (`run_view` / `load_view` in `src/main.rs`), through the CLI's own `tessellate`, so the artifact, the box and the progress code are shared, not duplicated. The loader sends the window `view::Load` messages over a channel: - **`Tree`:** a cached outline artifact's tree, sent before the kernel starts, then the run's `Event::Tree`. It's drawn in the tree panel (`Tree::from_nodes`). - **`Progress`:** "Transferring the shapes: P%" or "Meshing: P%", with a progress bar. - **`Done`:** the GPU scene is built and the viewer swaps in, with the full title. - **`Failed`:** the window closes and the report says why, as before. #89 will keep the tree with its reason instead. **Closing mid-load cancels the run (Q1).** `occt::run_streaming` gains a `cancel: Option<&AtomicBool>` parameter. `supervise`'s tick may stop the run and kill the kernel, which is the new `Outcome::Cancelled`. `view` reports status `cancelled` with exit 0. This public API change is in the rustdoc and the CHANGELOG. **Known limits.** `--software`, or no usable GPU, still waits for the whole run (#90). A failed run closes the window (#89). ## Tests (each new one fails on `origin/main`) - `tests/stream.rs` `a_cancelled_run_is_killed_at_once` (nextest): `Outcome::Cancelled`, no summary, within seconds of a 60 s cap. - Window tests: `#[ignore = "needs a window session; …"]`, run by `scripts/test-window-tests.sh`, which now counts 7. They go through `Home::view` (process group, memory cap, `--timeout`, screenshot hook). Under `STEPV_VIEW_SCREENSHOT` the window reports its frames on stderr, because the macOS CI runner never presents a window: - `the_viewer_shows_the_tree_before_the_geometry`: with the kernel stalled 8 s, the loading frame shows the outline's rows and no geometry, then the scene. On `main`: `no loading frame with the tree`. - `a_cached_outline_shows_the_tree_before_any_kernel_event`: a cached artifact with a mute kernel shows the artifact's rows. On `main`: no loading frame. - `closing_the_viewer_mid_load_cancels_the_kernel`: `STEPV_VIEW_CLOSE_LOADING=1` with a stalled kernel gives `cancelled`, exit 0, in under 20 s, and the kernel's process is gone. On `main`: `(4, "timeout")` after 30 s. - The existing watchdog test's deadline goes from 2 s to 10 s. The window now opens alongside the run, and macOS's first-launch check of the test's fresh kernel script was measured at up to 1.5 s, which made 2 s flaky. That's still far below stepv's own 30 s timeout. - The no-session early failure (#84) is unchanged and still passes in nextest. ## Review round 1 (ed150e9) - **Software fallback (blocker):** the viewer's pipelines are now built and validated in eframe's creator (`pipelines()` in `src/view/app.rs`), before the window is the viewer's. A refusal hands the load back, and `view::run` falls back to software, as on `main`. Only the scene's buffers are checked after `Done`. - New window test `a_gpu_that_refuses_the_pipelines_falls_back_to_software`, using the `STEPV_VIEW_REJECT_PIPELINES` hook: status `ok`, backend `software`, and the screenshot is drawn. At f18f607 it fails with `backend: "metal"`. - **Loader panic:** the loader takes the `Sender` by value, so a panic closes the channel. A unit test checks that a panicking loader ends the software viewer's wait. - **`cancelled` report:** it carries `message`, not `error` (documented in plan.md); the cancel test asserts it. - **CHANGELOG:** the `run_streaming` change is under **Changed**, marked breaking. - **Harness:** `Outcome::Cancelled` maps to a `Crash` verdict with a note, instead of `unreachable!`. ## Gate - `cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test` → exit 0 - `nix build -L --no-link .#checks.aarch64-darwin.nextest` → exit 0 (248 passed, 11 skipped: 3 existing ignores and the 8 window tests; at ed150e9) - `just view-test` → its test steps passed: 85 + 8 + the 8 window tests (at ed150e9). Its last step failed only because the recipe hardcodes `target/release/stepv`, while this build used `CARGO_TARGET_DIR`. `scripts/test-viewer.sh <that build>` → exit 0, with every check `ok` (both themes, software fallbacks, pick, measure, section, `--frames` on every fixture, failed topology).
2 tasks done
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
## Description Fixes #104. The Viewer (Linux, lavapipe) job's window tests intermittently failed with `winit EventLoopError … Failed to open connection to X server`. **Root cause:** Xvfb was started by `xvfb-run` without `-noreset`. An X server *resets* whenever its last client disconnects, and a connection that arrives during the reset is dropped. `scripts/test-window-tests.sh` runs the 14 window tests in parallel under one `xvfb-run`, and each `stepv view` is its own short-lived client. When all the running clients had closed at the same moment that another test's stepv connected, winit's `XOpenDisplay` failed. The GPU viewer then fell back to software for the wrong reason, and the test's note assertion (tests/cache.rs:1034) failed. **Ruled out:** - *Start race:* `xvfb-run` starts the command only after Xvfb signals readiness (SIGUSR1). Each failure was mid-suite, about 21 s in, after other tests had already connected. - *Server dying:* the same server served the software fallback in the same test, which drew and passed. - *Connection limit:* there are at most 4 clients at once, against Xvfb's 256. - *Display shared with another server:* there is one `xvfb-run -a` per step, run in sequence. - *#84 watchdog:* it kills the kernel only, never X. **Occurrences (kernel.yml run history):** 38337928702 (#103), 38362262033 (#98), 38377606897 (main push), 38378915656, 38848855133. Each time it was the same test and the same error. ## Type of Change - [x] `fix` -- Bug fix - [x] `ci` -- CI/CD pipeline changes ## Changes Made - `scripts/test-linux-viewer.sh`: one `xvfb <size> <cmd>` helper, `xvfb-run -a -s "-screen 0 <size>x24 -noreset"`, used for all three Xvfb steps (window tests, `test-viewer.sh`, no-GPU fallback). There are no sleeps, retries or skips. ## Demonstration These ran on Linux x86_64 (vm-dev), in CI's own container (`test-linux-viewer.sh`'s Debian trixie image and env). stepv was built once, then CI's window-test step was looped: `xvfb-run -a -s "<args>" scripts/test-window-tests.sh -q --release`. | Xvfb args | runs | pass | X-server failures | |---|---|---|---| | `-screen 0 1600x1000x24` (main) | 40 | 39 | **1**: run 38, `a_gpu_that_refuses_the_pipelines_falls_back_to_software`, `Failed to open connection to X server`, tests/cache.rs:1034, the same failure as CI | | `… -noreset` (this PR) | 120 | 118 | **0** | Neither of the 2 non-X failures after the fix was an X error. - One was observed as `Text file busy (os error 26)` (`closing_the_viewer_mid_load_cancels_the_kernel`, tests/cache.rs:992), from the tests' `script()` helper. That race has a different root cause and is filed as #117. - The other (`a_viewer_with_no_cache_leaves_no_artifact`, tests/cache.rs:862) failed on an exit-code/status mismatch, but its output wasn't kept. It is only **inferred** to be the same ETXTBSY race, because that test also execs a `script()` kernel. **The reset, deterministically:** one client sets a root-window property and disconnects, then a new client reads it back. - Default: `STEPV_104: no such atom on any window.` The server reset when its only client left. - `-noreset`: `STEPV_104(STRING) = "still-here"`. **Connections dropped during a reset:** 3 workers each opening and closing `xdpyinfo` in a loop, 5 × 3000 connections. With the default server, 3 were refused (`unable to open display ":99"`); with `-noreset`, 0. The Viewer (Linux, lavapipe) job passed on this PR. ## Changelog Entry ### Fixed - **The Linux viewer job's Xvfb no longer drops a window test's connection** ([#104](#104)): - Each Xvfb runs with `-noreset`. An X server resets when its last client disconnects and drops a connection that arrives during the reset. The window tests run in parallel, so one could connect just then and fail with `Failed to open connection to X server` Refs: #104
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.
Refs #63 (part 1 of 2; does not close it). Part 2 is #85.
Why split
All of #63 is well over the ~400-line cap: part 1 alone is +376/−22. Following the brief's own suggestion, this PR is the CLI half. Part 2, the viewer's outline-first window, is #85: it opens before the run finishes, shows the tree, a progress indicator and an honest message when the run is killed or times out, uses a cached artifact before any kernel event, and swaps in the meshes on
Done.What changed
Progress on a terminal (
Progressinsrc/main.rs). When stderr is a terminal, the run is streamed and one line there is redrawn in place:stepv: readingstepv: N parts · reading, as soon as the outline arrives, or at once from a cached outline artifact, before the kernel writes anything· transferring P%and· meshing P%, redrawn on each whole percentA pipe gets nothing on stderr. Stdout's JSON line is unchanged.
stepv viewwrites the outline artifact. Its load is streamed like a cached CLI run's, keyed on theFileIdtaken before the run, and the box is added after the mesh decodes.--no-cachewrites nothing.Docs. plan.md has a "Viewer and CLI show the outline and progress before the geometry (#54 step 5) #63 part 1" section (what's shown when, the exact messages, known limits with their issues), and the artifact section's "
viewdoes not write it yet" limit is removed. CHANGELOG has an entry.Tests (each fails on
origin/main)tests/progress.rs(stderr on a real pty vialibc::openpty):transferring 100%/meshing 100%, never a newline, and ends erased. The same run into a pipe writes no progress and gives the same JSON keys and values. Before the change:"stepv: reading" not in "".tests/cache.rsa_viewer_killed_after_its_outline_leaves_the_artifact: aviewwhose kernel stalls after the outline and is killed at a 10 s timeout leaves the artifact at the pre-run key, equal toocct::outline, with no box. Before the change the load wasn't streamed, the run completed, and a window opened ((-1, None)vs(4, "timeout")).STEPV_VIEW_SCREENSHOTnow makes such a window close itself, so a regression fails instead of hanging.Review round 1 (e15cb95)
posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC), and the slave is opened throughstd::fs::OpenOptions, which always setsO_CLOEXEC. SettingFD_CLOEXECafteropenptywould still leave a window in which a parallel test's spawn inherits them. The test asserts both flags.viewtest is bounded (viewer: a test-launchedstepv viewlikely reached ~38 GB within ~90 s and wedged the host #86) throughHome::view:--memory-mb 1024STEPV_VIEW_SCREENSHOTis set, so a window that opens closes itselfview --no-cacheleaves no artifact, while the same run with the cache on leaves one. It uses a kernel that crashes after a full run, so no window opens. A mutation that makesviewignore--no-cachefails it (--no-cache wrote an artifact).viewstores the box, equal to the summary's.Fix round 3 (a420b8b): no window session (#84's CI failure)
What failed: in nix's macOS builder (
_nixbld, with no window-server session),a_complete_view_adds_the_boxsawnull. That was the whole JSON report, not the box: the test panicked at its status assertion and never read the box.stepv viewran the kernel, then died insideeframe::run_native, where macOS's window layer aborts a process that has no session, and stdout's report died with it.Fix (option A, decided):
view::sessionchecks before the kernel. On macOS it usesCGSessionCopyCurrentDictionary; elsewhere on Unix,DISPLAYorWAYLAND_DISPLAY. With no session,viewfails at once: exit 3,error,"no window session: …"with the reason, and the header metadata.Tests:
STEPV_VIEW_TEST_NO_SESSIONhook, plus noDISPLAY),viewfails that way and never starts the kernel. It fails without the check.viewtests that need a window are#[ignore = "needs a window session; run by just view-test"].scripts/test-window-tests.shruns them with--ignored, and fails unless every one of them ran and passed.just view-testin kernel.yml's "GPU viewer on Metal" step, and under Xvfb in the "Viewer (Linux, lavapipe)" job (scripts/test-linux-viewer.sh).f391227: the first CI run of
a420b8bfaileda_terminal_sees_the_parts_and_each_stage_and_stdout_is_unchangedin nix's macOS sandbox. There the kernel's sandbox cannot nest (macos-outer), and stepv warns about it on stderr after erasing the progress line, which is the documented behavior. The test had forbidden any newline at all. It now checks the rule itself: no newline while redrawing, the erase right after the last redraw, and no progress after it.CI at f391227 runs the window tests on both platforms: Kernel (macos-15), in its "GPU viewer on Metal" step (
scripts/test-window-tests.sh), and Viewer (Linux, lavapipe), under Xvfb, each with4 passed; 0 failed. Every check is green.Gate
nix develop -c sh -c 'cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test'→ exit 0 (at f391227)nix build -L --no-link .#checks.aarch64-darwin.nextest→ exit 0 (246 passed, 7 skipped: the 3 existing#[ignore]s and the 4 window tests; at f391227)