Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Stop calling App Management off once you've been to System Settings
Țugui Dragoș0635c9ffd385
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex ad21c1d9..d0b86a21 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -25820,6 +25820,112 @@}}},+ "Checked at the next removal" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ověří se při příštím odstranění"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wird beim nächsten Entfernen geprüft"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Se comprueba en la siguiente eliminación"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vérification à la prochaine suppression"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Verificata alla prossima rimozione"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "次回ゴミ箱に入れるときに確認"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "다음에 제거할 때 확인됨"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wordt gecontroleerd bij volgende verwijdering"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sprawdzane przy następnym przeniesieniu do Kosza"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Verificado na próxima remoção"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Se verifică la următoarea eliminare"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Проверяется при следующем удалении"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kontrolleras vid nästa borttagning"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bir sonraki kaldırmada denetlenir"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Перевіряється під час наступного вилучення"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "下次移除时检查"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "下次移除時才會檢查"+ }+ }+ }+ },"Checking for updates…" : {"localizations" : {"cs" : {diff --git a/Peel/Model/FrontmostApp.swift b/Peel/Model/FrontmostApp.swiftindex 13056b73..719f6ffd 100644--- a/Peel/Model/FrontmostApp.swift+++ b/Peel/Model/FrontmostApp.swift@@ -9,8 +9,9 @@ final class FrontmostApp {static let shared = FrontmostApp()private(set) var bundleIdentifier = NSWorkspace.shared.frontmostApplication?.bundleIdentifier- /// True once System Settings has been in front since Peel started, however the person got there.- private(set) var hasShownSystemSettings = false+ /// How many times System Settings has come to the front since Peel started, however the person got there.+ private(set) var systemSettingsShows = 0+ var hasShownSystemSettings: Bool { systemSettingsShows > 0 }init(observing: Bool = true) {note(bundleIdentifier)@@ -29,7 +30,7 @@ final class FrontmostApp {func note(_ identifier: String?) {bundleIdentifier = identifierif identifier == "com.apple.systempreferences" {- hasShownSystemSettings = true+ systemSettingsShows += 1}}}diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swiftindex 16a1686f..1684139f 100644--- a/Peel/Model/HomeModel.swift+++ b/Peel/Model/HomeModel.swift@@ -108,6 +108,11 @@ final class HomeModel {/// weighing everything, including the signature the permission was given to, so it outranks the privacy/// database.private var appManagementSeenThisLaunch: AccessState?+ /// macOS refused this permission at a removal and the person has had the chance to change it since. macOS has no+ /// API for it, so only the next removal can say.+ private(set) var appManagementAwaitsARemoval = false+ /// How many times System Settings had come forward when macOS refused, while the refusal stands.+ private var systemSettingsShowsAtRefusal: Int?/// Full Disk Access only applies to a new process, so Peel offers to reopen itself.private(set) var needsRelaunchForFullDiskAccess = false/// Peel could not open a fresh copy of itself, so it stayed.@@ -115,15 +120,25 @@ final class HomeModel {/// False until the first check finishes. Until then no state is shown, so the panel never flashes a wrong one. The/// helper's row is checked apart and says so until its own answer.private(set) var hasChecked = false- private let frontmost = FrontmostApp.shared+ private let frontmost: FrontmostApp+ private let defaults: UserDefaults/// The login item Settings switches too, so Home shows each change as it lands.let loginItem: LoginItem- init(helper: HelperModel, loginItem: LoginItem = .ofTheMainApp()) {+ init(+ helper: HelperModel,+ loginItem: LoginItem = .ofTheMainApp(),+ defaults: UserDefaults = .standard,+ frontmost: FrontmostApp = .shared+ ) {self.helper = helperself.loginItem = loginItem- appManagement = AccessState(stored: UserDefaults.standard.string(forKey: Self.appManagementKey))+ self.defaults = defaults+ self.frontmost = frontmost+ let stored = AccessState(stored: defaults.string(forKey: Self.appManagementKey))+ appManagementAwaitsARemoval = stored == .missing+ appManagement = stored == .missing ? .unknown : stored}/// What each row shows. The helper's row is the helper model's, as it changes, from Home's first read on.@@ -145,10 +160,12 @@ final class HomeModel {var needsAttention: Bool { !missingRequired.isEmpty }/// Required permissions still pending, such as a helper waiting for approval or a check that got no- /// answer. Home doesn't say "You're all set" while any remain. App Management is left out: it is often- /// known only after the first removal.+ /// answer. Home doesn't say "You're all set" while any remain. App Management counts only after a refusal: it is+ /// often known only after the first removal.var waitingRequired: [Permission] {- Permission.allCases.filter { $0.isRequired && state(of: $0) == .pending && $0 != .appManagement }+ Permission.allCases.filter {+ $0.isRequired && state(of: $0) == .pending && ($0 != .appManagement || appManagementAwaitsARemoval)+ }}func state(of permission: Permission) -> State {@@ -192,6 +209,7 @@ final class HomeModel {fullDisk, systemSettingsWasInFront: frontmost.hasShownSystemSettings)await loginItem.refresh()+ followSystemSettings()found = [.fullDiskAccess: state(for: fullDisk),.appManagement: state(for: appManagementSeenThisLaunch ?? appManagement),@@ -219,7 +237,7 @@ final class HomeModel {private var modelName: String? {let identifier = device?.modelIdentifier ?? ""guard !identifier.isEmpty else { return nil }- return UserDefaults.standard.string(forKey: Self.modelNameKey + identifier)+ return defaults.string(forKey: Self.modelNameKey + identifier)}/// Reads the marketing name with `system_profiler` and saves it, when none is saved for this model yet.@@ -229,15 +247,17 @@ final class HomeModel {isReadingModelName = truedefer { isReadingModelName = false }guard let name = await DeviceInfo.marketingName() else { return }- UserDefaults.standard.set(name, forKey: Self.modelNameKey + identifier)+ defaults.set(name, forKey: Self.modelNameKey + identifier)device = device?.named(name)}func record(appManagement state: AccessState) {appManagementSeenThisLaunch = state+ appManagementAwaitsARemoval = false+ systemSettingsShowsAtRefusal = state == .missing ? frontmost.systemSettingsShows : nilguard state != appManagement else { return }appManagement = state- UserDefaults.standard.set(state.stored, forKey: Self.appManagementKey)+ defaults.set(state.stored, forKey: Self.appManagementKey)found[.appManagement] = self.state(for: state)}@@ -245,13 +265,26 @@ final class HomeModel {NSWorkspace.shared.open(FullDiskAccess.settingsURL)}- /// Opens the App Management settings and forgets the stored state. macOS has no API for this permission, so a- /// stored "off" that only a removal updates would keep Home red after the user turns it on.- func openAppManagementSettings() {+ /// A refusal stands until System Settings has come forward, by whichever button or by hand: only a removal updates+ /// it, so it would keep Home red after the person turned the permission on.+ func followSystemSettings() {+ guard let shows = systemSettingsShowsAtRefusal, frontmost.systemSettingsShows > shows else { return }+ systemSettingsShowsAtRefusal = nilappManagementSeenThisLaunch = nilappManagement = .unknown- UserDefaults.standard.removeObject(forKey: Self.appManagementKey)- found[.appManagement] = state(for: .unknown)+ appManagementAwaitsARemoval = true+ found[.appManagement] = .pending+ }++ /// Opens the App Management settings, where the person can turn off what a removal found on, so that answer no+ /// longer holds.+ func openAppManagementSettings() {+ if (appManagementSeenThisLaunch ?? appManagement) == .granted {+ appManagementSeenThisLaunch = nil+ appManagement = .unknown+ defaults.removeObject(forKey: Self.appManagementKey)+ found[.appManagement] = state(for: .unknown)+ }NSWorkspace.shared.open(AppManagement.settingsURL)}diff --git a/Peel/Views/Home/HomePermissionsView.swift b/Peel/Views/Home/HomePermissionsView.swiftindex 6124baaf..2e534335 100644--- a/Peel/Views/Home/HomePermissionsView.swift+++ b/Peel/Views/Home/HomePermissionsView.swift@@ -362,7 +362,8 @@ fileprivate extension HomeModel {case (.helper, .pending): "Needs approval, or was turned off"case (.finderExtension, .off) where isFinderExtensionFromAnotherCopy: "On in another copy of Peel"case (_, .notThisAccount): "Needs an administrator"- case (.appManagement, .pending): "Checked at first removal"+ case (.appManagement, .pending):+ appManagementAwaitsARemoval ? "Checked at the next removal" : "Checked at first removal"case (.commandLine, .on): "Installed"case (.commandLine, _):HomeModel.commandLineStanding == .somethingElse ? "Something else is there" : "Not installed"diff --git a/PeelTests/HomeAppManagementTests.swift b/PeelTests/HomeAppManagementTests.swiftnew file mode 100644index 00000000..41363121--- /dev/null+++ b/PeelTests/HomeAppManagementTests.swift@@ -0,0 +1,57 @@+import Foundation+@testable import Peel+import PeelCore+import Testing++@MainActor+struct HomeAppManagementTests {+ @Test func aRefusalGivesWayOnceSystemSettingsHasBeenInFront() throws {+ let madeUp = try MadeUpDefaults()+ defer { madeUp.forget() }+ let frontmost = FrontmostApp(observing: false)+ let home = HomeModel(helper: HelperModel(), defaults: madeUp.defaults, frontmost: frontmost)++ frontmost.note("com.apple.systempreferences")+ frontmost.note("org.example.other")+ home.record(appManagement: .missing)+ home.followSystemSettings()+ #expect(home.state(of: .appManagement) == .missing)+ #expect(home.missingRequired.contains(.appManagement))++ frontmost.note("com.apple.systempreferences")+ frontmost.note("com.tuguidragos.Peel")+ home.followSystemSettings()+ #expect(home.state(of: .appManagement) == .pending)+ #expect(!home.missingRequired.contains(.appManagement))+ #expect(home.waitingRequired.contains(.appManagement))+ #expect(home.appManagementAwaitsARemoval)++ home.record(appManagement: .granted)+ #expect(home.state(of: .appManagement) == .on)+ #expect(!home.waitingRequired.contains(.appManagement))+ #expect(!home.appManagementAwaitsARemoval)+ }++ @Test func aRefusalFromAnEarlierLaunchWaitsForTheNextRemoval() throws {+ let madeUp = try MadeUpDefaults()+ defer { madeUp.forget() }+ let frontmost = FrontmostApp(observing: false)+ HomeModel(helper: HelperModel(), defaults: madeUp.defaults, frontmost: frontmost)+ .record(appManagement: .missing)++ let home = HomeModel(helper: HelperModel(), defaults: madeUp.defaults, frontmost: frontmost)++ #expect(!home.missingRequired.contains(.appManagement))+ #expect(home.waitingRequired.contains(.appManagement))+ }++ @Test func neverHavingAskedIsNotWaiting() throws {+ let madeUp = try MadeUpDefaults()+ defer { madeUp.forget() }+ let frontmost = FrontmostApp(observing: false)+ let home = HomeModel(helper: HelperModel(), defaults: madeUp.defaults, frontmost: frontmost)++ #expect(!home.appManagementAwaitsARemoval)+ #expect(!home.waitingRequired.contains(.appManagement))+ }+}