Repository navigation
fix(cli): attach parent console on Windows so CLI output appears (#364) - #367
Merged
Merged
Conversation
The release Windows binary is built with `windows_subsystem = "windows"`, which stops a console flashing on tray launch but also leaves the process with no console attached — so every CLI path (`help`, `status`, `log`, argument errors) wrote to a closed handle and printed nothing. Latent until Scoop packaging (#359) first put `entracte` on PATH. Extract the argv dispatch out of `main.rs` into a pure `cli::classify` returning an `Invocation` enum, with `produces_console_output()` marking the printing paths. On Windows only, attach to the parent console via `AttachConsole(ATTACH_PARENT_PROCESS)` before those paths run, never on the tray-app fall-through (that would flash a console on Explorer launch). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0192uQGtxemm5efjCrjZs6Tn
Contributor
🔍 Advisory audit reportThese checks don't block merges — they surface drift in dependencies, licensing, and external links. cargo-deny✅ clean (advisories, bans, licenses, sources) lychee (broken links)✅ all links resolve npm audit✅ no high-severity vulnerabilities |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #367 +/- ##
==========================================
+ Coverage 89.69% 89.72% +0.02%
==========================================
Files 147 147
Lines 25495 25542 +47
Branches 861 861
==========================================
+ Hits 22868 22917 +49
+ Misses 2601 2599 -2
Partials 26 26
🚀 New features to boost your workflow:
|
Contributor
📖 Docs preview✅ Built and deployed for commit
Posted by docs-preview.yml — updates in place on every push. |
drmowinckels
added a commit
that referenced
this pull request
Oct 5, 2026
#367 fixed `entracte help` / `status` printing into a closed handle on Windows but shipped without a changelog entry, and #361's Scoop entry had been carrying the caveat that those commands were still silent — which that fix made untrue. Removing the stale caveat left the fix undocumented, so record it on its own. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
@drmowinckels — for review, not auto-merged (nightly triage opens issue PRs OPEN for a human).
Closes #364
Root cause
The release Windows binary is built with
windows_subsystem = "windows"(src-tauri/src/main.rs:2) so the tray app doesn't flash a console. The side effect is that the process never attaches to the console it was invoked from, so every CLI code path —help,status/profile/settings,log, and theeprintln!argument-error path — writes to a closed handle and prints nothing. It was latent until Scoop packaging (#359) first putentracteonPATH.What changed
cli.rs— extracted the argv dispatch that lived inline inmain.rsinto a purecli::classify(argv) -> Invocation, withInvocation::produces_console_output()marking the paths that print (everything except the tray-app fall-through). Behaviour mirrors the old dispatch exactly (help/logrecognised ahead of the parser; locally-runnable commands via IPC; parse errors print + exit 2; otherwise launch the app).cli.rs— added#[cfg(windows)] attach_parent_console(), a thinAttachConsole(ATTACH_PARENT_PROCESS)wrapper. Per.github/AGENTS.mdthe pure decision is unit-tested on every OS and only the FFI line is uncovered (the sanctioned OS-FFI patch-coverage bypass).main.rs— callsclassify, then on Windows only attaches the console whenproduces_console_output()— never onInvocation::LaunchApp, so launching from Explorer still shows no console window.Cargo.toml— added theWin32_System_Consolefeature to the already-present Windows-onlywindows-sysdependency (whereAttachConsole/ATTACH_PARENT_PROCESSlive).Tests (ship with the code, same PR)
New un-gated tests in
cli.rscovering everyInvocationvariant and bothproduces_console_output()outcomes:classify_help_variants_are_help_and_print—help/-h/--help→Invocation::Help, prints.classify_log_is_log_and_prints—log→Invocation::Log, prints.classify_local_command_prints—status→Invocation::Local(Status), prints.classify_quick_flags_are_local_and_print—--profile=→Invocation::Local(Quick), prints.classify_parse_error_still_prints— unknown command →Invocation::ParseError, prints.classify_no_command_launches_app_without_console— no args →Invocation::LaunchApp, does not attach a console (the guard that stops the Explorer-launch console flash).Verification
Ran locally on Linux:
cargo fmt --check✅cargo clippy --all-targets -- -D warnings✅cargo test --lib— allclitests pass (30/30, incl. the 6 new). The only suite failure isscheduler::commands::backup::tests::commit_stage_surfaces_metadata_error, which is unrelated to this change: itchmod 0o000s a dir and expectsPermissionDenied, but this sandbox runs as root, which bypasses permission bits. It passes on CI's non-root runners.Not verifiable from this Linux environment, left to CI / your check:
attach_parent_console+ thewindows-sysfeature) only compiles on the Windows CI matrix leg — the same as all existingwindows-sysFFI in this repo, none of which compiles on the Ubuntu leg. The feature name andAttachConsole/ATTACH_PARENT_PROCESSsignatures were checked against the vendoredwindows-sys0.59 source.knip/cspellwere N/A: this is a Rust-only diff,knipanalyses TS, andcspell's glob ismd,ts,tsx(not.rs), so neither result can change.Residual risk / notes
#364's "Done when" also asks to remove a CLI caveat fromdocs/guide/cli.mdand the Scoop/install guide. Those caveats are not onmain— they live in the still-open Scoop PR feat(packaging): install Entracte with Scoop on Windows (#359) #361. Nothing to remove here; that cleanup belongs with feat(packaging): install Entracte with Scoop on Windows (#359) #361 when it lands.AttachConsoleis the standard mitigation and matches what most Rust GUI+CLI binaries do.🤖 Generated with Claude Code
https://claude.ai/code/session_0192uQGtxemm5efjCrjZs6Tn
Generated by Claude Code