Skip to content

Commit 3ee1bf3

Browse files
corepunchclaude
andcommitted
Diskmap: fix the #59 QA pass; pie sectors brighten in place on hover
Correctness and safety - StorageScan results keep their types in Lua: flags are booleans (a failed command was truthy, and every scanned root was "partial"), counts are integers, strings keep embedded NULs. Git state, Last opened and the rebuildable totals work again. - The collector and the Review sheet refuse Keychains, Preferences, Mail, Messages, cloud roots, media libraries, other users' homes, /tmp and /private/var, compared without case and through the root's links. - A root that is a volume's mount point is capped at the space the volume uses, so Preboot measures what Disk Utility shows. Numbers and lists - Unreadable counts agree; unreadable locations read "No access"; the Map and Largest Items name their base; the Developer badge is its page's total. - Simulators never show zeros while loading and keep their inventory between visits; DerivedData's shared caches are not projects; projects show their folder and skip tool folders; apps are named as Finder names them. - Large Files opens on the files a person can act on and has empty states; search narrows the Map's list; excluded media libraries are named on the Overview and the setting is remembered. Framework - A raised SectorChart's hovered sector no longer lifts or slides: it takes its color at full strength and steps away from the backdrop. Sectors.highlight highlights a sector from code; selecting a list row points at its sector. - A wrapped label is as tall as the lines its cell draws, so the last line is no longer clipped. - Table cells keep their symbol when a file has no known type. Layout - One legend column on the Overview, equal-height stat tiles, fixed icon columns in Guide and Help, a Map that fits the narrowest window. Closes #59 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent dd66f47 commit 3ee1bf3

63 files changed

Lines changed: 879 additions & 198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/diskmap/Controller.lua‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ function Controller:badges()
217217
local badges = {}
218218
local summary = Overview.summary(self.model, self.scan.disk, self.capacity)
219219
if summary.available then badges.overview = summary.used end
220-
for id, category in pairs({developer = "developer", simulators = "simulators"}) do
221-
local row = Categories.row(self.model, category)
222-
if row and row.bytes and row.bytes > 0 and not row.calculating then badges[id] = row.size end
223-
end
220+
local simulators = Categories.row(self.model, "simulators")
221+
if simulators and simulators.bytes and simulators.bytes > 0 and not simulators.calculating then badges.simulators = simulators.size end
222+
-- The badge is the page's own total, AI tools included, so the sidebar
223+
-- and the page header name one number.
224+
local developer = Developer.presentation(self.model)
225+
if developer.bytes > 0 and not developer.calculating then badges.developer = developer.total end
224226
for _, id in ipairs({"xcode", "projects", "folder"}) do
225227
local page = self.pages[id]
226228
if page.badge then badges[id] = page:badge() end

‎apps/diskmap/Diskmap.xcodeproj/project.pbxproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
);
269269
runOnlyForDeploymentPostprocessing = 0;
270270
shellPath = /bin/sh;
271-
shellScript = "# Lua sources and app data are copied as trees, so new files need no project edit.\nset -e\nroot=\"$SRCROOT/../..\"\nresources=\"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\ncopy() {\n\tmkdir -p \"$resources/$2\"\n\trsync -a --delete --prune-empty-dirs --exclude=Build/ --include='*/' --include='*.lua' --include='*.etlua' --include='*.bin' --exclude='*' \"$root/$1/\" \"$resources/$2/\"\n}\ncopy lua lua\ncopy apps/diskmap apps/diskmap\n";
271+
shellScript = "# Lua sources and app data are copied as trees, so new files need no project edit.\nset -e\nroot=\"$SRCROOT/../..\"\nresources=\"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\ncopy() {\n\tmkdir -p \"$resources/$2\"\n\trsync -a --delete --delete-excluded --prune-empty-dirs --exclude=Build/ --include='*/' --include='*.lua' --include='*.etlua' --include='*.bin' --exclude='*' \"$root/$1/\" \"$resources/$2/\"\n}\ncopy lua lua\ncopy apps/diskmap apps/diskmap\n";
272272
};
273273
/* End PBXShellScriptBuildPhase section */
274274

‎apps/diskmap/README.md‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ the Developer category.
3131
- **Largest Items** — the hundred largest measured locations across every
3232
category, each with its semantic owner, cleanup status and share bar.
3333
- **Large Files** — the individual files over 50 MB found by the same scan,
34-
with when each was last used, filtered by All, Unused for a year, Installers &
35-
archives and Media. Your own documents (not files inside ~/Library, hidden
34+
with when each was last used, filtered by Yours (the files you can act on,
35+
shown first), All, Unused for a year, Installers & archives and Media. Your own documents (not files inside ~/Library, hidden
3636
tool folders or packages such as a Photos library) can be moved to the Trash
3737
after confirmation.
3838
- **File Types** — every measured byte grouped by kind (videos, disk images
@@ -54,7 +54,8 @@ the Developer category.
5454
- **Map** — the same semantic tree as a raised (3D) sunburst or a squarified
5555
treemap (segmented Rings / Rectangles), beside a list of the focused node's
5656
children. Click a group to look inside, click the center or the breadcrumb
57-
to go back, hover for the path, size and share. Colors are muted category
57+
to go back, hover for the path, size and share; the hovered sector brightens in place, and
58+
selecting a row in the list highlights its sector. Colors are muted category
5859
colors that lighten with depth; hatching marks rebuildable data. "Worth a
5960
look" lists the largest rebuildable resources under the focus.
6061
- **Xcode** — Device Support per OS version (the newest per platform is
@@ -144,8 +145,13 @@ Applications, Xcode, Projects, Duplicates, Disks and Updates pages, or a drop on
144145
the collector bar under every page, adds items to one basket;
145146
marking never touches the disk. The Marked toolbar sheet lists them with their
146147
consequences and moves them to the Trash one at a time, checking each again
147-
first. It refuses the disk root, system folders, mount points and your home's
148-
standard folders, and never follows symlinks. Sizes are measured again before
148+
first. Marking and moving both refuse the disk root, system folders, mount
149+
points, your home's standard folders, `/tmp` and `/private/var`, the shared
150+
folder and other users' homes, the iCloud Drive and cloud storage roots, Photos,
151+
Music and TV libraries, and anything in Keychains, Preferences, Mail, Messages,
152+
Accounts, Cookies or `~/.ssh`. Paths are compared without regard to case and
153+
through the root's links (`/tmp` is `/private/tmp`), and symlinks are never
154+
followed. Sizes are measured again before
149155
the move, and each item is checked just before it moves: one whose app is
150156
running (Xcode for DerivedData, a browser for its cache, the parent app of a
151157
helper), whose project file has gone, that was replaced since it was marked
@@ -166,13 +172,12 @@ watched folder that disappears stays listed as Missing, and a bookmark follows
166172
it when it is moved or renamed.
167173

168174
Categories open their resources in a sheet with Safe/rebuildable, Needs review
169-
and Essential to keep filters. Refresh, Stop, Clean Up, Settings and Search live
170-
in the toolbar; search applies to the current page. The window subtitle shows
171-
free space. `--page=<id>` (for example `--page=files`) opens a destination at
172-
launch for screenshots and walkthroughs.
173175
and Essential to keep filters. Back, Forward, Refresh, Stop, Clean Up,
174176
Marked, Settings and Search live in the toolbar; search applies to the current
175-
page. The window subtitle shows free and available space (available includes
177+
page (on the Map it narrows the list beside the chart, which keeps the whole
178+
level so its proportions stay true), and a search without matches says so.
179+
`--page=<id>` (for example `--page=files`) opens a destination at launch for
180+
screenshots and walkthroughs. The window subtitle shows free and available space (available includes
176181
purgeable storage) and how many items are marked. Sidebar rows show sizes as
177182
badges. The overview explains space no scan can attribute: purgeable storage,
178183
local snapshots and unreadable locations. With **Keep storage history** on in
@@ -246,8 +251,7 @@ actions change only the provider's in-memory copy; restarting restores the
246251
fixture. Finder, owner apps, System Settings and real device commands are not
247252
launched. The real provider remains the default when the mock switch is absent.
248253

249-
Every launch starts a fresh inventory. The category list follows macOS Storage: Applications, Trash, Books, Developer, Documents, iCloud Drive, iOS Files, Mail, Messages, Music, Music Creation, Photos, Podcasts, TV, Other Users & Shared, macOS and System Data, plus AI agents and snapshot backups. Photos, Music, TV and known media support locations are excluded by default; opt in for the current session in Settings. Excluded sizes are unknown, never zero. Diskmap has no directory
250-
argument or live scan-result cache. The explicit mock fixture is a synthetic
254+
Every launch starts a fresh inventory. The category list follows macOS Storage: Applications, Trash, Books, Developer, Documents, iCloud Drive, iOS Files, Mail, Messages, Music, Music Creation, Photos, Podcasts, TV, Other Users & Shared, macOS and System Data, plus AI agents and snapshot backups. Photos, Music, TV and known media support locations are excluded by default, which the Overview says; Include media libraries in Settings measures them and is remembered between launches. Excluded sizes are unknown, never zero. The inventory always covers the whole startup disk (`--folder=<path>` only opens the Folder Map on a folder), and no live scan results are cached. The explicit mock fixture is a synthetic
251255
filesystem for repeatable testing; use `--export-mock` to create a local snapshot
252256
of this Mac.
253257

@@ -265,9 +269,12 @@ resolved from installed application bundles, with a symbol fallback.
265269

266270
Every startup and refresh recalculates the inventory. Each pending category
267271
shows a native spinner and “Calculating…” in place of its size, then displays
268-
its fresh result once all of its locations finish. No scan results or diagnostics
269-
are retained between launches. Only Keep choices, watched locations with their
270-
last size and the background-check setting persist, in Diskmap's Application
272+
its fresh result once all of its locations finish. No live scan results or
273+
diagnostics are retained between launches. What persists is what you chose:
274+
Keep choices, watched locations with their last size, the settings (background
275+
checks, media libraries, storage history and notifications), folders added to
276+
Projects, and, once you export a snapshot, that snapshot with its cached
277+
per-location totals (`snapshot-summary`), in Diskmap's Application
271278
Support folder (resolved by `NSFileManager`, so a sandboxed build uses its container).
272279

273280
Headless tests inject scanner results through the service interface, without

‎apps/diskmap/controllers/ApplicationsController.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function Controller:update(state)
106106
refs.appsTileDetail.text = Model.plural(summary.count, "application bundle")
107107
refs.dataTileValue.text = self.model.files and Model.size(summary.data) or "—"
108108
refs.unusedTileValue.text = self.info and tostring(summary.unused) or "—"
109-
refs.unusedTileDetail.text = self.info and (Model.size(summary.unusedBytes) .. " not opened in 6 months") or "Reading last-used dates…"
109+
refs.unusedTileDetail.text = self.info and (Model.size(summary.unusedBytes) .. " not opened in 6 months, or never") or "Reading last-used dates…"
110110
refs.leftoversTileValue.text = summary.leftovers and Model.size(summary.leftoverBytes) or "—"
111111
refs.leftoversTileDetail.text = summary.leftovers and (Model.plural(summary.leftovers, "folder") .. " of apps not installed") or "Checking installed apps…"
112112
end

‎apps/diskmap/controllers/CleanupPageController.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ function Controller:update(state)
4747
end
4848
refs.summary.text = data.summary
4949
refs.rebuildableTileValue.text = Model.size(data.rebuildableBytes)
50-
refs.rebuildableTileDetail.text = #data.rebuildable .. (#data.rebuildable == 1 and " location" or " locations") .. " regenerated by their owners"
50+
refs.rebuildableTileDetail.text = Model.plural(#data.rebuildable, "location") .. " regenerated by their owners"
5151
refs.reviewTileValue.text = Model.size(data.reviewBytes)
52-
refs.reviewTileDetail.text = #data.review .. (#data.review == 1 and " location" or " locations") .. " that may hold your work"
52+
refs.reviewTileDetail.text = Model.plural(#data.review, "location") .. " that may hold your work"
5353
refs.checkedTileValue.text = tostring(data.known)
5454
refs.checkedTileDetail.text = "Known space hogs checked · " .. data.absent .. " not on this Mac"
5555
local tips = self.tips:presentation(state and state.disk)

‎apps/diskmap/controllers/FilesController.lua‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end
1313

1414
-- File Types opens this page narrowed to one kind.
1515
function Controller:focus(kind)
16-
self.kind, self.filterIndex = kind, 1
16+
self.kind, self.filterIndex = kind, Files.filterIndex("All")
1717
end
1818

1919
function Controller:mount(host, state)
@@ -37,23 +37,32 @@ function Controller:update(state)
3737
local filter = Files.filters[self.filterIndex]
3838
local rows = Files.rows(self.model, filter, state and state.query, self.kind)
3939
refs.files:replaceRows(rows)
40+
-- An empty list says why it is empty: nothing matches the search, or
41+
-- this filter has no files.
42+
local query = state and state.query or ""
43+
local measured = self.model.files ~= nil
44+
refs.filesPanel.hidden = measured and #rows == 0
45+
refs.filesEmpty.hidden = not (measured and #rows == 0 and query == "")
46+
refs.filesNoResults.hidden = not (measured and #rows == 0 and query ~= "")
4047
local summary = Files.summary(self.model)
4148
local kind = self.kind and Files.kindById(self.kind)
4249
refs.clearKind.hidden = kind == nil
43-
refs.filterDetail.text = (kind and (kind.name .. " · ") or "") .. (#rows == 1 and "1 file" or (#rows .. " files"))
50+
refs.filterDetail.text = (kind and (kind.name .. " · ") or "") .. Model.plural(Model.count(#rows), "file")
4451
.. (filter == "Unused for a year" and " not opened or changed in a year" or "")
52+
.. (filter == "Yours" and " you can move to the Trash" or "")
53+
.. (query ~= "" and " matching the search" or "")
4554
if not summary then
4655
refs.summary.text = "Measuring files… Large files appear when the scan finishes."
4756
return
4857
end
49-
refs.summary.text = string.format("%d files over %s use %s%s.", summary.count, Model.size(Inventory.summary.minimumFileBytes),
58+
refs.summary.text = string.format("%s over %s use %s%s.", Model.plural(Model.count(summary.count), "file"), Model.size(Inventory.summary.minimumFileBytes),
5059
Model.size(summary.bytes), summary.partial and " · some locations could not be read" or "")
5160
refs.largeTileValue.text = Model.size(summary.bytes)
52-
refs.largeTileDetail.text = summary.count .. " files, largest first"
61+
refs.largeTileDetail.text = Model.plural(Model.count(summary.count), "file") .. ", largest first"
5362
refs.oldTileValue.text = Model.size(summary.oldBytes)
54-
refs.oldTileDetail.text = summary.oldCount .. " files not opened or changed in a year"
63+
refs.oldTileDetail.text = Model.plural(Model.count(summary.oldCount), "file") .. " not opened or changed in a year"
5564
refs.movableTileValue.text = Model.size(summary.reviewableOldBytes)
56-
refs.movableTileDetail.text = summary.reviewableOld .. " unused documents you can move to the Trash"
65+
refs.movableTileDetail.text = Model.plural(Model.count(summary.reviewableOld), "unused document") .. " you can move to the Trash"
5766
end
5867

5968
function Controller:dispose()

‎apps/diskmap/controllers/FolderController.lua‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local ns = require("AppKit")
22
local Template = require("ui.template")
33
local FolderTree = require("apps.diskmap.models.FolderTree")
44
local Model = require("apps.diskmap.Model")
5+
local Sectors = require("ui.sectors")
56
local Controller = {}; Controller.__index = Controller
67

78
local STYLES = {"rings", "rectangles"}
@@ -297,7 +298,9 @@ function Controller:update(state)
297298
up = function() self:up() end,
298299
selectRow = function(_, _, row)
299300
if row and not row.other then self.selected = row.path end
300-
if row then self:describe(row.id) end
301+
if not row then return end
302+
self:describe(row.id)
303+
if self.refs.folderSunburst then Sectors.highlight(self.refs.folderSunburst, row.id) end
301304
end,
302305
drillRow = function(_, _, row) if row and not row.other then self:activate(row.id) end end,
303306
rowMenu = function(_, _, row)

‎apps/diskmap/controllers/LargestController.lua‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ function Controller:update(state)
2929
self.refs.largest:replaceRows(rows)
3030
local bytes = 0
3131
for _, row in ipairs(rows) do bytes = bytes + row.bytes end
32+
local used = state.disk and state.disk.totalKb and state.disk.totalKb > 0 and (state.disk.totalKb - state.disk.freeKb) * 1024 or nil
3233
self.refs.largestSummary.text = #rows == 0 and "No measured items match yet."
33-
or string.format("The %d largest measured locations use %s.", #rows, Model.size(bytes))
34+
or string.format("The %d largest measured locations use %s%s.", #rows, Model.size(bytes),
35+
used and used >= bytes and (" of " .. Model.size(used) .. " used") or "")
3436
end
3537

3638
function Controller:dispose()

‎apps/diskmap/controllers/MapController.lua‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local Template = require("ui.template")
33
local Categories = require("apps.diskmap.models.Categories")
44
local MapTree = require("apps.diskmap.models.MapTree")
55
local Model = require("apps.diskmap.Model")
6+
local Sectors = require("ui.sectors")
67
local Controller = {}; Controller.__index = Controller
78

89
local STYLES = {"rings", "rectangles"}
@@ -60,7 +61,10 @@ function Controller:presentation()
6061
local nodes, total = MapTree.nodes(self.model, self.focus)
6162
self.total = total
6263
local trail = MapTree.path(self.model, self.focus)
63-
local rows = Categories.rows(self.model, self.focus ~= "" and self.focus or nil)
64+
-- Search narrows the list beside the chart, as on every other page; the
65+
-- chart keeps the whole level so its proportions stay true.
66+
local query = self.state and self.state.query or ""
67+
local rows = Categories.rows(self.model, self.focus ~= "" and self.focus or nil, query)
6468
table.sort(rows, function(a, b) return (a.bytes or -1) > (b.bytes or -1) end)
6569
local largest = rows[1] and rows[1].bytes or 0
6670
for _, row in ipairs(rows) do
@@ -75,10 +79,15 @@ function Controller:presentation()
7579
end
7680
self.defaultHover = #nodes == 0 and "" or "Hover over the map for details; click a group to look inside."
7781
local focusRow = self.focus ~= "" and Categories.row(self.model, self.focus) or nil
82+
-- The Overview counts what the disk reports as used; the Map counts
83+
-- what Diskmap measured. Saying both keeps the two pages reconcilable.
84+
local disk = self.state and self.state.disk
85+
local used = disk and disk.totalKb and disk.totalKb > 0 and (disk.totalKb - disk.freeKb) * 1024 or nil
7886
return {nodes = nodes, rows = rows, trail = trail, worth = worth, style = self.style, hover = self.defaultHover,
79-
total = Model.size(total),
87+
total = Model.size(total), query = query,
8088
subtitle = (focusRow and (focusRow.name .. " · ") or "") .. Model.size(total) .. " measured"
81-
.. (self.focus == "" and " across every category" or ""),
89+
.. (self.focus == "" and (used and used >= total and (" of " .. Model.size(used) .. " used · shares are of what was measured")
90+
or " across every category") or ""),
8291
accessibilityLabel = "Storage map of " .. trail[#trail].name .. ", " .. #nodes .. " areas"}
8392
end
8493

@@ -103,7 +112,12 @@ function Controller:update(state)
103112
chartSelect = function(id, count) if count and count > 1 then self:activate(id) elseif isGroup(self.model, id) then self:setFocus(id) else self:describe(id) end end,
104113
chartHover = function(id) self:describe(id) end,
105114
up = function() self:up() end,
106-
selectRow = function(_, _, row) if row then self:describe(row.id) end end,
115+
-- A selected row points at its sector, as hovering the sector would.
116+
selectRow = function(_, _, row)
117+
if not row then return end
118+
self:describe(row.id)
119+
if self.refs.sunburst then Sectors.highlight(self.refs.sunburst, row.id) end
120+
end,
107121
drillRow = function(_, _, row) if row then self:activate(row.id) end end,
108122
rowMenu = function(_, _, row) return self.actions:resource(row.id) end,
109123
-- A mark drags as its folder or file, like a Finder item.

‎apps/diskmap/controllers/OverviewController.lua‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ function Controller:update(state)
5050
for _, item in ipairs(chart.legend) do
5151
actions["category_" .. item.id] = function() self.handlers.open(item.id) end
5252
end
53+
local cloudBytes, cloudFiles = Inventory.cloud(self.model)
5354
self.hero:update({summary = Overview.summary(self.model, state.disk, state.capacity), chart = chart,
54-
hidden = Overview.hidden(state.disk, state.capacity, state.snapshotCount, self.model.scan.errors, Inventory.cloud(self.model)),
55+
hidden = Overview.hidden(state.disk, state.capacity, state.snapshotCount, self.model.scan.errors, cloudBytes, cloudFiles,
56+
not self.model.includeMedia),
5557
reclaim = Overview.reclaim(self.model), volumeName = state.volumeName, actions = actions})
5658
self.changes:update({changes = state.changes, actions = {showAllChanges = function() self.handlers.changes() end}})
59+
-- An empty section takes no place in the page, so it adds no spacing.
60+
refs.changes.hidden = state.changes == nil
5761
-- Folders the scan could not read, while Full Disk Access is missing.
58-
local unreadable = state.fullDiskAccess == false and Overview.unreadable(self.model) or {paths = {}, more = 0}
62+
local unreadable = state.fullDiskAccess == false and Overview.unreadable(self.model) or {paths = {}, more = 0, moreText = "0"}
5963
self.access:update({unreadable = unreadable, actions = {grantAccess = function() self.handlers.access() end}})
64+
refs.accessNotice.hidden = #unreadable.paths == 0
6065
end
6166

6267
function Controller:dispose()

0 commit comments

Comments
 (0)