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
Name what runs under an orphaned group's identifier
Țugui Dragoșbb1c4cd380ee
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 24ea46e5..2cc7b076 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -6570,6 +6570,112 @@}}},+ "%@ is running now, so these may still be in use" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikace %@ teď běží, takže se tyto soubory možná ještě používají"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ läuft gerade, daher werden diese möglicherweise noch verwendet"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ se está ejecutando ahora, así que puede que estos archivos aún estén en uso"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ est en cours d’exécution : ces fichiers sont donc peut-être encore utilisés"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ è in esecuzione ora, quindi questi file potrebbero essere ancora in uso"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”は現在実行中のため、これらはまだ使用中の可能性があります"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’이(가) 지금 실행 중이므로 이 항목이 아직 사용 중일 수 있음"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ is nu actief, dus deze zijn misschien nog in gebruik"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ działa teraz, więc te pliki mogą być jeszcze używane"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ está em execução agora, então estes itens podem ainda estar em uso"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ rulează acum, așa că acestea ar putea fi încă în uz"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Программа «%@» сейчас выполняется, поэтому эти файлы, возможно, еще используются"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ körs just nu, så dessa kanske fortfarande används"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ şu anda çalışıyor, bu yüzden bunlar hâlâ kullanımda olabilir"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Програма «%@» зараз працює, тож ці елементи, можливо, ще використовуються"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”正在运行,因此这些文件可能仍在使用中"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "「%@」正在執行,因此這些項目可能仍在使用中"+ }+ }+ }+ },"%@ is up to date" : {"localizations" : {"cs" : {@@ -189615,112 +189721,6 @@}}},- "Something with this identifier is running now" : {- "localizations" : {- "cs" : {- "stringUnit" : {- "state" : "translated",- "value" : "Něco s tímto identifikátorem teď běží"- }- },- "de" : {- "stringUnit" : {- "state" : "translated",- "value" : "Etwas mit dieser ID läuft gerade"- }- },- "es" : {- "stringUnit" : {- "state" : "translated",- "value" : "Algo con este identificador se está ejecutando ahora"- }- },- "fr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Un élément portant cet identifiant est en cours d’exécution"- }- },- "it" : {- "stringUnit" : {- "state" : "translated",- "value" : "Qualcosa con questo identificatore è in esecuzione ora"- }- },- "ja" : {- "stringUnit" : {- "state" : "translated",- "value" : "この識別子を持つものが現在実行中"- }- },- "ko" : {- "stringUnit" : {- "state" : "translated",- "value" : "이 식별자를 가진 무언가가 지금 실행 중임"- }- },- "nl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Er is nu iets met deze ID actief"- }- },- "pl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Coś z tym identyfikatorem jest teraz uruchomione"- }- },- "pt" : {- "stringUnit" : {- "state" : "translated",- "value" : "Algo com este identificador está em execução agora"- }- },- "ro" : {- "stringUnit" : {- "state" : "translated",- "value" : "Ceva cu acest identificator rulează acum"- }- },- "ru" : {- "stringUnit" : {- "state" : "translated",- "value" : "Сейчас выполняется что-то с этим идентификатором"- }- },- "sv" : {- "stringUnit" : {- "state" : "translated",- "value" : "Något med den här identifieraren körs just nu"- }- },- "tr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Bu tanıtıcıya sahip bir şey şu anda çalışıyor"- }- },- "uk" : {- "stringUnit" : {- "state" : "translated",- "value" : "Щось із цим ідентифікатором зараз працює"- }- },- "zh-Hans" : {- "stringUnit" : {- "state" : "translated",- "value" : "带有此标识符的某个程序正在运行"- }- },- "zh-Hant" : {- "stringUnit" : {- "state" : "translated",- "value" : "有使用此識別碼的項目正在執行"- }- }- }- },"Sort By" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 5a43994a..6310b1a0 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -104,7 +104,12 @@ struct OrphansCommand: AsyncParsableCommand {// The same signals the app uses (the apps Peel remembers, the apps running, and what uninstalls left for an// administrator), so both judge these files alike. What Peel remembers is only read here, never written.let remembered = await AppMemory().load()- let running = Set(await RunningCopies.current.compactMap(\.bundleIdentifier))+ let running = Dictionary(+ await RunningCopies.current.compactMap { process in+ process.bundleIdentifier.map { ($0, process.name ?? $0) }+ },+ uniquingKeysWith: { first, _ in first }+ )let exclusions = await UnreadableExclusions.load()let scanner = OrphanScanner(exclusions: exclusions)let owners = OrphanOwners().load()diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 710137e7..54638802 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -516,7 +516,7 @@ extension OrphanConfidence {/// The strongest reason behind the judgment, the same one the app shows, in the command line's plain English.var summary: String {switch reasons.first {- case .running: "something with this identifier is running now"+ case .running(let name): "\(Output.plain(name)) is running now, so these may still be in use"case .leadsIntoAnAppThatIsGone: "these links lead into an app that is no longer there"case .onlyTheName(let name): "only the name ties these to \(Output.plain(name)), which Peel saw installed"case .writtenRecently(let date): "modified on \(Output.day(date)), so something may still use these files"diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/RunningCopies.swift b/Packages/PeelCore/Sources/PeelCore/Apps/RunningCopies.swiftindex 06992df4..d737b557 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/RunningCopies.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/RunningCopies.swift@@ -18,6 +18,11 @@ public enum RunningCopies {self.bundleURL = bundleURLself.mayBeQuit = mayBeQuit}++ /// The name a person knows it by: its bundle's name as Finder shows it, else its identifier.+ public var name: String? {+ bundleURL.map(AppInspector.displayName) ?? bundleIdentifier+ }}@MainActordiff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swiftindex 376eaa2f..246e1a81 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift@@ -32,8 +32,8 @@ public struct OrphanConfidence: Sendable, Hashable {case writtenAfterItLeft(name: String, written: Date)/// An app by the same maker is still installed, and apps by one maker can share group folders.case sameMakerStillInstalled- /// Something with this identifier is running right now.- case running+ /// Something with this identifier, by this name, is running right now.+ case running(String)/// Links into an app that is gone, so they lead nowhere.case leadsIntoAnAppThatIsGone/// Only the name of an app Peel saw installed ties these files to it.@@ -66,12 +66,15 @@ public struct OrphanConfidence: Sendable, Hashable {public static func judge(_ group: OrphanGroup,installedTeams: Set<String> = [],- running: Set<String> = [],+ running: [String: String] = [:],now: Date = .now) -> OrphanConfidence {let declared = group.rememberedApp?.bundleIdentifier.lowercased()- if running.contains(where: { isOneApp($0.lowercased(), group.identifier.lowercased(), declared: declared) }) {- return OrphanConfidence(level: .unsure, reasons: [.running])+ let isTheGroups = { (identifier: String) in+ isOneApp(identifier.lowercased(), group.identifier.lowercased(), declared: declared)+ }+ if let match = running.keys.sorted().first(where: isTheGroups) {+ return OrphanConfidence(level: .unsure, reasons: [.running(running[match] ?? match)])}// A plug-in's row says so and isn't recommended, while what else the app left is judged by the signs below.if group.items.allSatisfy({ $0.heldBack == .loadedByOtherApps }) {diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex 564396d3..3861b1eb 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -61,14 +61,14 @@ public struct OrphanScanner: Sendable {////// `installedApps` must be the complete list: anything it does not claim can be reported as orphaned./// `remembered` holds the apps Peel has seen installed before, so a group can be named after the app that- /// left it. `running` holds the bundle identifiers of what is running now: a helper or an agent can keep a+ /// left it. `running` names what is running now by its bundle identifier: a helper or an agent can keep a/// folder that no app bundle claims, and while it runs, its group is marked unsure. `owners` are the groups the/// person said belong to an app (`OrphanOwners`), left out while that app is installed.@concurrentpublic func scan(installedApps: [InstalledApp],remembered: [RememberedApp] = [],- running: Set<String> = [],+ running: [String: String] = [:],owners: [String: String] = [:],leftForAnAdministrator records: [LeftForAnAdministrator.Record] = []) async -> OrphanScan {@@ -509,7 +509,7 @@ public struct OrphanScanner: Sendable {_ found: [(identifier: String, item: OrphanItem)],remembered: [RememberedApp] = [],installedTeams: Set<String> = [],- running: Set<String> = [],+ running: [String: String] = [:],now: Date = .now) -> [OrphanGroup] {let roots = Set(found.map { groupingKey(for: $0.identifier).lowercased() }).sorted { $0.count < $1.count }diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swiftindex 4b07a2ac..dc4223ae 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift@@ -294,7 +294,7 @@ public enum SpaceRemoval {var names: [String: String] = [:]for process in running {let bundle = process.bundleURL?.deletingPathExtension().lastPathComponent- guard let displayed = name(of: process) else { continue }+ guard let displayed = process.name else { continue }let spellings = [process.bundleIdentifier,process.bundleIdentifier?.split(separator: ".").last.map(String.init),@@ -315,14 +315,10 @@ public enum SpaceRemoval {}/// The name a plan gives an open app, the one the person knows: Finder's, else its identifier.- static func name(of process: RunningCopies.Process) -> String? {- process.bundleURL.map(AppInspector.displayName) ?? process.bundleIdentifier- }-/// Those of `apps`, named as a plan names them (`Plan.appsToQuit`), that `running` no longer holds.@concurrentpublic static func quit(of apps: [String], running: [RunningCopies.Process]) async -> [String] {- let open = Set(running.compactMap(name(of:)))+ let open = Set(running.compactMap(\.name))return apps.filter { !open.contains($0) }}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 87f42481..83e7441f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -366,7 +366,7 @@ struct FileCommandTests {var group = OrphanGroup(identifier: "com.example.gone", items: [])#expect(OrphansCommand.unsureNote(for: group).isEmpty)- group.confidence = OrphanConfidence(level: .unsure, reasons: [.running])+ group.confidence = OrphanConfidence(level: .unsure, reasons: [.running("Example")])#expect(OrphansCommand.unsureNote(for: group) == ["unsure: \(group.confidence.summary)"])}@@ -828,6 +828,11 @@ struct FileCommandTests {#expect(OrphanConfidence(level: .certain, reasons: [.untouched(months: 7)]).summary == "not modified in 7 months")}+ @Test func namesWhatIsRunningUnderAnOrphanGroupsIdentifier() {+ let running = OrphanConfidence(level: .unsure, reasons: [.running("Example Helper")]).summary+ #expect(running == "Example Helper is running now, so these may still be in use")+ }+@Test func namesTheFolderThatKeepsAProjectSearchOut() throws {let directory = try TemporaryDirectory()let installed = try directory.directory("Code/app/node_modules/org-example-dep")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swiftindex 7c641f74..7957bf0c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift@@ -75,9 +75,9 @@ struct OrphanConfidenceTests {@Test("Something running under that identifier settles it, whatever else is true")func runningOutranksEverything() {let old = group(written: 400 * 24 * 60 * 60, remembered: left("Example"))- let judged = OrphanConfidence.judge(old, running: ["com.example.app"], now: now)+ let judged = OrphanConfidence.judge(old, running: ["com.example.app": "Example"], now: now)#expect(judged.level == .unsure)- #expect(judged.reasons == [.running])+ #expect(judged.reasons == [.running("Example")])}@Test("A folder written this week belongs to something that still runs, even if no app claims it")@@ -144,31 +144,31 @@ struct OrphanConfidenceTests {lastPath: "/Applications/Example.app")let itsOwn = group(identifier: "md.example", written: 400 * 24 * 60 * 60, remembered: gone)- #expect(OrphanConfidence.judge(itsOwn, running: ["md.example.helper"], now: now).reasons == [.running])+ #expect(OrphanConfidence.judge(itsOwn, running: ["md.example.helper": "Running md.example.helper"], now: now).reasons == [.running("Running md.example.helper")])let nobodysPrefix = group(identifier: "md.example", written: 400 * 24 * 60 * 60)- #expect(OrphanConfidence.judge(nobodysPrefix, running: ["md.example.helper"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(nobodysPrefix, running: ["md.example.helper": "Running md.example.helper"], now: now).level == .certain)}@Test("What is running is matched the way an app is: a helper runs under its app's identifier and a longer one")func aRunningHelperOrItsAppBothCount() {let old = group(identifier: "com.example.app", written: 400 * 24 * 60 * 60)- #expect(OrphanConfidence.judge(old, running: ["com.example.app.helper"], now: now).reasons == [.running])- #expect(OrphanConfidence.judge(old, running: ["COM.EXAMPLE.APP"], now: now).reasons == [.running])+ #expect(OrphanConfidence.judge(old, running: ["com.example.app.helper": "Running com.example.app.helper"], now: now).reasons == [.running("Running com.example.app.helper")])+ #expect(OrphanConfidence.judge(old, running: ["COM.EXAMPLE.APP": "Running COM.EXAMPLE.APP"], now: now).reasons == [.running("Running COM.EXAMPLE.APP")])let helper = group(identifier: "com.example.app.helper", written: 400 * 24 * 60 * 60)- #expect(OrphanConfidence.judge(helper, running: ["com.example.app"], now: now).reasons == [.running])+ #expect(OrphanConfidence.judge(helper, running: ["com.example.app": "Running com.example.app"], now: now).reasons == [.running("Running com.example.app")])// Two components name a maker, not an app, and `com.example.apple` is not a helper of `com.example.app`.let other = group(identifier: "com.example.other", written: 400 * 24 * 60 * 60)- #expect(OrphanConfidence.judge(other, running: ["com.example"], now: now).level == .certain)- #expect(OrphanConfidence.judge(old, running: ["com.example.apple"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(other, running: ["com.example": "Running com.example"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(old, running: ["com.example.apple": "Running com.example.apple"], now: now).level == .certain)}@Test("A Safari web app is its own app: Safari running, or another web app, says nothing about it")func safariRunningSaysNothingOfAWebApp() {let identifier = "com.apple.Safari.WebApp.0E4F6A2C-1B3D-4E5F-8A9B-0C1D2E3F4A5B"let webApp = group(identifier: identifier, written: 400 * 24 * 60 * 60)- #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari"], now: now).level == .certain)- #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari.WebApp"], now: now).level == .certain)- #expect(OrphanConfidence.judge(webApp, running: [identifier], now: now).reasons == [.running])+ #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari": "Running com.apple.Safari"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari.WebApp": "Running com.apple.Safari.WebApp"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(webApp, running: [identifier: "Web App"], now: now).reasons == [.running("Web App")])}@Test("An app Peel watched leave is the strongest thing it can say")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 67a5314f..dadc848a 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -668,7 +668,7 @@ struct OrphanScannerTests {}let scan = await scanner(in: directory).scan(- installedApps: installed, remembered: gone, running: ["com.gone.busy"]+ installedApps: installed, remembered: gone, running: ["com.gone.busy": "Busy"])let paths = { (urls: [URL]) in Set(urls.map(PathPattern.comparablePath(of:))) }func group(_ identifier: String) -> OrphanGroup? { scan.groups.first { $0.identifier == identifier } }@@ -680,6 +680,7 @@ struct OrphanScannerTests {#expect(group("com.gone.solo") == nil)#expect(paths(group("com.gone.coin")?.items.map(\.url) ?? []) == paths([coin]))#expect(paths(group("com.gone.busy")?.items.map(\.url) ?? []) == paths([busy]))+ #expect(group("com.gone.busy")?.confidence.reasons == [.running("Busy")])}/// What the walk saw inside may exist nowhere else. A folder with a wallet, a signing key, or a repositorydiff --git a/Packages/PeelCore/Tests/PeelCoreTests/SelectableRowsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SelectableRowsTests.swiftindex 365b4bb3..c0b7872c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SelectableRowsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SelectableRowsTests.swift@@ -217,7 +217,7 @@ struct SelectableRowsTests {requiresPrivileges: false)var group = OrphanGroup(identifier: "org.example.Running", items: [cache])- group.confidence = OrphanConfidence(level: .unsure, reasons: [.running])+ group.confidence = OrphanConfidence(level: .unsure, reasons: [.running("Example")])#expect(group.selectableRows(canUseHelper: true).selectable == [cache.url])#expect(group.selectableRows(canUseHelper: true).recommended.isEmpty)diff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swiftindex 9740b0a7..f4b391e7 100644--- a/Peel/Model/OrphanLibrary.swift+++ b/Peel/Model/OrphanLibrary.swift@@ -73,7 +73,12 @@ final class OrphanLibrary {let remembered = await AppMemory().remember(installedApps)// What is currently running is better evidence than anything worked out from what is installed: a// helper or an agent can keep a folder that no app bundle claims.- let running = Set(NSWorkspace.shared.runningApplications.compactMap(\.bundleIdentifier))+ let running = Dictionary(+ NSWorkspace.shared.runningApplications.compactMap { app in+ app.bundleIdentifier.map { ($0, app.localizedName ?? $0) }+ },+ uniquingKeysWith: { first, _ in first }+ )let scan = await OrphanScanner(exclusions: ExclusionsStore.shared.exclusions).scan(installedApps: installedApps,remembered: remembered,diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 27138692..35b9e91d 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -623,8 +623,8 @@ extension OrphanConfidence {private func text(for reason: Reason?) -> Text {guard let reason else { return Text("No installed app claims these") }return switch reason {- case .running:- Text("Something with this identifier is running now")+ case .running(let name):+ Text("\(name) is running now, so these may still be in use")case .leadsIntoAnAppThatIsGone:Text("These links lead into an app that is no longer there")case .onlyTheName(let name):