git-agent for Swiftgit-agent understands Swift Package Manager layouts, SwiftUI view hierarchies, and actor concurrency patterns, producing conventional commits that reflect iOS and macOS development conventions.
diff --git a/Sources/App/Services/ImageLoader.swift b/Sources/App/Services/ImageLoader.swift
index 6c3d2a1..4f8e9b7 100644
--- a/Sources/App/Services/ImageLoader.swift
+++ b/Sources/App/Services/ImageLoader.swift
@@ -1,14 +1,26 @@
import Foundation
+import OSLog
-class ImageLoader: ObservableObject {
- @Published var image: UIImage?
+@MainActor
+final class ImageLoader: ObservableObject {
+ @Published var image: UIImage?
+ @Published var isLoading = false
- func load(url: URL) {
- URLSession.shared.dataTask(with: url) { data, _, _ in
- if let data = data {
- DispatchQueue.main.async {
- self.image = UIImage(data: data)
- }
- }
- }.resume()
- }
+ private let logger = Logger(subsystem: "com.example.app", category: "ImageLoader")
+
+ func load(url: URL) async {
+ isLoading = true
+ defer { isLoading = false }
+ do {
+ let (data, _) = try await URLSession.shared.data(from: url)
+ image = UIImage(data: data)
+ } catch {
+ logger.error("Failed to load image from \(url): \(error)")
+ }
+ }
}refactor(services): migrate ImageLoader to async/await and MainActor isolation
- annotate with @MainActor to eliminate manual DispatchQueue.main.async dispatch
- convert load(url:) to async throws using URLSession's async data(from:) method
- add isLoading published property with defer-based cleanup
- replace print with OSLog Logger for structured logging
The DispatchQueue approach was not safe under strict concurrency checking;
@MainActor annotation satisfies the compiler and makes the isolation
intent explicit.brew install gitagenthq/tap/git-agent
# inside your Swift project
git-agent init # reads Package.swift targets to suggest scopesDoes git-agent handle Xcode project file changes?Can git-agent work with Swift on Linux?How does git-agent handle SwiftUI previews?