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.

Lead from an extension to its app's page, not to the extension

Țugui Dragoșd5ab6708fd1d
diff --git a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
index e611664c..43ef2148 100644
--- a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
@@ -135,6 +135,18 @@ extension AppExtension {
return kind == .systemExtension && category == "com.apple.system_extension.network_extension"
}
+ /// The app it came with while that app is there: the outermost app around an app extension, as for its name, or
+ /// the app macOS's record names for a system extension. Nil when Peel can't tell, or the app is gone.
+ public var appURL: URL? {
+ switch kind {
+ case .appExtension:
+ guard let path = url?.path(percentEncoded: false), let end = path.range(of: ".app/") else { return nil }
+ return URL(filePath: String(path[..<end.lowerBound]) + ".app", directoryHint: .isDirectory)
+ case .systemExtension:
+ return goneApp == nil ? installedFor.map { URL(filePath: $0, directoryHint: .isDirectory) } : nil
+ }
+ }
+
/// The name of the app it came with, also once that app is gone.
public var appName: String? {
owner ?? goneApp.map { URL(filePath: $0).deletingPathExtension().lastPathComponent }
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
index 8fb59023..a9a6e312 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
@@ -24,6 +24,30 @@ struct AppExtensionsTests {
#expect(extensionOf("com.apple.FinderSync").showsItsState)
}
+ @Test func knowsTheAppAnExtensionCameWith() {
+ func part(_ path: String) -> AppExtension {
+ AppExtension(
+ identifier: "org.example.app.part", name: "Part", kind: .appExtension, point: "com.apple.FinderSync",
+ owner: "Example", url: URL(filePath: path), election: .on, teamIdentifier: nil, reportedState: nil
+ )
+ }
+ func systemExtension(gone: Bool) -> AppExtension {
+ AppExtension(
+ identifier: "org.example.filter", name: "Filter", kind: .systemExtension, point: nil, owner: "Example",
+ url: URL(filePath: "/Library/SystemExtensions/1/org.example.filter.systemextension"), election: .on,
+ teamIdentifier: nil, reportedState: "activated enabled", installedFor: "/Applications/Example.app",
+ goneApp: gone ? "/Applications/Example.app" : nil
+ )
+ }
+ let example = URL(filePath: "/Applications/Example.app", directoryHint: .isDirectory)
+
+ #expect(part("/Applications/Example.app/Contents/PlugIns/Part.appex").appURL == example)
+ #expect(part("/Applications/Example.app/Contents/Library/LoginItems/Helper.app/Contents/PlugIns/Part.appex").appURL == example)
+ #expect(part("/Library/Application Support/Part.appex").appURL == nil)
+ #expect(systemExtension(gone: false).appURL == example)
+ #expect(systemExtension(gone: true).appURL == nil, "an app that is gone has no page to open")
+ }
+
@Test func readsWhatPluginkitSaysAboutEachExtension() {
let line = " net.whatsapp.WhatsApp.Intents(26.37.22)\t99D7BB9C-5DFD\t2026-09-17 18:44:09 +0000\t/Applications/WhatsApp.app/Contents/PlugIns/Intents.appex"
let parsed = AppExtensions.parse(line)
diff --git a/Peel/Views/Extensions/ExtensionDetailView.swift b/Peel/Views/Extensions/ExtensionDetailView.swift
index 6c2bb4db..c8d13a1b 100644
--- a/Peel/Views/Extensions/ExtensionDetailView.swift
+++ b/Peel/Views/Extensions/ExtensionDetailView.swift
@@ -27,11 +27,25 @@ struct ExtensionDetailView: View {
}
if let owner = item.appName {
LabeledContent("Comes with") {
- VStack(alignment: .trailing, spacing: 1) {
- Text(verbatim: owner)
- if item.goneApp != nil {
- Text("No longer installed")
- .font(.caption)
+ HStack(spacing: 8) {
+ VStack(alignment: .trailing, spacing: 1) {
+ Text(verbatim: owner)
+ if item.goneApp != nil {
+ Text("No longer installed")
+ .font(.caption)
+ }
+ }
+ if let app = item.appURL {
+ Button {
+ Navigator.shared.requestedApp = app
+ Navigator.shared.requestedTool = .applications
+ } label: {
+ Label("Review in Applications", systemImage: "square.grid.2x2")
+ .minimumTarget()
+ }
+ .labelStyle(.iconOnly)
+ .buttonStyle(.borderless)
+ .help(Text("Review in Applications"))
}
}
}
@@ -65,21 +79,12 @@ struct ExtensionDetailView: View {
if let url = item.url {
Section {
- HStack(spacing: 8) {
- Text(url.abbreviatedPath)
- .lineLimit(1)
- .truncationMode(.middle)
- Spacer(minLength: 8)
- Button {
- NSWorkspace.shared.activateFileViewerSelecting([url])
- } label: {
- Label("Show in Finder", systemImage: "arrow.up.forward.app")
- .minimumTarget()
- }
- .labelStyle(.iconOnly)
- .buttonStyle(.borderless)
- .help(Text("Show in Finder"))
- }
+ // Not in Finder: moved alone, an extension breaks its app, or leaves macOS a record with no copy.
+ Text(url.abbreviatedPath)
+ .lineLimit(1)
+ .truncationMode(.middle)
+ .textSelection(.enabled)
+ .help(Text(verbatim: url.path(percentEncoded: false)))
} header: {
Text("Where")
}