Skip to content

Move airport/runway fetch to background context in BasePerformanceViewModel#4

Merged
RISCfuture merged 2 commits intomainfrom
worktree-agent-acfeaa3f
Apr 12, 2026
Merged

Move airport/runway fetch to background context in BasePerformanceViewModel#4
RISCfuture merged 2 commits intomainfrom
worktree-agent-acfeaa3f

Conversation

@RISCfuture
Copy link
Copy Markdown
Contributor

Summary

  • Contributes to fixing SF50-TOLD-1X (DB on main thread)
  • Replaces stored `context` property with `container` (no subclasses use `context`)
  • Airport/runway observation task in `setupObservation()` is now `Task.detached`, fetching on a fresh background `ModelContext` per iteration
  • Returns `PersistentIdentifier` values across actor boundaries cleanly, then rehydrates models on `MainActor` via `mainContext.model(for:)` for property assignment

Test plan

  • Unit tests (SF50 Shared Unit Tests) pass
  • UI tests (47 tests, SF50 TOLD UI Tests) pass
  • swift format + swiftlint clean

🤖 Generated with Claude Code

RISCfuture and others added 2 commits April 11, 2026 17:20
…wModel

Contributes to fixing SF50-TOLD-1X (DB on main thread). The airport
and runway observation task in setupObservation() previously used
container.mainContext for findAirportAndRunway fetches, causing
SwiftData queries to run on the main thread.

Replaces the stored context property with container. The observation
task is now Task.detached, fetching on a fresh background ModelContext
per iteration. Results are returned as PersistentIdentifier values
that cross actor boundaries cleanly, then rehydrated on MainActor via
mainContext.model(for:) for property assignment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Drops the nonisolated static fetchAirportAndRunwayIDs helper in favor
of inlining the fetch and PersistentIdentifier extraction directly in
the Task.detached closure.

SwiftData @model types cannot be safely sent across isolation
boundaries under strict concurrency, so PersistentIdentifier (a
Sendable value type) is extracted on the background context and the
model is rehydrated via mainContext.model(for:) on MainActor.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@RISCfuture RISCfuture merged commit ecbe48c into main Apr 12, 2026
4 checks passed
@RISCfuture RISCfuture deleted the worktree-agent-acfeaa3f branch April 12, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant