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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,13 @@ and removes duplicate hardlinks.

## Switching volumes

Press `v` (or click **Volumes** beside the disk name in the side panel) to
bring up the volume picker. It lists every candidate volume mounted on the
system together with its free space, ordered fullest first, filtering out
pseudo-filesystems and duplicate btrfs/APFS mount points. Selecting any
entry resets the scan root directly to that volume.
Press `v`, or click the disk's name or **Volumes** beside it in the side
panel, to bring up the volume picker. When the scan is of a whole volume,
its crumb in the trail (`C:\` or `/`) opens it too. It lists every
candidate volume mounted on the system together with its free space,
ordered fullest first, filtering out pseudo-filesystems and duplicate
btrfs/APFS mount points. Selecting any entry resets the scan root directly
to that volume.

## The whole disk

Expand Down
7 changes: 7 additions & 0 deletions crates/disktree-app/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,13 @@ impl Disktree {
}
}

/// Whether the scanned root is itself a volume: there is nothing above
/// it to widen to, so the only way on from its crumb is another volume.
pub fn root_is_a_volume(&self) -> bool {
self.root_path.parent().is_none()
|| self.disk_root.as_deref() == Some(self.root_path.as_path())
}

/// Recompute "worth a look" from the tree on screen.
fn refresh_insights(&mut self) {
self.scanned_at = now_seconds();
Expand Down
36 changes: 36 additions & 0 deletions crates/disktree-app/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1844,3 +1844,39 @@ fn the_power_menu_offers_only_what_the_cpus_can_tell_apart(
draw(cx);
assert!(read(&view, cx, |app| app.power_menu.is_none()));
}

#[gpui_kit::test]
fn the_crumb_of_a_whole_volume_offers_the_other_volumes(
cx: &mut TestAppContext,
) {
cx.update(gpui_omarchy::init);
let temp = fixture();
let (view, cx) = view_over(temp.path(), cx);
draw(cx);
// A directory with a disk above it is not one: its crumb goes to the
// top of the scan, as it always did.
assert!(!read(&view, cx, Disktree::root_is_a_volume));
let crumb = cx.debug_bounds("root-crumb").expect("the root's crumb");
cx.simulate_click(crumb.center(), gpui_kit::Modifiers::none());
draw(cx);
assert!(!read(&view, cx, |app| app.volumes_open));

update(&view, cx, |app, cx| {
app.disk_root = Some(app.root_path.clone());
cx.notify();
});
assert!(read(&view, cx, Disktree::root_is_a_volume));
draw(cx);
let crumb = cx.debug_bounds("root-crumb").expect("the root's crumb");
cx.simulate_click(crumb.center(), gpui_kit::Modifiers::none());
draw(cx);
assert!(read(&view, cx, |app| app.volumes_open));
press(cx, "escape");
assert!(!read(&view, cx, |app| app.volumes_open));

// The disk's label in the panel is the same way on.
let label = cx.debug_bounds("disk-label").expect("the disk label");
cx.simulate_click(label.center(), gpui_kit::Modifiers::none());
draw(cx);
assert!(read(&view, cx, |app| app.volumes_open));
}
56 changes: 44 additions & 12 deletions crates/disktree-app/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,29 @@ fn tree_crumb(
cx: &Context<'_, Disktree>,
) -> gpui_kit::AnyElement {
let Some((&index, parent)) = path.split_last() else {
// The scanned root: no siblings in the tree to offer.
return widgets::crumb(id, label, current, cx)
.on_click(
cx.listener(move |this, _, _, cx| this.go_to(Vec::new(), cx)),
)
.into_any_element();
// The scanned root: no siblings in the tree to offer. Being there
// already, the crumb of a whole volume offers the other volumes
// instead, as a current crumb in the tree offers its siblings.
let volumes = current && app.root_is_a_volume();
let crumb = widgets::crumb(id, label, current, cx)
.debug_selector(|| "root-crumb".into())
.when(volumes, |crumb| {
crumb.hover(|style| style.bg(theme.hover_fill()))
})
.on_click(cx.listener(move |this, _, window, cx| {
if volumes {
this.open_volumes(cx);
this.apply_focus(window, cx);
} else {
this.go_to(Vec::new(), cx);
}
}));
return if volumes {
with_tooltip(crumb, "Scan another volume \u{00b7} v")
.into_any_element()
} else {
crumb.into_any_element()
};
};
let parent = parent.to_vec();
let open = app
Expand Down Expand Up @@ -2014,13 +2031,28 @@ fn disk_section(
.flex_row()
.items_center()
.gap(space::SM)
.child(widgets::eyebrow("Disk", cx))
.child(
.child(with_tooltip(
div()
.text_size(text::CAPTION)
.text_color(theme.secondary.opacity(0.6))
.child(device),
)
.id("disk-label")
.debug_selector(|| "disk-label".into())
.flex()
.flex_row()
.items_center()
.gap(space::SM)
.hover(|style| style.bg(theme.hover_fill()))
.on_click(cx.listener(|this, _, window, cx| {
this.open_volumes(cx);
this.apply_focus(window, cx);
}))
.child(widgets::eyebrow("Disk", cx))
.child(
div()
.text_size(text::CAPTION)
.text_color(theme.secondary.opacity(0.6))
.child(device),
),
"Scan another volume \u{00b7} v",
))
.child(div().flex_1())
.child(
button("volumes", "Volumes", ButtonVariant::Secondary, cx)
Expand Down