Skip to content

installer: scale APFS shrink time estimate (~1 min/GB) and show live progress - #159

Open
grierj wants to merge 1 commit into
OrchardLinux:mainfrom
grierj:feat/shrink-time-estimate-and-progress
Open

grierj wants to merge 1 commit into
OrchardLinux:mainfrom
grierj:feat/shrink-time-estimate-and-progress

Conversation

@grierj

@grierj grierj commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #157.

Changes

  • crates/flow/src/lib.rs, view.rs & tests.rs:
    • Add SplitAction (Shrink { gb }, Grow, PartitionOnly), SplitStage (Shrinking, Finishing), SplitProgress, split_action(), shrink_gb_for(), shrink_estimate_minutes() (SHRINK_MINUTES_PER_GB = 1), format_approx_minutes(), format_remaining_minutes(), and format_remaining_compact() (overflow-safe u128/u64 math).
    • Add splittable_bytes and ipados_container_bytes to Layout so shrink/grow/partition-only classification uses the actual APFS container size (including interrupted-shrink layouts).
    • Add Event::SplitProgress(SplitProgress) and progress: Option<SplitProgress> on State::Splitting.
    • Mark the link and companion connected (Link::Up, flow.companion = true) when adopting a running split (Event::SplitRunning) or receiving Event::SplitProgress, so reopening the installer shows live progress instead of a reconnect warning and routes refusals back to ChooseSplit rather than DFU.
  • crates/runtime/src/companion.rs:
    • Parse optional helper telemetry fields (observedCapacityBytes, apfsStep, startedAt, observedAt, stepIndex, plan.before, plan.steps, plan.targetBytes) tolerantly so partial/null/unexpected telemetry never breaks terminal completed/stopped/unknown handling.
    • Pair ETA rate calculations with helper timestamps (observedAt - startedAt) or a delta baseline on reopen instead of mixing lifetime released bytes with a fresh UI clock.
    • Track both locally started and adopted splits in SplitWatcher by device and operation ID, and process reconnect snapshots immediately so a split that finishes or stops during a disconnect always delivers its outcome.
  • crates/app/src/lib.rs & install_screens.rs:
    • Preserve self.since across transient Splitting/Reconnect screen transitions.
    • Show a size-scaled upfront estimate under the split bar on choose_split (~1 min per GB, depending on data layout).
    • Surface live GB shrunk, percent, step count, helper-backed elapsed time, live ETA, and a dedicated finishing state (advancing to step 3 instead of flashing the upfront estimate at 100%).
  • crates/cli/src/commands/install.rs:
    • Show size-scaled upfront estimates in after_row and State::Splitting (never printing 0 GB on resume), keep the live TTY status line within 80 columns, emit permanent progress milestones on non-TTY output, emit split-progress JSON events, and fail cleanly when a split is refused instead of hanging on ChooseSplit.
  • companion/App/App.swift:
    • Replace hardcoded "around 30 minutes" with direction-neutral "Shrinking can take around 1 minute per GB. Your computer shows how it's going.".

Verification

  • cargo test -p orchard-flow: 129 passed, 0 failed.
  • cargo test -p orchard-runtime: 112 passed, 0 failed (1 ignored).
  • cargo test -p orchard-cli -- commands::install: 21 passed, 0 failed.
  • cargo check --workspace --tests: passed cleanly.

@grierj
grierj force-pushed the feat/shrink-time-estimate-and-progress branch from 3011da4 to f8f2d0c Compare December 4, 2026 16:54
Large APFS shrinks (100+ GB) take well over an hour (~1 min/GB), so the
hardcoded 'around 30 minutes' estimate misled users into thinking the
operation had hung, and neither the GUI nor CLI surfaced the helper's
live step or byte progress.

- Compute upfront split action (shrink/grow/partition-only) from the
  actual APFS container size and show a size-based estimate (~1 min/GB)
  on the split picker and while splitting.
- Parse the helper's optional telemetry fields tolerantly into
  SplitProgress (released/total bytes, step count, finishing stage, and
  rate-paired elapsed time) without breaking terminal status handling.
- Track both locally started and adopted splits through reconnects so a
  split that finishes or stops during a disconnect always delivers its
  terminal outcome, and mark adopted splits connected so GUI/CLI show
  live progress instead of a reconnect warning.
- Surface live progress, paired ETA, and finishing state in the GUI and
  CLI (80-column-safe live TTY line, non-TTY milestones, JSON events,
  and clean exit on split refusal).
- Update companion app copy to avoid a fixed 30-minute claim.

Fixes OrchardLinux#157
Assisted-by: LLM
@grierj
grierj force-pushed the feat/shrink-time-estimate-and-progress branch from f8f2d0c to ccce9d0 Compare December 5, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installer: scale APFS shrink time estimate (~1 min/GB) and show live shrink progress

1 participant