Open History to see the last commit
1import SwiftUI
2
3struct FeatureToolActivityIcon: View {
4 let presentation: ToolActivityPresentation?
5 let context: MarkdownImageContext?
6 @SwiftUI.Environment(\.colorScheme) private var colorScheme
7 @State private var nativeURL: URL?
8
9 private var url: URL? {
10 nativeURL ?? (colorScheme == .dark ? presentation?.darkURL ?? presentation?.lightURL : presentation?.lightURL)
11 }
12
13 private var fallback: String {
14 switch presentation?.surface {
15 case "browser": "globe"
16 case "computer": "desktopcomputer"
17 default: "terminal"
18 }
19 }
20
21 var body: some View {
22 AsyncImage(url: url) { image in
23 image.resizable().scaledToFit()
24 } placeholder: {
25 Image(systemName: fallback)
26 }
27 .frame(width: 16, height: 16)
28 .accessibilityHidden(true)
29 .task(id: presentation) {
30 nativeURL = nil
31 guard let context, let app = presentation?.nativeApp else { return }
32 let url = try? await context.resolver.nativeAppIconURL(threadID: context.threadID, app: app)
33 guard !Task.isCancelled else { return }
34 nativeURL = url
35 }
36 }
37}