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
Say why an enabled background item leaves the list
Țugui Dragoșa63fe6d7e8fd
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 4ce32b15..a7a43175 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -67095,6 +67095,218 @@}}},+ "It isn’t loaded now, so it leaves this list until macOS loads it again, usually the next time you log in." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Teď není načtená, takže z tohoto seznamu zmizí, dokud ji systém macOS znovu nenačte, obvykle při příštím přihlášení."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es ist gerade nicht geladen, daher verschwindet es aus dieser Liste, bis macOS es wieder lädt, in der Regel bei deiner nächsten Anmeldung."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ahora no está cargado, así que desaparece de esta lista hasta que macOS vuelva a cargarlo, normalmente la próxima vez que inicies sesión."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il n’est pas chargé pour le moment : il disparaît donc de cette liste jusqu’à ce que macOS le charge à nouveau, généralement à votre prochaine ouverture de session."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Al momento non è caricato, quindi scompare da questo elenco finché macOS non lo carica di nuovo, di solito al prossimo login."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "現在は読み込まれていないため、macOSが再び読み込むまで、このリストには表示されません。通常は次回のログイン時に読み込まれます。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "지금은 로드되어 있지 않으므로, macOS가 다시 로드할 때까지 이 목록에서 사라집니다. 보통 다음에 로그인할 때 다시 로드됩니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het is nu niet geladen, dus verdwijnt het uit deze lijst totdat macOS het weer laadt, meestal de volgende keer dat je inlogt."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ta rzecz nie jest teraz wczytana, więc znika z tej listy, dopóki macOS nie wczyta jej ponownie, zwykle przy następnym logowaniu."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ele não está carregado agora, então sai desta lista até que o macOS o carregue novamente, geralmente na próxima vez que você iniciar a sessão."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nu este încărcat acum, așa că dispare din această listă până când macOS îl încarcă din nou, de obicei data viitoare când faceți login."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Сейчас он не загружен, поэтому не будет показываться в этом списке, пока macOS снова его не загрузит, обычно при следующем входе в систему."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det är inte inläst nu, så det försvinner från den här listan tills macOS läser in det igen, oftast nästa gång du loggar in."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Şu anda yüklü değil, bu yüzden macOS onu yeniden yükleyene kadar bu listeden çıkar; bu genellikle bir sonraki oturum açışınızda olur."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Зараз його не завантажено, тож у цьому списку його не буде, доки macOS не завантажить його знову, зазвичай під час вашого наступного входу в систему."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它目前未载入,因此在macOS再次载入它之前(通常是你下次登录时),它不会显示在此列表中。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它目前未載入,因此在macOS再次載入它之前,它不會出現在此列表中;macOS通常會在你下次登入時載入它。"+ }+ }+ }+ },+ "It isn’t loaded now, so it leaves this list until macOS loads it again, usually when the Mac restarts." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Teď není načtená, takže z tohoto seznamu zmizí, dokud ji systém macOS znovu nenačte, obvykle po restartu Macu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es ist gerade nicht geladen, daher verschwindet es aus dieser Liste, bis macOS es wieder lädt, in der Regel beim nächsten Neustart des Mac."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ahora no está cargado, así que desaparece de esta lista hasta que macOS vuelva a cargarlo, normalmente cuando el Mac se reinicie."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il n’est pas chargé pour le moment : il disparaît donc de cette liste jusqu’à ce que macOS le charge à nouveau, généralement au redémarrage du Mac."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Al momento non è caricato, quindi scompare da questo elenco finché macOS non lo carica di nuovo, di solito al riavvio del Mac."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "現在は読み込まれていないため、macOSが再び読み込むまで、このリストには表示されません。通常はMacの再起動時に読み込まれます。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "지금은 로드되어 있지 않으므로, macOS가 다시 로드할 때까지 이 목록에서 사라집니다. 보통 Mac을 재시동할 때 다시 로드됩니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het is nu niet geladen, dus verdwijnt het uit deze lijst totdat macOS het weer laadt, meestal als de Mac opnieuw opstart."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ta rzecz nie jest teraz wczytana, więc znika z tej listy, dopóki macOS nie wczyta jej ponownie, zwykle po ponownym uruchomieniu Maca."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ele não está carregado agora, então sai desta lista até que o macOS o carregue novamente, geralmente quando o Mac for reiniciado."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nu este încărcat acum, așa că dispare din această listă până când macOS îl încarcă din nou, de obicei când Mac‑ul repornește."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Сейчас он не загружен, поэтому не будет показываться в этом списке, пока macOS снова его не загрузит, обычно при перезагрузке Mac."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det är inte inläst nu, så det försvinner från den här listan tills macOS läser in det igen, oftast när datorn startas om."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Şu anda yüklü değil, bu yüzden macOS onu yeniden yükleyene kadar bu listeden çıkar; bu genellikle Mac yeniden başladığında olur."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Зараз його не завантажено, тож у цьому списку його не буде, доки macOS не завантажить його знову, зазвичай після перезапуску Mac."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它目前未载入,因此在macOS再次载入它之前(通常是Mac重新启动时),它不会显示在此列表中。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它目前未載入,因此在macOS再次載入它之前,它不會出現在此列表中;macOS通常會在Mac重新開機時載入它。"+ }+ }+ }+ },"It isn’t there anymore." : {"localizations" : {"cs" : {@@ -230509,6 +230721,112 @@}}},+ "“%@” is enabled." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Položka „%@“ je zapnutá."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ ist aktiviert."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Se ha activado “%@”."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "« %@ » est activé."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” è abilitato."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”を有効にしました。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’이(가) 활성화되었습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "'%@' is ingeschakeld."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Włączono „%@”."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” está ativado."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@” este activat."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Объект «%@» включен."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "”%@” har aktiverats."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” etkinleştirildi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "«%@» увімкнено."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "已启用“%@”。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "「%@」已啟用。"+ }+ }+ }+ },"“%@” is in the Trash but couldn’t be stopped." : {"localizations" : {"cs" : {diff --git a/Peel/Model/BackgroundItemLibrary.swift b/Peel/Model/BackgroundItemLibrary.swiftindex 7e4fd8e3..8c747805 100644--- a/Peel/Model/BackgroundItemLibrary.swift+++ b/Peel/Model/BackgroundItemLibrary.swift@@ -16,8 +16,8 @@ final class BackgroundItemLibrary {/// clears another row's busy state.private(set) var runningActionItemIDs: Set<BackgroundItem.ID> = []var selection: BackgroundItem.ID?- /// Actions run on several items at once, so their failures wait their turn rather than replace each other.- private(set) var failures = AlertQueue<ActionFailure>()+ /// Actions run on several items at once, so what each has to say waits its turn rather than replace another.+ private(set) var alerts = AlertQueue<ActionAlert>()var selectedItem: BackgroundItem? {items?.first { $0.id == selection }@@ -58,8 +58,20 @@ final class BackgroundItemLibrary {var fileMoved = false}- func dismissFailure() {- failures.dismissCurrent()+ /// What the list says after an action: why it failed, or that an enabled job left the list until macOS loads it.+ enum ActionAlert {+ case failed(ActionFailure)+ case enabledUntilLoaded(label: String, kind: BackgroundItem.Kind)+ }++ func dismissAlert() {+ alerts.dismissCurrent()+ }++ /// A job enabled while launchd doesn't have it leaves the list, since it is listed only while disabled or loaded.+ static func alertAfterEnabling(_ item: BackgroundItem, listed: [BackgroundItem]?) -> ActionAlert? {+ guard let listed, !listed.contains(where: { $0.id == item.id }) else { return nil }+ return .enabledUntilLoaded(label: item.label, kind: item.kind)}/// Runs `action` on `item`, then scans again. What a move to the Trash moved and refused goes to `record` before@@ -69,11 +81,14 @@ final class BackgroundItemLibrary {) async {runningActionItemIDs.insert(item.id)defer { runningActionItemIDs.remove(item.id) }+ var isEnabled = falsedo {switch action {case .start: try await BackgroundItemActions.start(item)case .stop: try await BackgroundItemActions.stop(item)- case .enable: try await BackgroundItemActions.setEnabled(true, for: item)+ case .enable:+ try await BackgroundItemActions.setEnabled(true, for: item)+ isEnabled = truecase .disable: try await BackgroundItemActions.setEnabled(false, for: item)case .moveToTrash:let exclusions = ExclusionsStore.shared.exclusions@@ -84,16 +99,21 @@ final class BackgroundItemLibrary {return moved}if let refusal = moved.result.failures.first {- failures.add(ActionFailure(label: item.label, action: action, reason: .trash(refusal.reason)))+ let failure = ActionFailure(label: item.label, action: action, reason: .trash(refusal.reason))+ alerts.add(.failed(failure))}if let reason = moved.stillRunning {- failures.add(ActionFailure(label: item.label, action: action, reason: reason, fileMoved: true))+ let failure = ActionFailure(label: item.label, action: action, reason: reason, fileMoved: true)+ alerts.add(.failed(failure))}}} catch {- failures.add(ActionFailure(label: item.label, action: action, reason: error))+ alerts.add(.failed(ActionFailure(label: item.label, action: action, reason: error)))}await refresh(installedApps: installedApps)+ if isEnabled, let alert = Self.alertAfterEnabling(item, listed: items) {+ alerts.add(alert)+ }}}diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swiftindex 23597dce..88ba8920 100644--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift@@ -70,10 +70,10 @@ struct BackgroundItemList: View {.rescanAfterPutBack(.backgroundItems) { await backgroundItems.refresh(installedApps: library.apps) }// Shown from the list, which stays on screen. An alert on the item's page would vanish with the page if// the rescan after the action removed the item, and then show up on the next item the user opens.- .alert(failureTitle, isPresented: isShowingFailure) {+ .alert(alertTitle, isPresented: isShowingAlert) {Button("OK", role: .cancel) {}} message: {- failureMessage+ alertMessage}}@@ -84,15 +84,33 @@ struct BackgroundItemList: View {return .content}- private var isShowingFailure: Binding<Bool> {+ private var isShowingAlert: Binding<Bool> {Binding(- get: { backgroundItems.failures.current != nil },- set: { if !$0 { backgroundItems.dismissFailure() } }+ get: { backgroundItems.alerts.current != nil },+ set: { if !$0 { backgroundItems.dismissAlert() } })}- private var failureTitle: Text {- guard let failure = backgroundItems.failures.current else { return Text(verbatim: "") }+ private var alertTitle: Text {+ switch backgroundItems.alerts.current {+ case .failed(let failure)?: failureTitle(failure)+ case .enabledUntilLoaded(let label, _)?: Text("“\(label)” is enabled.")+ case nil: Text(verbatim: "")+ }+ }++ private var alertMessage: Text {+ switch backgroundItems.alerts.current {+ case .failed(let failure)?: failureMessage(failure)+ case .enabledUntilLoaded(_, .daemon)?:+ Text("It isn’t loaded now, so it leaves this list until macOS loads it again, usually when the Mac restarts.")+ case .enabledUntilLoaded?:+ Text("It isn’t loaded now, so it leaves this list until macOS loads it again, usually the next time you log in.")+ case nil: Text(verbatim: "")+ }+ }++ private func failureTitle(_ failure: BackgroundItemLibrary.ActionFailure) -> Text {let label = failure.labelreturn switch failure.action {case .start: Text("“\(label)” couldn’t be started.")@@ -104,21 +122,20 @@ struct BackgroundItemList: View {}}- private var failureMessage: Text {- let reason = reasonMessage- guard backgroundItems.failures.current?.fileMoved == true else { return reason }+ private func failureMessage(_ failure: BackgroundItemLibrary.ActionFailure) -> Text {+ let reason = reasonMessage(failure.reason)+ guard failure.fileMoved else { return reason }return Text("\(reason)\n\n\(Text("macOS won’t start it again: it stops for good when the Mac restarts."))")}- private var reasonMessage: Text {- switch backgroundItems.failures.current?.reason {+ private func reasonMessage(_ reason: BackgroundItemActions.Failure) -> Text {+ switch reason {case .requiresPrivileges: Text("It needs administrator access, which Peel’s helper provides.")case .noFileToMove: Text("This one comes from the app itself, so there is no file to move. Remove the app to get rid of it.")case .launchctl(let output): Text(verbatim: FixedSentence.translated(output))case .trash(let reason): Text(verbatim: reason.explanation)case .disabled: Text("macOS won’t load this while it is disabled. Enable it first, then start it.")case .quarantinedPlist: Text("macOS won’t load this: its configuration file carries the mark macOS puts on downloads. Reinstalling the app that put it there may write it again without the mark.")- case nil: Text(verbatim: "")}}diff --git a/PeelTests/BackgroundItemLibraryTests.swift b/PeelTests/BackgroundItemLibraryTests.swiftnew file mode 100644index 00000000..619921a0--- /dev/null+++ b/PeelTests/BackgroundItemLibraryTests.swift@@ -0,0 +1,23 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++struct BackgroundItemLibraryTests {+ @Test func anEnabledJobThatLeftTheListSaysWhenItComesBack() {+ let job = BackgroundItem(+ label: "org.example.agent", kind: .agent, source: .app, plistURL: nil, program: nil, runsAtLoad: nil,+ keepsAlive: nil, ownerBundleIdentifier: "org.example.app", ownerName: "App",+ ownerURL: URL(filePath: "/Applications/App.app", directoryHint: .isDirectory), isOrphan: false,+ state: .notLoaded, isDisabled: true+ )++ let left = BackgroundItemLibrary.alertAfterEnabling(job, listed: [])+ guard case .enabledUntilLoaded(let label, let kind)? = left else {+ Issue.record("no alert for a job that left the list")+ return+ }+ #expect(label == "org.example.agent" && kind == .agent)+ #expect(BackgroundItemLibrary.alertAfterEnabling(job, listed: [job]) == nil)+ }+}