Skip to content

Treemap revamp: framed folders, open in place, smooth navigation - #30

Open
horus-leonardo wants to merge 16 commits into
phalladar:mainfrom
horus-leonardo:feat/treemap-revamp
Open

horus-leonardo wants to merge 16 commits into
phalladar:mainfrom
horus-leonardo:feat/treemap-revamp

Conversation

@horus-leonardo

Copy link
Copy Markdown
Contributor

Summary

I'm always short on disk space, and I open MacDirStat almost every day to free some and check what matters. I made these changes so it could be my daily driver.

This PR reworks the treemap. Folders become frames with a title, and you can open them in place, select them, and drill in with an animation. It builds on choices you already made: your squarify layout, your ten categories and your selection dim all stay.

Addresses #22. The detail levels come from that issue, which you called a fair request, so take them as one possible answer.

One dependency to know about: this branch drops the size picker's side effect of taking you from the welcome screen back to the treemap. #28 replaces it with an explicit Back button. If you take this branch, it works best together with #28. If you'd rather not take #28, tell me and I'll keep the old path here instead.

The PR is cut into slices that you can take separately. You can take all of it, take some slices, change anything, or decline it, with no hard feelings.

main This PR
main: the treemap today revamp: framed folders with titles in light mode

Same folder, same window size.

Dark mode revamp in dark mode

At a glance

#28 and #29 conflict lightly with this branch. If either goes in, I'll rebase this one.


Slices

The letters are stable IDs, so we can say "take A, B, C, drop F".

A · Linear squarify (no visible change)

Your squarify loop stays. The row keeps a running sum, min and max, so each candidate costs O(1) instead of a pass over the row. Children are sorted and summed in one pass, and zero sizes stay out, since they make the worst ratio infinite.

On / (55,220 items) the layout goes from 1,300 ms to 352 ms. Depends on nothing; it could be its own PR.

B · Framed folders, detail level, open and close (the core)

Main draws all 12 levels at once, so a big disk is thousands of squares, and a folder can't be selected as a whole. #22 asked to see the big folders on the first few levels.

detail level 1 on a whole disk detail level 3 on a whole disk

Level 1 and level 3 on a whole disk.

  • Detail level 1 to 8, default 3: two levels open and the third closed, like SpaceSniffer. Opening a folder by hand can go down to 32 levels.
  • Room is the only rule: 110×70 pt to open by level, 46×40 pt by hand, 60×36 pt for a title.
  • A folder opened or closed by hand keeps that state until a new scan or View ▸ Collapse All.
  • Items under 144 pt² gather into one "N smaller items" block instead of vanishing.
  • The shown folder isn't drawn, since the breadcrumb names it. The new state lives in AppState, next to your sizeMetric.

Every visual slice needs this one.

C + D · Look and color modes

Your categories now use system colors on the window background, so they follow light, dark and Increase Contrast. A folder gets its own shape, so it no longer reads as a lighter file.

Color by Folder
  • A folder is a titled frame, or a block with a tab when small. A closed folder shows a thin category bar.
  • Items are one fill with rounded, pixel-snapped edges and 1 pt gaps, instead of a fill plus a stroke.
  • Nested frames get 5% darker per level in light and 3% lighter in dark, instead of 8% darker, which reaches black within two levels.
  • Files get a light gradient and 11 pt labels. Smaller-items blocks are striped, and Increase Contrast outlines everything.
  • Color by Folder gives each child of the shown folder its own color, useful when most of a disk is "Other".

A folder is not colored by its main category, because a folder of 51% video and 49% code would show as video.

Needs B. D can be dropped alone.

E · Click, open in place, drill down

Like SpaceSniffer, a single click opens a folder, so you can go 3 levels down in one folder and 10 in another.

a folder opened in place and selected
  • Clicking a closed folder opens it in place and selects it, if it has room and contents. ▾ closes it.
  • A click acts at once instead of waiting to rule out a double click. A double click drills into what the first click hit, except an empty folder.
  • A smaller-items block selects its folder and has no Move to Trash.

Needs B.

F · Transitions

Main already wraps navigation in withAnimation, but a Canvas draws each frame from scratch, so nothing moves. This slice makes that intent visible.

  • Drill, Back, breadcrumb, open and close animate for 250 ms, with items moving, growing or shrinking to their new place.
  • Resizes and setting changes stay instant, and so does everything under Reduce Motion.
  • Nothing runs while idle, and an interrupted transition starts from where it is.

Needs B. It can be dropped whole.

G · Selection: your dim, with a ring that travels

Your dim stays, restyled to match the new shapes.

folder selected with dim and ring, hover card
  • The 0.55 black scrim and white stroke become a lighter scrim cut to the rounded shape, an accent ring and a shadow. A selected file dims nothing.
  • The ring travels to the next selection. It's about 60 lines and easy to remove.
  • A folder hidden inside a closed one, picked in the sidebar, rings its nearest visible ancestor.

Needs B.

H · Hover card and status bar

Main shows the hovered item only in the status bar. A card beside the cursor adds the category mix without crowding the treemap.

file hover card folder hover card

A file card, and a folder card.

  • The card shows size, file count and path, and for folders up to 4 category rows, with the rest folded into "Other types". A smaller-items card says what a double click opens.
  • When nothing is hovered, the status bar shows the volume: "Macintosh HD · 782 GB used · 81.9 GB free".

Needs B.

I · Show Folders off: main's flat look, refreshed

Some people will prefer main's flat look. Folders become undrawn groups, as your layout engine already emits them, so selection and the dim work without a special path.

Show Folders off, Color by Type Show Folders off, Color by Folder

  • Only files and smaller-items blocks are drawn, 1 pt apart. The detail controls are disabled, and folders opened by hand keep their state for when folders come back.
  • Laying out / takes about 44 ms for 16,143 items.

Needs B and C.

J · VoiceOver

Main's Canvas is a single element to VoiceOver. One element per item would flood it, so the list is capped.

  • Every folder plus the 200 largest other items, read like "Library, folder, 266 GB, closed", with Open/Close and Enter actions.

Needs B.

K · Sidebar sync

Main expands the sidebar on every selection, which with open in place would mean on every click.

drilled in: breadcrumb pills and the sidebar expanded to the folder
  • Only navigation moves the sidebar: drill, breadcrumb, Back, and picks from the sidebar or the skipped-folders list. Drilling also expands the folder.

Independent.

L · Toolbar, View menu, breadcrumb

With drill-down, navigation and view controls are separate jobs, so they sit on separate sides of the toolbar. ⌘+ and ⌘− now mean detail, so the zoom buttons go; scroll and pinch zoom stay.

the View menu
  • Back is always in the toolbar and disabled at the root, so the toolbar doesn't relayout on every drill.
  • "Scan Drive" becomes "New Scan". Rescan covers the shown folder, and ⇧⌘R rescans everything.
  • The View menu gets detail, color, Show Folders, Back, Rescan and the inspector, with shortcuts, plus Actual Size ⌘0. ⌘= also means More Detail.
  • Every control has a tooltip, shown after 400 ms. The breadcrumb becomes pills, and the treemap controls are disabled until there's a scan.

Detail, color and Show Folders need B, D and I; the rest stands alone.

M + N + O · Empty states, inspector, small fixes

The empty states and the inspector follow the same small, quiet style as the rest of macOS.

fresh launch: welcome screen, small No Scan and No Selection empty states, treemap controls disabled

Fresh launch: small empty states, treemap controls disabled.

  • Empty states become a small icon, "No Scan" or "No Selection", and what to do.
  • The inspector leads with one large size and groups the rest, like Finder's Get Info. Paths truncate in the middle, like Finder.
  • The banner's "Show Folders" button becomes "List Skipped Folders…", so it doesn't clash with the new toggle.
  • The inspector animates again. Toggle the inspector without animation to avoid a hang on macOS 27 #27 turned the animation off because it hung AppKit on macOS 27 while the treemap has a context menu. That no longer happens on 27.2.1, so the workaround and its CLAUDE.md note are gone.

Each piece stands alone. The inspector restyle conflicts with #29.

P + Q · Performance, tests, docs
  • The treemap canvas renders off the main thread.
  • Signposts plus benchmark and snapshot tests, which run only when an environment variable is set. Dropping them changes no behavior.
  • Four new test files. README and CLAUDE.md describe the new behavior.

Commits

16 commits, each one builds and passes the tests on its own. Most map to one slice; a few carry part of a neighbor where splitting them wouldn't build.

  1. Make squarify linear and add treemap layout and draw signposts (A)
  2. Lay out the treemap as framed folders with a detail level (B)
  3. Draw framed folders with system colors and two color modes (C, D)
  4. Open folders in place on click and explain items on hover (E, H)
  5. Draw treemap edges once, with continuous corners and exact gaps (C)
  6. Animate opening folders and navigating the treemap (F)
  7. Reorganize the toolbar and add treemap commands to the View menu (L)
  8. Add a Show Folders switch that draws the treemap without frames (I)
  9. Expose treemap folders and the largest items to VoiceOver (J)
  10. Give toolbar controls tooltips and make the empty states quiet (L, M)
  11. Restore the selection dim around folders with a ring that travels (G)
  12. Emit folders as undrawn groups when folders are hidden (I)
  13. Keep the selection dim through transitions and open only when it can (G, E)
  14. Move the sidebar only on navigation (K)
  15. Give the inspector a hierarchy and animate it again (N, O)
  16. Trim the treemap code, render off the main thread, and update docs (P, Q)

Defaults I picked, yours to change

Show Folders on, detail level 3, Color by Type, a click that opens, 250 ms transitions, 400 ms tooltips, and Rescan of the shown folder.

Left alone on purpose

  • Two free-space numbers. The status bar reads what Finder shows, and the welcome screen reads volumeAvailableCapacity. Which one is right is your call.
  • Shared view state. Detail, color mode and Show Folders apply to every window, like your size metric.

Testing

swift test passes 75 tests, and swift build has no warnings.


Thanks for MacDirStat. It was a pleasure to build on. Take all of this, some slices, change anything, or close it; any of those is fine, and I'm glad to split out a slice or rebase on request.

🤖 Generated with Claude Code

horus-leonardo and others added 16 commits November 26, 2026 18:28
The row keeps a running sum, min and max, so each candidate costs O(1)
instead of a pass over the row. Signposts mark layout and draw for
Instruments, and an env-gated benchmark times layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Folders open by detail level (1-8, default 3) and room, or by hand, and
small children gather into one smaller-items block. The state lives in
AppState; children are sorted and summed in one pass, zero sizes left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Categories use system colors on the window background, so they follow
light, dark and Increase Contrast. Color by Folder gives each child of
the shown folder its own color.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A click acts at once: it opens a closed folder in place and selects it,
and the chevron closes it. A double click drills into what the first
click hit. A card beside the cursor shows size, path and makeup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One fill per item with rounded, pixel-snapped edges and 1 pt gaps
replaces a stroke that antialiased twice and looked jagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drill, Back, breadcrumb, open and close move items to their new place
over 250 ms. Idle costs nothing, Reduce Motion stays instant, and fading
items go without text so the frames stay fast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Navigation sits on the left and view controls on the right. The View
menu gets detail, color, Back, Rescan and the inspector, calling the
shared AppState.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Off, only files and smaller-items blocks are drawn, one gap apart, for
those who prefer the flat look. One spacing rule now covers frames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every folder plus the 200 largest other items, with Open, Close and
Enter actions, rebuilt only when the layout changes. README and
CLAUDE.md describe the new treemap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every control has a tooltip and tree controls stay off without a scan.
Back is disabled instead of removed so the toolbar keeps still. Empty
columns show a small icon, a title and what to do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lighter scrim cut to the rounded shape, an accent ring and a shadow.
Only the selected folder's own item dims, and the ring travels to the
next selection. Dark mode lifts each nested frame instead of darkening.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without folders shown, folders become groups the renderer, hit testing,
transitions and VoiceOver skip, so selection needs no special path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
During a transition the ring and dim wait at the destination, and a
click opens a folder in place only when it has room and contents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting or opening in the treemap leaves the sidebar alone. Drilling
in expands the folder, and a pick from the skipped-folders list reveals it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inspector leads with one large size, and paths truncate in the
middle like Finder. macOS 27.2.1 no longer hangs, so the unanimated
toggle and its CLAUDE.md note go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete dead state and duplicated snapping, keep only timing in the
benchmark, rasterize the base canvas asynchronously, match the README,
and tighten comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant