Skip to content

Commit b9e0d51

Browse files
corepunchclaude
andcommitted
Diskmap: one breakdown page template; sheets become pages
Overview, Storage Map, File Types and Folder Map are one etlua template (views/pages/Breakdown.etlua) over different route data: a heading at the top of the page (trail, title, picker, detail, low-space warning), the breakdown card (ring with a compact legend, or rectangles filling the card), then full-width lists. - One toolbar button switches every breakdown page between rings and rectangles (`--chart-style` picks the first). - Clean Up and Review leave the toolbar; flagged items are a Flagged sidebar row with a count badge. - Map and Folder Map drop their toolbar operations; rows and charts act in place, a folder being measured has its own Stop. - A running scan shows in its progress sheet again. - Former sheets (settings, history, SDKs, snapshot changes, tour, onboarding) are pages with history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a2b73e0 commit b9e0d51

174 files changed

Lines changed: 1991 additions & 2686 deletions

File tree

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: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ local ns = require("AppKit")
33
local App = require("App")
44
local xml = require("ui.xml")
55
local Workflows = require("apps.diskmap.models.Workflows")
6+
local Operations = require("apps.diskmap.helpers.Operations")
67
local Format = require("apps.diskmap.helpers.Format")
7-
local CollectorController = require("apps.diskmap.controllers.CollectorController")
88
local Environment = require("apps.diskmap.controllers.Environment")
99
local Provider = require("apps.diskmap.services.Provider")
1010
local Keep = require("apps.diskmap.flows.Keep")
@@ -13,7 +13,6 @@ local ScanProgress = require("apps.diskmap.controllers.ScanProgressController")
1313
local NavigationController = require("apps.diskmap.controllers.NavigationController")
1414
local CommandsController = require("apps.diskmap.controllers.CommandsController")
1515
local Model = require("data.model")
16-
local SheetController = require("apps.diskmap.controllers.SheetController")
1716
local PageController = require("data.pagecontroller")
1817
local Location = require("data.location")
1918
local Scans = require("apps.diskmap.models.Scans")
@@ -32,31 +31,40 @@ function Controller.new(service, launch)
3231
refresh = function() self:updateRows() end,
3332
changed = function() self:scanChanged() end,
3433
basketChanged = function() self:basketChanged() end,
35-
openHistory = function() self.env.history:open(self.window) end,
34+
openHistory = function() self:show("history") end,
3635
openReview = function(path) self:openReview(path) end,
3736
keep = function(id) self:keep(id) end,
3837
destination = function() return self.destination end,
3938
access = function() self:grantAccess() end,
4039
openChanges = function()
41-
if self.env.snapshots and self.env.snapshots.result then self.env.session.changesSheet:open(self.window, self.env.snapshots.result) end
40+
if self.env.snapshots and self.env.snapshots.result then self:show("snapshotChanges") end
4241
end,
4342
shortcuts = function() return self.shortcuts or {} end,
4443
command = function(name) return self.commandActions[name]() end,
45-
beforeSheet = function() if self.progress then self.progress:close() end end,
4644
raise = function() if self.window then self.window:show() end end,
4745
promptParent = function() return self.window end,
4846
links = CommandsController.links(),
47+
awaitAccess = function(page)
48+
if _G.__headless then return end
49+
local generation = page.generation
50+
local tick = Model.bound(self.env.model, function() page:poll() end)
51+
ns.async(function()
52+
while page.active and page.generation == generation do
53+
ns.sleep(page.interval)
54+
if page.active and page.generation == generation then tick() end
55+
end
56+
end)
57+
end,
4958
onboarded = function(granted)
59+
self:show("overview")
5060
self.env.session.fullDiskAccess = granted == true
5161
self.env.scan:start()
52-
if self.env.tour:needed(self.env.scan.disk) then self.env.tour:open(self.window) end
62+
if self.env.tour:needed(self.env.scan.disk) then self:show("tour") end
5363
end,
5464
}
5565
self.env = Environment.new(service or launch.service, launch, router)
56-
for _, sheet in pairs(self.env.context.sheets) do SheetController.attach(sheet, self.env.model) end
5766
self.navigation = NavigationController.new(function(id) self:show(id) end,
5867
function(location, restoring) self:go(location, restoring) end)
59-
self.collectorController = CollectorController.new(self.env.context)
6068
self.progress = ScanProgress.new(self.env.scan)
6169
self.commands = CommandsController.new(self.env.model, self.env.service, {
6270
show = function(id, params) self:show(id, params) end,
@@ -69,14 +77,14 @@ function Controller.new(service, launch)
6977
emptyTrash = function() Manage({app = self.env.context}):manage("user-trash") end,
7078
navigation = self.navigation,
7179
review = function() self:openReview() end,
72-
history = function() self.env.history:open(self.window) end,
80+
history = function() self:show("history") end,
7381
openFolder = function() self:chooseFolder() end,
7482
quickLook = function() self:quickLook() end,
7583
canQuickLook = function() local model = self.page and self.page.request; return model ~= nil and model.canQuickLook ~= nil and model:canQuickLook() end,
7684
openScan = function() self:openScan() end,
7785
compareScan = function() self:compareScan() end,
7886
exportScan = function() self:exportScan() end,
79-
tour = function() self.env.tour:open(self.window) end,
87+
tour = function() self:show("tour") end,
8088
})
8189
self.commandActions = self.commands:actions()
8290
for name, action in pairs(self.commandActions) do self.commandActions[name] = Model.bound(self.env.model, action) end
@@ -102,19 +110,10 @@ end
102110
function Controller:focusSearch()
103111
if self.window and self.searchField then self.window:focus(self.searchField) end
104112
end
105-
-- Opens a resource where its location sends it: a sidebar page, a sheet of
106-
-- its own, or its category's list with its row selected. An id that names
107-
-- no resource is a page ("updates").
108-
function Controller:open(id, filter)
113+
-- Opening a resource always navigates in the window's page history.
114+
function Controller:open(id)
109115
local destination = Locations:destination(id) or self.env.manifest.pages[id] and {page = id}
110-
if not destination then return end
111-
if destination.page then
112-
self.env.management:close(); self:show(destination.page)
113-
elseif destination.sheet == "sdks" then
114-
self.env.management:close(); self.env.sdks:open(self.window, Locations:find(id))
115-
else
116-
self.env.management:open(self.window, destination.category, {filter = filter, select = destination.select})
117-
end
116+
if destination then self:show(destination.page, destination.params) end
118117
end
119118

120119
function Controller:state()
@@ -125,8 +124,6 @@ end
125124

126125
function Controller:subtitle()
127126
local text = Scans:summary(self.env.scan.disk, self.env.session.capacity).short or ""
128-
local marked = self.env.basket:count()
129-
if marked > 0 then text = text .. " · " .. marked .. " marked for cleanup" end
130127
return text
131128
end
132129
-- Sidebar sizes come from measured categories and scan-owned inventories.
@@ -152,6 +149,9 @@ function Controller:badges()
152149
badges.projects = require("apps.diskmap.models.Projects"):badge()
153150
local folder = self.env.requests.folder
154151
badges.folder = folder and folder:badge()
152+
-- Flagged counts its items, as Mail counts a mailbox's unread messages.
153+
local flagged = self.env.basket:count()
154+
if flagged > 0 then badges.basket = tostring(flagged) end
155155
return badges
156156
end
157157
function Controller:updateRows()
@@ -163,8 +163,6 @@ function Controller:updateRows()
163163
if self.page then self.page:update(self:state()) end
164164
self.navigation:setBadges(self:badges())
165165
self.navigation:setWorkflows(self.env:presentWorkflows())
166-
self.env.management:draw()
167-
self.env.sdks:draw()
168166
end
169167
-- A kind of work leads nobody who does not do it (#52): its pages appear
170168
-- once one of its markers exists (Xcode for Developer, Logic Pro for Music
@@ -174,8 +172,7 @@ end
174172

175173
function Controller:basketChanged()
176174
if self.window then self.window.subtitle = self:subtitle() end
177-
self:updateToolbar()
178-
self.collectorController:update()
175+
self.navigation:setBadges(self:badges())
179176
if self.page and self.page.marksChanged then self.page:marksChanged() end
180177
end
181178

@@ -212,13 +209,11 @@ function Controller:quickLook()
212209
return false
213210
end
214211

215-
-- A running scan shows in its progress window and nowhere else; the pages
212+
-- A running scan shows in its progress sheet and nowhere else; the pages
216213
-- are drawn when it is over.
217214
function Controller:scanChanged()
218215
self:updateToolbar()
219-
local sheetOpen = false
220-
for _, sheet in pairs(self.env.context.sheets) do if sheet.sheet then sheetOpen = true end end
221-
if self.env.model.scan.running and self.window and not sheetOpen then
216+
if self.env.model.scan.running and self.window then
222217
self.progress:show(self.window)
223218
else
224219
self.progress:close()
@@ -250,12 +245,14 @@ function Controller:show(id, params, restoring)
250245
if self.page then self.page:dispose() end
251246
if request.focus then request:focus(params) end
252247
local page = PageController.new({page = entry, ns = ns, viewsDir = "apps/diskmap/views/",
253-
store = self.env.model, request = request, located = function(where) self:located(entry, where) end})
248+
store = self.env.model, request = request, located = function(where) self:located(entry, where) end,
249+
presented = function(data) self.operations = Operations.forPage(entry.id, data); self:updateToolbar() end})
254250
self.destination, self.page = id, page
251+
self.charted = request.view == "pages/Breakdown"
255252
page:mount(self.content, self:state())
256253
self.navigation:select(id)
257-
self.collectorController.onBasket = id == "basket"
258-
self.collectorController:update()
254+
255+
259256
self:updateRows()
260257
end
261258
self.restoring = nil
@@ -321,11 +318,10 @@ function Controller:compareScan(path)
321318
self:show("overview")
322319
end
323320
function Controller:openSettings()
324-
self.env.settings:open(self.window)
321+
self:show("settings")
325322
end
326323
-- The marked items are a page: Back and Forward reach it like any other.
327324
function Controller:openReview(path)
328-
self.env.settings:close()
329325
self:show("basket", {path = path})
330326
end
331327
-- Window.etlua's data. Its toolbar follows the scan as a SwiftUI toolbar
@@ -336,40 +332,55 @@ function Controller:windowData()
336332
data.subtitle = self:subtitle()
337333
data.actions = setmetatable({
338334
search = function(value) self:search(value) end,
339-
reclaim = function() self:show("cleanup") end,
335+
chartStyle = function() self:toggleChartStyle() end,
340336
}, {__index = self.commandActions})
337+
data.operations = self.operations or {}
338+
for _, item in ipairs(data.operations) do
339+
data.actions["operation_" .. item.id] = function()
340+
if self.page then return self.page.actions[item.action]() end
341+
end
342+
data.actions["enabled_" .. item.id] = function() return not item.disabled end
343+
end
341344
data.navigation = not self.launch.isolated
342345
data.scanning = self.env.scan.job ~= nil
343-
data.marked = self.env.basket:count()
346+
data.charted, data.chartStyle = self.charted, self.env.context.chartStyle
344347
return data
345348
end
346-
-- The window template is described again only when the scan starts or
347-
-- stops, and only its toolbar is applied.
349+
-- Rings or rectangles, for every breakdown page at once.
350+
function Controller:toggleChartStyle()
351+
local context = self.env.context
352+
context.chartStyle = context.chartStyle == "rectangles" and "rings" or "rectangles"
353+
self:updateToolbar()
354+
if self.page then self.page:update(self:state()) end
355+
end
356+
357+
-- Redescription follows page operations, scan state and the Review badge.
358+
-- Progress and hover never rebuild the toolbar.
348359
function Controller:updateToolbar()
349-
local scanning, marked = self.env.scan.job ~= nil, self.env.basket:count()
350-
if not self.window or (self.scanning == scanning and self.marked == marked) then return end
351-
self.scanning, self.marked = scanning, marked
360+
local scanning = self.env.scan.job ~= nil
361+
local parts = {}
362+
for _, item in ipairs(self.operations or {}) do table.insert(parts, table.concat({item.id, item.title, item.icon, item.action, tostring(item.disabled), tostring(item.hidden)}, ":")) end
363+
local operationKey = table.concat(parts, "|")
364+
local chartKey = tostring(self.charted) .. self.env.context.chartStyle
365+
if not self.window or (self.scanning == scanning and self.operationKey == operationKey and self.chartKey == chartKey) then return end
366+
self.operationKey, self.chartKey = operationKey, chartKey
367+
self.scanning = scanning
352368
self.window:updateToolbar(xml.toolbarFile(layout("Window"), self:windowData()))
353369
end
354370
function Controller:createWindow()
355371
self.env:prepare()
356372
local data = self:windowData()
357-
self.scanning, self.marked = data.scanning, data.marked
373+
self.scanning = data.scanning
358374
local cfg, windowRefs = render("Window", data)
359375
self.searchField = windowRefs and windowRefs.search
360376
self.shortcuts = self.commands:shortcuts(cfg.commands)
361377
local content, contentRefs = render("Content", {actions = {
362-
dropToMark = function(paths) return self.collectorController:dropToMark(paths) end,
363378
dropToOpen = function(paths) return paths[1] ~= nil and self:openFolder(paths[1]) end,
364-
review = function() self:openReview() end,
365-
pageDrag = function(targeted) self.collectorController:drag("page", targeted) end,
366-
collectorDrag = function(targeted) self.collectorController:drag("collector", targeted) end,
367379
}})
368380
self.navigation:setWorkflows(self.env:presentWorkflows())
369381
cfg.content = content
370382
if not self.launch.isolated then cfg.sidebar = self.navigation:render() end
371-
self.content, self.collector = contentRefs.content, contentRefs
372-
self.collectorController.refs = contentRefs
383+
self.content = contentRefs.content
373384
self:basketChanged()
374385
self.window = ns.Window(cfg)
375386
if self.launch.page then self:go(self.launch.page) else self:show("overview") end
@@ -402,10 +413,10 @@ function Controller:createWindow()
402413
-- scan and starts the scan once access is granted or declined.
403414
-- The welcome tour follows while the scan runs.
404415

405-
if self.env.onboarding:needed() then self.env.onboarding:open(self.window)
416+
if self.env.onboarding:needed() then self:show("onboarding")
406417
else
407418
self.env.scan:start()
408-
if self.env.tour:needed(self.env.scan.disk) then self.env.tour:open(self.window) end
419+
if self.env.tour:needed(self.env.scan.disk) then self:show("tour") end
409420
end
410421
end
411422
local scope = ns.Scope.current()
@@ -418,10 +429,10 @@ function Controller:createWindow()
418429
end
419430
return self.window
420431
end
421-
-- The window is going: its page, sheets and running work go with it.
432+
-- The window is going: its page and running work go with it.
422433
function Controller:dispose()
423434
if self.page then self.page:dispose() end
424-
self.collectorController:dispose()
435+
425436
if not self.launch.isolated and not self.launch.secondary then self.env.service.onOpenFiles(nil) end
426437
self.progress:close()
427438
self.env:dispose()

‎apps/diskmap/DESIGN.md‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ become app features. Feature shutdown is not a promise of immediate asset remova
5252
The window has a native sidebar grouped by user goal: Storage (Overview, Map,
5353
Largest Items), Apps (App Leftovers), Tools (Developer, Xcode, Projects,
5454
Simulators), System (Updates & Snapshots) and Learn (Storage Guide). Choosing a category anywhere opens
55-
its resources in a sheet. Suggested cleanups open from the toolbar and from the
56-
overview's call to action, grouped by impact, with contextual tips. Settings
55+
its resource page in the same window. Suggested cleanups open from the toolbar,
56+
grouped by impact, with contextual tips. Settings
5757
opens from the toolbar. Largest Items ranks catalog resources; it is not a
5858
folder browser.
5959

@@ -136,24 +136,29 @@ there. There is no separate folder-hunting workflow required to finish cleanup.
136136

137137
## Window and interaction design
138138

139-
Use one native window with a source-list sidebar. Category management, SDKs
140-
and Diskmap settings are sheets; suggested cleanups are the Clean Up page.
139+
Use one native window with a source-list sidebar. SDKs, settings and review are ordinary pages reached through navigation.
140+
Suggested cleanups are the Clean Up page.
141141
All screens and partials are etlua.
142142

143-
Every page scrolls as one surface. Lists inside a page are `scrollDisabled`
143+
Pages choose ContentPage or TablePage. ContentPage scrolls as one
144+
surface; TablePage fills the available height. Breakdowns share one compact
145+
chart-left, legend-right widget above the full item list. Rectangles fill the
146+
whole widget without a side legend.
147+
An icon button shows the alternate mode. Page and selection operations use
148+
the native toolbar. Sectioned lists are `scrollDisabled`
144149
and share one row design (`views/components/ResourceList.etlua`): icon, name and
145150
location, a status column, a meter (size and share on a line above the share
146151
bar, one native cell, as on every level list) and a "More" (⋯) button.
147152
Row actions live in that button's menu and the row's contextual menu, built
148-
by `RowMenus` from the same rules the sheets use, so the same data
153+
by `RowMenus` from the same rules the pages use, so the same data
149154
reads the same way on Largest Items, Large Files, Developer, Clean Up,
150155
Applications and Disks, and no action buttons sit beneath a list. Stat tiles
151156
summarize a page above its lists.
152157

153158
Alignment follows the rule in `AGENTS.md`: within a card, every symbol, dot
154159
and disclosure triangle is centered on one vertical line and every label
155160
starts at one edge. The Overview card has one symbol column for its warning,
156-
legend dots, hidden-space symbols and cleanup symbol (`HERO.symbol`); info
161+
legend dots and hidden-space symbols (`breakdownSymbolColumn`); info
157162
rows, tips, guide and help topics share a 26-point column with a 10-point
158163
gap; section titles with a symbol use `views/components/SectionTitle.etlua`. Optional
159164
trailing buttons sit in a fixed column so values keep one trailing edge.

0 commit comments

Comments
 (0)