Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion companion/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private func splitting(minutes: UILabel) -> UIView {
width.priority = .defaultHigh
width.isActive = true
return column([badge(.accent, 0.08, fixed(Spinner(), 40, 40)),
heading("Splitting the storage", "This can take around 30 minutes. Your computer shows how it's going."),
heading("Splitting the storage", "Shrinking can take around 1 minute per GB. Your computer shows how it's going."),
minutes, box])
}

Expand Down
110 changes: 80 additions & 30 deletions crates/app/src/install_screens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::screens::{column, event_link, icon, paragraph, pressable, primary, se
use crate::theme::*;
use crate::Installer;
use gpui::{div, linear_color_stop, linear_gradient, prelude::*, px, Context, Div, FontWeight, MouseButton, SharedString};
use orchard_flow::{Account, Event, Flow, Layout, Link, SnapshotOffer, State, MIN_OMARCHY_GB};
use orchard_flow::{Account, Event, Flow, Layout, Link, SnapshotOffer, SplitAction, SplitProgress, State, MIN_OMARCHY_GB};
use std::time::Instant;

/// The text column's width on the full-width split screens (960 − 2 × 72).
Expand Down Expand Up @@ -400,13 +400,23 @@ fn choose_split(layout: &Layout, shown_gb: f32, approved: bool, flow: &Flow, stu
let snapshot = snapshot_box(layout, flow, seconds, cx);
// Little room, and no snapshot box that offers more: say how to get more.
let little = max < orchard_flow::RECOMMENDED_OMARCHY_GB && snapshot.is_none();
let slider = div()
let chosen = shown_gb.round() as u32;
let mut slider = div()
.w_full()
.flex()
.flex_col()
.gap(px(12.))
.child(split_labels(layout.total_gb - shown_gb.round() as u32, shown_gb.round() as u32))
.child(split_labels(layout.total_gb - chosen, chosen))
.child(split_bar(layout, shown_gb, if replaces { OmarchyNote::Replaces } else { OmarchyNote::None }, Some((focus, ring)), cx));
if let SplitAction::Shrink { gb } = orchard_flow::split_action(layout, chosen) {
let approx = orchard_flow::format_approx_minutes(orchard_flow::shrink_estimate_minutes(gb));
slider = slider.child(
div()
.text_size(px(12.))
.text_color(c(MUTED))
.child(orchard_flow::for_device(&format!("Shrinking iPadOS by {gb} GB typically takes {approx} (~1 min per GB, depending on data layout).")).to_owned()),
);
}
let mut col = div().w_full().flex().flex_col().gap(px(22.)).child(header("Split the storage", split_subtitle(), TITLE)).child(slider);
if let Some(snapshot) = snapshot {
col = col.child(snapshot);
Expand Down Expand Up @@ -518,7 +528,7 @@ fn no_room(layout: &Layout, flow: &Flow, seconds: f32, cx: &mut Context<Installe
}

/// The split's three steps (2.4, 2.4b, 2.5): done, now, later.
fn split_steps(lost: bool, grow: Option<bool>, seconds: f32) -> Div {
fn split_steps(lost: bool, action: Option<SplitAction>, replaces: bool, finishing: bool, seconds: f32) -> Div {
let row = |label: &'static str, state: u8, first: bool| {
let (color, weight) = match state {
0 => (c(SUBTITLE), FontWeight::NORMAL),
Expand Down Expand Up @@ -547,6 +557,13 @@ fn split_steps(lost: bool, grow: Option<bool>, seconds: f32) -> Div {
}
r
};
let resize_label = match action {
Some(SplitAction::Grow) => orchard_flow::for_device("Grow iPadOS"),
Some(SplitAction::Shrink { .. }) | None => orchard_flow::for_device("Shrink iPadOS"),
Some(SplitAction::PartitionOnly) if replaces => "Remove the old partitions",
Some(SplitAction::PartitionOnly) => "Update partitions",
};
let (resize_state, check_state) = if finishing { (0, 1) } else { (1, 2) };
div()
.w_full()
.flex()
Expand All @@ -555,48 +572,81 @@ fn split_steps(lost: bool, grow: Option<bool>, seconds: f32) -> Div {
.border_1()
.border_color(c(PANEL_LINE))
.child(row("Check storage", 0, true))
.child(row(match grow { Some(true) => orchard_flow::for_device("Grow iPadOS"), Some(false) => orchard_flow::for_device("Shrink iPadOS"), None => "Remove the old partitions" }, 1, false))
.child(row("Check the result", 2, false))
.child(row(resize_label, resize_state, false))
.child(row("Check the result", check_state, false))
}

fn minutes(since: Instant) -> u64 {
since.elapsed().as_secs() / 60
}

/// 2.4 / 2.4b / 2.5: splitting, after a relaunch, or the link lost.
/// `ipados`: iPadOS's size (GB) after and before the split, when known.
fn splitting(link: Link, reopened: bool, ipados: Option<(u32, u32)>, stuck: bool, since: Instant, seconds: f32) -> Div {
#[allow(clippy::too_many_arguments)]
fn splitting(link: Link, reopened: bool, layout: Option<&Layout>, omarchy_gb: u32, split_progress: Option<SplitProgress>, stuck: bool, since: Instant, seconds: f32) -> Div {
let lost = link == Link::Lost;
// Growing into removed partitions is quick; shrinking APFS takes long.
// None: the same size, only the old partitions go.
let grow = match ipados {
Some((after, before)) if after == before => None,
Some((after, before)) => Some(after > before),
None => Some(false),
};
let progress = div().w_full().flex().flex_col().gap(px(10.)).child(split_steps(lost, grow, seconds));
let action = layout.map(|l| orchard_flow::split_action(l, omarchy_gb));
let target_gb = layout.map(|l| l.total_gb.saturating_sub(omarchy_gb)).or_else(|| split_progress.and_then(|p| p.target_ipados_gb));
let replaces = layout.is_some_and(|l| !l.outside.is_empty());
let finishing = split_progress.is_some_and(|p| p.is_finishing());
let progress = div().w_full().flex().flex_col().gap(px(10.)).child(split_steps(lost, action, replaces, finishing, seconds));
if lost {
return column()
.gap(px(24.))
.child(header(orchard_flow::for_device("Reconnect your iPad"), orchard_flow::for_device("The connection to your iPad was lost. Plug it back in to continue."), RED))
.child(progress);
}
let subtitle = if reopened {
let subtitle = if finishing {
orchard_flow::for_device("iPadOS finished shrinking. Checking the storage and updating the partition table…").to_owned()
} else if reopened && split_progress.is_none() {
orchard_flow::for_device("The installer was closed while the storage was being split. Checking on your iPad…").to_owned()
} else {
match (ipados, grow) {
(Some((gb, _)), Some(true)) => orchard_flow::for_device(&format!("iPadOS is growing to {gb} GB. This takes a moment.")).to_owned(),
(Some((gb, _)), Some(false)) => orchard_flow::for_device(&format!("iPadOS is shrinking to {gb} GB. This can take around 30 minutes.")).to_owned(),
(Some(_), None) => format!("Removing the old {} partitions. This takes a moment.", sys()),
(None, _) => "This can take around 30 minutes.".to_owned(),
let remaining = split_progress.and_then(|p| p.remaining_minutes());
match (action, target_gb) {
(Some(SplitAction::Grow), Some(gb)) => orchard_flow::for_device(&format!("iPadOS is growing to {gb} GB. This takes a moment.")).to_owned(),
(Some(SplitAction::PartitionOnly), _) if replaces => format!("Removing the old {} partitions. This takes a moment.", sys()),
(Some(SplitAction::PartitionOnly), _) => "Updating the partition table. This takes a moment.".to_owned(),
(Some(SplitAction::Shrink { gb: shrink_gb }), Some(gb)) => {
if let Some(left) = remaining {
orchard_flow::for_device(&format!("iPadOS is shrinking to {gb} GB. {}.", orchard_flow::format_remaining_minutes(left))).to_owned()
} else {
let approx = orchard_flow::format_approx_minutes(orchard_flow::shrink_estimate_minutes(shrink_gb));
orchard_flow::for_device(&format!("iPadOS is shrinking to {gb} GB. This can take {approx} (~1 min per GB, depending on data layout).")).to_owned()
}
}
(_, Some(gb)) => {
if let Some(left) = remaining {
orchard_flow::for_device(&format!("iPadOS is shrinking to {gb} GB. {}.", orchard_flow::format_remaining_minutes(left))).to_owned()
} else {
orchard_flow::for_device(&format!("iPadOS is shrinking to {gb} GB. Shrinking typically takes around 1 minute per GB, depending on data layout.")).to_owned()
}
}
(_, None) => {
if let Some(left) = remaining {
format!("{}.", orchard_flow::format_remaining_minutes(left))
} else {
"Shrinking typically takes around 1 minute per GB, depending on data layout.".to_owned()
}
}
}
};
// Not designed beyond the example line: only what the window knows.
let status = format!("still working · {} min so far", minutes(since));
// Only after a minute (fading in), its place kept from the start so
// nothing moves (after a relaunch too).
let elapsed = split_progress.and_then(|p| p.elapsed_secs).map(|s| s / 60).unwrap_or_else(|| minutes(since));
let status = match split_progress {
Some(p) if p.is_finishing() => format!("finishing up · {elapsed} min"),
Some(p) => {
let done_gb = p.released_bytes as f64 / 1e9;
let total_gb = p.total_bytes as f64 / 1e9;
let pct = p.percent();
match (p.step, p.planned_steps) {
(Some(step), Some(total)) if total > 0 => format!("{done_gb:.1} / {total_gb:.1} GB ({pct}%) · step {step}/{total} · {elapsed} min"),
_ => format!("{done_gb:.1} / {total_gb:.1} GB ({pct}%) · {elapsed} min"),
}
}
None => format!("still working · {elapsed} min so far"),
};
// Visible immediately once live progress arrives; otherwise fades in after
// a minute, its place kept from the start so nothing moves.
let after = since.elapsed().as_secs_f32();
let visible = ((after - 60.) / 0.4).clamp(0., 1.);
let visible = if split_progress.is_some() { 1. } else { ((after - 60.) / 0.4).clamp(0., 1.) };
let liveness = div()
.opacity(visible)
.flex()
Expand Down Expand Up @@ -1381,10 +1431,10 @@ pub fn text_column(installer: &mut Installer, cx: &mut Context<Installer>) -> Op
choose_split(layout, shown, *approved, &flow, stuck, seconds, &focus, ring, cx).into_any_element()
}
}
State::Splitting { link, reopened, omarchy_gb, .. } => {
let ipados = installer.layout.as_ref().map(|l| (l.total_gb - omarchy_gb, l.ipados_gb));
State::Splitting { link, reopened, omarchy_gb, progress, .. } => {
let layout = installer.layout.clone();
let seconds = installer.started.elapsed().as_secs_f32();
splitting(*link, *reopened, ipados, installer.link_stuck(), installer.since, seconds).into_any_element()
splitting(*link, *reopened, layout.as_ref(), *omarchy_gb, *progress, installer.link_stuck(), installer.since, seconds).into_any_element()
}
State::SplitDone { omarchy_gb, .. } => {
let layout = installer.layout.clone();
Expand Down
11 changes: 10 additions & 1 deletion crates/app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,16 @@ impl Installer {
shown.device = device;
}
if shown.content != content {
self.since = now;
let same_work = matches!(
(shown.content, content),
(ScreenKind::Splitting | ScreenKind::SplittingReopened, ScreenKind::Reconnect)
| (ScreenKind::Reconnect, ScreenKind::Splitting | ScreenKind::SplittingReopened)
| (ScreenKind::Installing, ScreenKind::Reconnect)
| (ScreenKind::Reconnect, ScreenKind::Installing)
);
if !same_work {
self.since = now;
}
self.refocus = true;
// A new screen closes the trouble dialog; focus starts afresh.
self.trouble = false;
Expand Down
Loading
Loading