From Gemini refactoring audit (2026-05-04) — LOW.
`MacSlowCooker/XPCClient.swift:30-72` (`fetchHelperVersion`) implements timeout by spawning a parallel `Task` that invalidates the connection on expiry, leveraging the proxy's error handler to resume the continuation. Clever, correct, but specific to NSXPCConnection.
If we ever add another XPC method that needs a bounded timeout (e.g., a future `fetchHelperDiagnostics`), we'll re-implement the same pattern.
Refactor
Extract a generic helper:
```swift
@mainactor
static func withTimeout(
seconds: TimeInterval,
operation: @escaping (NSXPCConnection) async throws -> T,
on connection: NSXPCConnection
) async throws -> T? {
// ... timeout task that invalidates conn on expiry
}
```
The challenge: NSXPCConnection's error-handler-based callback contract doesn't compose cleanly with generic async/await. May need a small actor-based wrapper.
Acceptance
- `fetchHelperVersion` reduces to a thin wrapper around the helper
- Future XPC calls with timeout reuse the same primitive
From Gemini refactoring audit (2026-05-04) — LOW.
`MacSlowCooker/XPCClient.swift:30-72` (`fetchHelperVersion`) implements timeout by spawning a parallel `Task` that invalidates the connection on expiry, leveraging the proxy's error handler to resume the continuation. Clever, correct, but specific to NSXPCConnection.
If we ever add another XPC method that needs a bounded timeout (e.g., a future `fetchHelperDiagnostics`), we'll re-implement the same pattern.
Refactor
Extract a generic helper:
```swift
@mainactor
static func withTimeout(
seconds: TimeInterval,
operation: @escaping (NSXPCConnection) async throws -> T,
on connection: NSXPCConnection
) async throws -> T? {
// ... timeout task that invalidates conn on expiry
}
```
The challenge: NSXPCConnection's error-handler-based callback contract doesn't compose cleanly with generic async/await. May need a small actor-based wrapper.
Acceptance