Repository navigation
Link the sidebar and treemap selections, with size sparklines in the sidebar - #23
Conversation
computeAggregates now also sums bytes per category, so categoryBreakdown reads stored totals instead of walking the subtree on every call. The inspector calls it on each selection, and the sidebar sparklines will call it once per visible row. On a synthetic tree of 1.37M files and 137k folders (swiftc -O): - categoryBreakdown on the root: 41 ms -> 0.2 µs per call - computeAggregates: 27 ms -> 35 ms - memory: +25 MB (+8%) File and allocated sizes share one array, so a node grows from 184 to 192 bytes and stays in the same malloc size class; with two arrays it crossed into the next one. Categories with zero bytes are no longer listed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting a folder in the sidebar outlines it in the treemap and dims everything outside it; if the folder is outside the treemap's current root, the treemap moves to the folder's parent. Clicking in the treemap expands the sidebar down to the item's folder and scrolls to it. A file selects its folder's row while the inspector keeps showing the file. OutlineGroup can't be expanded or scrolled programmatically, so the sidebar is now a List of DisclosureGroups bound to a set of expanded folders in AppState. Rows keep native chevrons, arrow keys and outline accessibility. Double-click or Return on a row drills the treemap into the folder, and the context menu offers Reveal in Finder, Copy Path and Show in Treemap. Collapsing a folder that hides the selection selects that folder, as in Finder. The selection outline moved from the base canvas to its own overlay, so changing the selection doesn't redraw the treemap. Reveal in Finder and Copy Path moved into FileActions, now shared by three menus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each row gets a small bar: its length is the folder's share of its parent, split by file category in the treemap's colors, so you can see where the space goes without opening every folder. It reads the per-category totals stored by computeAggregates. The sparkline and a fixed-width size column take about 50 pt, so the sidebar's ideal width goes from 260 to 300 pt, and the folder name keeps layout priority so deep rows don't truncate it to nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
phalladar
left a comment
There was a problem hiding this comment.
Thanks @horus-leonardo, this is a great addition! Linking the sidebar and treemap makes the app much easier to navigate, and the per-category totals are a nice win for the inspector. I built it locally, ran the tests, and tried the linked selection in the app; it works well.
Two small things I'd like changed before merging, both performance:
-
FileCategory.indexruns a linear search overallCasesfor every file incomputeAggregates.allCaseslikely allocates a fresh array on each call, which probably accounts for most of the 27 → 35 ms slowdown. Aswitch, or a lookup cached in astatic let, should get most of that back. -
revealInTreewrites toexpandedIDson every selection, even when the ancestors are already expanded. Any mutation of an@Observableproperty notifies its observers, so every treemap click redraws every visibleDisclosureGrouprow. That gets noticeable on large expanded trees. Checkingcontainsbeforeinsert, or building the new set and assigning it only when it differs, would avoid it.
Non-blocking, just thoughts:
- Once a folder is selected, the dimming stays until the selection changes. It might be worth letting Esc or a click on empty space clear it.
- When a file is selected, clicking its folder's row does nothing and the inspector keeps showing the file. I see that's deliberate, but some users may expect to see the folder.
Happy to approve once the two fixes are in. Thanks again!
Any write to an @observable property notifies its observers, so inserting ids that were already present made every treemap click redraw every visible sidebar row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Esc selects the folder the treemap shows, which removes the dimming around a selected folder. Clicking the sidebar row of a selected file's folder now selects the folder. The selection setter ignored the row's own id to keep the file selected, but the List only writes the selection on a click, so the guard only blocked that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review! Pushed two commits:
On
The lookup costs about nothing; the compiler doesn't allocate Tested on macOS 27 with SDK 15 and SDK 26 builds. |
phalladar
left a comment
There was a problem hiding this comment.
Thanks @horus-leonardo, the updates look great, and thanks for measuring the FileCategory.index change. You're right that the lookup costs nothing, so leaving it as is makes sense.
I tested the new build in the app, and everything passed:
- Clicking a file deep in the treemap expands and scrolls the sidebar to its folder, and the inspector keeps showing the file.
- Clicking a selected file's folder row selects the folder, with the outline and dimming.
- Esc clears the dimming.
- Esc still cancels a scan in progress.
Merging now. Thanks again for the contribution, it's a really nice improvement to the app!
Closes #21. Three commits: per-category totals, linked selection, sparklines.
What changes
Implementation notes
ListofDisclosureGroups bound toexpandedIDsinAppState.OutlineGroupcan't be expanded or scrolled programmatically, which the treemap → sidebar direction needs. Native chevrons, ←/→ and outline accessibility are kept.computeAggregatesstores bytes per category in each folder, so the sparklines and the inspector's breakdown stop walking the subtree.FileActions, shared by the inspector, the sidebar and the treemap menus.Measurements
Synthetic tree of 1.37M files and 137k folders,
swiftc -O:categoryBreakdownon the rootcomputeAggregatesFile and allocated sizes share one array, so a node grows from 184 to 192 bytes and stays in the same malloc size class.
Behavior changes
Validation
swift buildandswift test.vtool: revealing and scrolling to a folder 10 levels deep from a treemap click, ←/→, collapsing an ancestor of the selection, double-click/Return drill-down, and the context menu.🤖 Generated with Claude Code