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
Home reads the helper's and login item's status off the main thread
Țugui Dragoșbfc51bd35573
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swiftindex 18324480..82a60e7a 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift@@ -50,6 +50,12 @@ public enum PrivilegedHelper {}}+ /// `status`, read away from the caller's actor: `SMAppService` asks `smd` over XPC, which takes milliseconds.+ @concurrent+ public static func currentStatus() async -> Status {+ status+ }+public static func register() throws {try service.register()}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HelperStandingTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HelperStandingTests.swiftindex f73d267a..2dc71446 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HelperStandingTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HelperStandingTests.swift@@ -4,6 +4,18 @@ import Testingstruct HelperStandingTests {private let statuses: [PrivilegedHelper.Status] = [.notRegistered, .requiresApproval, .enabled, .unavailable]+ @MainActor @Test func readsTheStatusAwayFromTheMainActor() async {+ final class Turn {+ var taken = false+ }+ let turn = Turn()+ Task { @MainActor in turn.taken = true }++ _ = await PrivilegedHelper.currentStatus()++ #expect(turn.taken)+ }+/// The helper serves administrators only, so a standard account is never offered to install, approve or repair/// it, whatever its registration says.@Test func aStandardAccountNeedsAnAdministratorWhateverTheRegistration() {diff --git a/Peel/Model/HelperModel.swift b/Peel/Model/HelperModel.swiftindex 2a5fa6be..e43c782b 100644--- a/Peel/Model/HelperModel.swift+++ b/Peel/Model/HelperModel.swift@@ -43,7 +43,7 @@ final class HelperModel {}func checkConnection() async {- refresh()+ status = await PrivilegedHelper.currentStatus()isResponding = status == .enabled ? await PrivilegedHelper.isResponding() : nilisRegisteredByAnotherCopy = status == .notRegistered ? await PrivilegedHelper.isRegisteredByAnyCopy() : false}diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swiftindex b7c4db2f..4f6db6db 100644--- a/Peel/Model/HomeModel.swift+++ b/Peel/Model/HomeModel.swift@@ -158,13 +158,14 @@ final class HomeModel {let fullDisk = await accessneedsRelaunchForFullDiskAccess = fullDisk == .missing && hasOpenedFullDiskAccessSettingslet appBundles = await bundles+ let opensAtLogin = await Self.opensAtLogin()states = [.fullDiskAccess: state(for: fullDisk),.helper: helperState,.appManagement: state(for: appManagementSeenThisLaunch ?? (appBundles == .unknown ? appManagement : appBundles)),.notifications: notificationStatus == .authorized ? .on : .off,.finderExtension: isFinderExtensionEnabled ? .on : .off,- .openAtLogin: SMAppService.mainApp.status == .enabled ? .on : .off,+ .openAtLogin: opensAtLogin ? .on : .off,.commandLine: CommandLineTool.isOnThePath(embedded: Bundle.main.bundleURL.appending(path: "Contents/Helpers/peel")) ? .on : .off,]hasChecked = true@@ -255,6 +256,12 @@ final class HomeModel {FIFinderSyncController.isExtensionEnabled}+ /// Off the main thread: `SMAppService` asks `smd` over XPC.+ @concurrent+ private static func opensAtLogin() async -> Bool {+ SMAppService.mainApp.status == .enabled+ }+private static func finderExtensionRunsFromAnotherCopy() async -> Bool {guard let own = Bundle.main.builtInPlugInsURL.flatMap({ Bundle(url: $0.appending(path: "PeelFinder.appex")) }),let identifier = own.bundleIdentifier