Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say what the AI models Developer lists take in Space on macOS 26 too

Țugui Dragoșb0a73e4a14a9
diff --git a/GUIDE.md b/GUIDE.md
index acefa93f..8746de7a 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -248,8 +248,8 @@ names in its own file says so, and what a formula keeps in Homebrew's `etc` or i
of TeX Live in `/usr/local/texlive` and the versions of the .NET SDK are shown the same way, each with its size, and
those other than the year in use or with a newer version beside them say so. Where Developer knows part of a folder,
Space says how much of it moves here and opens Developer for the rest. Space also explains the snapshots macOS keeps
-on the disk, which Peel never removes, and, on macOS 27, says how much Apple Intelligence may keep on this Mac, by
-Apple's figure, and how much the AI models and datasets Developer lists take.
+on the disk, which Peel never removes, says how much the AI models and datasets Developer lists take, and, on macOS
+27, how much Apple Intelligence may keep on this Mac, by Apple's figure.
Nothing is selected for you: Select Recommended takes what Peel could measure in an area and nothing holds back. A
cache, or a log in the Library every account shares or in Homebrew's folder, that something wrote to in the last 15
diff --git a/Peel/Model/SpaceLibrary.swift b/Peel/Model/SpaceLibrary.swift
index 5ca60d96..cbdd5f37 100644
--- a/Peel/Model/SpaceLibrary.swift
+++ b/Peel/Model/SpaceLibrary.swift
@@ -28,12 +28,17 @@ final class SpaceLibrary: RowSelection {
/// name folders a move has taken since.
@ObservationIgnored private var plansStarted: [SpaceItem.ID: Int] = [:]
private let makePlan: @Sendable (SpaceItem, Exclusions, [RunningCopies.Process]) async -> SpaceRemoval.Plan
+ private let findModels: @Sendable (Exclusions) async -> [DeveloperEnvironment.Location]
init(
makingPlans makePlan: @escaping @Sendable (SpaceItem, Exclusions, [RunningCopies.Process]) async
- -> SpaceRemoval.Plan = { await SpaceRemoval.plan(for: $0, exclusions: $1, running: $2) }
+ -> SpaceRemoval.Plan = { await SpaceRemoval.plan(for: $0, exclusions: $1, running: $2) },
+ measuringModels findModels: @escaping @Sendable (Exclusions) async -> [DeveloperEnvironment.Location] = {
+ await DeveloperCaches.models(exclusions: $0)
+ }
) {
self.makePlan = makePlan
+ self.findModels = findModels
}
var selectedItem: SpaceItem? {
@@ -183,18 +188,15 @@ final class SpaceLibrary: RowSelection {
for (item, _) in made {
await measureWhatIsLeftToDeveloper(in: item)
}
- if #available(macOS 27, *) {
- await measureModels()
- }
+ await measureModels()
}
/// Measures the AI models and datasets after the areas, keeping the newest answer: a measurement that ends after
/// a newer one began, or is stopped, changes nothing.
- @available(macOS 27, *)
- private func measureModels() async {
+ func measureModels() async {
modelsMeasurement += 1
let measurement = modelsMeasurement
- let found = await DeveloperCaches.models(exclusions: ExclusionsStore.shared.exclusions)
+ let found = await findModels(ExclusionsStore.shared.exclusions)
guard !Task.isCancelled, measurement == modelsMeasurement else { return }
models = found.isEmpty ? nil : SizeTotal(found.map(\.size))
}
diff --git a/Peel/Views/Space/SpaceList.swift b/Peel/Views/Space/SpaceList.swift
index 0cf29628..df3527c0 100644
--- a/Peel/Views/Space/SpaceList.swift
+++ b/Peel/Views/Space/SpaceList.swift
@@ -141,7 +141,7 @@ struct SpaceList: View {
.font(.caption)
}
}
- if #available(macOS 27, *), let models = space.models {
+ if let models = space.models {
VStack(alignment: .leading, spacing: 2) {
modelsLine(models)
.font(.caption)
@@ -160,7 +160,6 @@ struct SpaceList: View {
.padding(.vertical, 6)
}
- @available(macOS 27, *)
private func modelsLine(_ total: SizeTotal) -> Text {
switch total.reading {
case .exactly(let size): Text("AI models and datasets take \(size.byteCount) on this Mac.")
diff --git a/PeelTests/SpaceLibraryTests.swift b/PeelTests/SpaceLibraryTests.swift
index 631d6463..7470a450 100644
--- a/PeelTests/SpaceLibraryTests.swift
+++ b/PeelTests/SpaceLibraryTests.swift
@@ -15,6 +15,20 @@ struct SpaceLibraryTests {
#expect(space.report == nil)
}
+ @Test func measuresTheModelsTheDeveloperPageListsOnEveryMacOS() async {
+ let models = [1_000, 2_000].map { (size: Int64) in
+ DeveloperEnvironment.Location(
+ url: URL(filePath: "/tmp/org.example.model\(size)"), kind: .models, size: size,
+ source: "https://example.com"
+ )
+ }
+ let space = SpaceLibrary(measuringModels: { _ in models })
+
+ await space.measureModels()
+
+ #expect(space.models == SizeTotal(known: 3_000, isComplete: true))
+ }
+
@Test func aPlanThatStartedEarlierAndEndedLaterIsDropped() async throws {
let older = URL(filePath: "/Users/x/Library/Caches/org.example.moved")
let newer = URL(filePath: "/Users/x/Library/Caches/org.example.left")