# Changelog
All notable changes to the `litho` crate and binaries are documented here.
## Unreleased
### Docs
- **README** — user-focused quick start + banner; technical content moved to `docs/developer-docs.md`
### Changed (platform segregation)
- **`platform/traits`** — `DeviceReader`/`DeviceWriter`, `DeviceInventory`, `DevicePathOps`, `DeviceSafety`, `VolumeOps`, `PrivilegeOps`, umbrella `Platform`
- **Per-OS modules** — `platform/{linux,windows,macos}/` with `io`, `inventory`, `path`, `safety`, `volume`, `privilege`
- **`devices.rs`** — thin façade over `platform::Active`; portable block-size policy only
- **Windows writer** — holds `VolumeOps::Guard` (`PhysicalDriveIoSession`); `preflight_for_io` unmounts without long-lived locks
- **TUI privilege** — re-exports `liblitho::platform` elevation façade
- **Plan** — `docs/platform-segregation-plan.md`
### Changed (rust-skills review follow-up)
- **`flash` / `clone` API** — path arguments are `&str` (no owned `String` at the library boundary).
- **`.xz` flash** — stream-decompress into the write loop; removed temp-file path and `tempfile` dependency.
- **`DeviceError` (`thiserror`)** — typed validation/mount errors (`InvalidPath`, `SystemDisk`, `Busy`, `UnmountFailed`, `NotListed`, `Unsupported`, `QueryFailed`).
- **Dependencies** — removed unused `openssl` and `tokio`; TUI operations use `std::thread`.
- **Unsafe** — `// SAFETY:` / `# Safety` documentation on all `unsafe` sites.
- **Linux device enum** — simplified sysfs walk in `get_storage_devices`; `is_removable_device` is Linux-only (`cfg`).
### Added
- **CLI output modes** — `-o terminal|gui` (`--output-mode`): terminal progress bar (`=` / `-`) or GUI-friendly `@progress` / `@error` / `@done` line protocol.
- **`cli_output` / `cli_simulate` modules** — CLI-only formatting and simulated flash/clone for output testing (real `liblitho` I/O not wired in CLI yet).
- **`litho-tui`** — interactive terminal UI with flash/clone mode selection, device and file pickers, progress display, and responsive layout (minimum 60×24 terminal).
- **TUI privilege flow** — runtime root detection; `pkexec` re-launch with `--mode`, `--device`, and `--image` pre-filled (`--start` never passed by elevation).
- **TUI file logging** — default log path `~/.cache/litho/litho-tui.log`; `--log-file` and `--log-level` CLI options.
- **`OperationProgress` API** — structured progress events (`OperationPhase`, bytes, percentage, message) replacing string-based pub-sub.
- **`devices::device_size_bytes()`** — read device size from sysfs for accurate clone progress.
### Changed
- **CLI `litho` binary** — removed `env_logger` / `--json-progress`; user-facing output via `println!` / `eprintln!`; proper exit codes (`0` / `1`).
- **Library progress** — single `FnMut(OperationProgress)` callback; removed `simple-pub-sub` / `mio` dependencies.
- **Clone progress** — percentage now derived from bytes written vs device size (was incorrectly `bytes / 100`).
- **CLI `main`** — synchronous; removed `--sockfile` / pub-sub integration.
- **TUI module layout** — split into `app`, `ui`, `layout`, `helpers`, `privilege`, `logging`, `launch`.
- **pkexec relaunch** — uses `exec()` with inherited stdio and preserved `TERM` / locale env vars to keep the controlling TTY.
### Fixed
- **CLI clone** — correct argument order (`device`, then `file`).
- **TUI terminal errors** — TTY checks, logged terminal init/shutdown failures, terminal recovery after failed elevation.
### Added (alignment pass — pre real TUI I/O)
- Stronger polkit detection (`find_polkit_auth_agent` + `pkexec` on PATH)
- TUI logging: `--log-file=-`, `LITHO_LOG_STDERR=1`, 5 MiB log rotation
- Device list refresh log when `--device` pre-fills launch
- Footer shortcut hints on tall terminals; `scripts/record-demo.sh` for P11
- Extra tests: clap launch parsing, clone-style progress %, layout hints
### Added (remaining work P1–P10)
- **TUI** — `tui/operation.rs` operation runner (simulated progress; real `liblitho` I/O disabled in TUI)
- **TUI** — focus **Start** when launch args pre-fill; polkit hint in header; richer startup logs
- **CLI** — `--json-progress` emits JSON `OperationProgress` lines on stdout (removed in favor of `--output-mode gui`)
- **Tests** — layout and launch unit tests; `OperationProgress` derives `Serialize`
### Known limitations
- **CLI `litho`** — flash/clone are simulated; real `liblitho::flash` / `clone` wiring pending.
- **TUI** — flash/clone are simulated; use the library for real I/O until CLI/TUI wiring is complete.
- **Device vendor** — NVMe drives often lack `/sys/block/.../device/vendor`; a warn-level log is expected.
- **Platform** — device enumeration and full E2E support are Linux-first; see `platform-support.md`.