hex/src/control/cli
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dax dc9401189f
Fix #1947: hex restart waits for the old Hex to exit before relaunching (#1949)
* Fix #1947: hex restart waits for the old Hex to exit before relaunching

* hex restart: watch the old process from before the quit, and keep a forwarder's wait

- `ExitWatch` takes the Windows SYNCHRONIZE handle while the old Hex still
  runs, before the restart is sent, and closes it on drop; Unix keeps the pid
  and polls liveness. `wait(timeout)` covers both, and `hex restart` waits on
  it instead of on the local API, whose discovery file is retracted earlier in
  the drain.
- `hex start` no longer treats an exited child as failure by itself: a Linux
  `hex app` forwards to the systemd unit (or a 2.3.1 install's handoff) and
  exits once the forward is accepted, so a successful forwarder keeps the
  ordinary 20 s wait. Any other exit gets a 2 s grace for a successor to
  answer, then fails with a message that fits why the child exited.
- docs: the pid-wait test is Unix only, and the Windows path is compiled in
  CI without one.

* the restart watch's test is Linux only

macOS never takes an ExitWatch (it relaunches itself), so the test must not
name one there; Windows waits on a process handle and is compiled only.

* start: treat a 2.3.1 install's handoff as a start in progress

A Windows `hex app` from a legacy layout starts the managed copy in the
background and exits, so that exit is not a failure. `legacy::will_take_over`
is the predicate `take_over` already uses, checked here before the spawn, so a
successful child keeps the ordinary 20 s wait instead of only the 2 s grace.

The comments now say where a handoff actually exits: Windows, since Linux's
legacy relaunch execs and never returns; Linux's forwarder is the systemd
unit.

* restart's watch: refuse pid 0, clamp the Windows timeout, and test it everywhere

- `ExitWatch::new` refuses pid 0 (on Unix `kill(0, …)` means the process
  group), and the Windows wait clamps to `u32::MAX - 1` so a huge timeout can
  never become INFINITE.
- The wait's test moves out of the Unix-only module and runs on Linux and
  Windows, with the child halves taken from this same test binary by `--exact`
  and an environment variable, as `desktop::process_exit` does. Check Windows
  runs it under nextest.
- The docs now name `control/cli/launch.rs` and say where the discovery file,
  Linux's service lock, and Windows' instance event really go relative to the
  process, and the wait test's Linux-and-Windows reach.
- `will_take_over` is Windows-only and asked before the spawn, which is the
  launch it describes.

* comments: spell out when the old Hex's locks and files go, per OS

On Linux the host worker's drop of the service Server joins before
LocalApi::shutdown removes the discovery file, so the lock goes first; on
Windows the file goes first, then the tray, and the instance event last, at
process exit. The test comment also names the parent's wait_with_output as the
reap.

* restart's watch: loop the Windows wait on a clock, and gate the child on a pipe

`WaitForSingleObject` timeouts are tick-quantized and can report a timeout
before the requested interval has passed, which made the test's elapsed-time
assertion flaky. The Windows branch now loops against an `Instant` deadline,
asks once more with no timeout when the clock says the time is up, and returns
false on `WAIT_FAILED`.

The test's child no longer sleeps: it blocks on one byte of stdin, which the
parent holds open while it takes the watch and closes to end it, so neither
case races the clock. It also asserts pid 0 is refused.
2026-11-17 23:14:08 -05:00
..
completions.rs make the labs card copy plain (#1929) 2026-11-16 22:32:02 -05:00
embedded.rs feat(cli): hex transcribe reads any common media file, with or without the app (#1799) 2026-11-13 13:14:15 -08:00
human.rs capture: keep all audio in long captures (#1795) (#1894) 2026-11-16 10:28:54 -05:00
launch.rs Fix #1947: hex restart waits for the old Hex to exit before relaunching (#1949) 2026-11-17 23:14:08 -05:00
prepare.rs feat(cli): hex transcribe reads any common media file, with or without the app (#1799) 2026-11-13 13:14:15 -08:00
progress.rs feat(cli): hex transcribe reads any common media file, with or without the app (#1799) 2026-11-13 13:14:15 -08:00
transcribe.rs capture: keep all audio in long captures (#1795) (#1894) 2026-11-16 10:28:54 -05:00