import AppKit import SwiftUI /// Resolves only for visible rows; the task is keyed by process identity and executable path. struct ProcessIcon: View { let process: ProcessMetrics @State private var icon: NSImage? var body: some View { Group { if let icon { Image(nsImage: icon).resizable().interpolation(.high) } else { Image(systemName: "app.dashed").resizable().scaledToFit().padding(2) } } .frame(width: 15, height: 15) .accessibilityHidden(true) .task(id: "\(process.id)-\(process.path ?? "")") { guard PanelResourceAudit.omitted != "icons" else { return } // Resolve by the sampled executable, avoiding an icon from a reused PID. guard let path = process.path else { icon = nil; return } icon = ProcessIconCache.shared.image(for: path) } } }