Cache task events on disk per server; fix performance audit findings

This commit is contained in:
Ian Gulliver
2026-10-23 12:49:43 -07:00
parent dc2fcc6075
commit d6be98f9d8
13 changed files with 448 additions and 250 deletions
+2
View File
@@ -48,6 +48,8 @@ The update UI must not offer Skip or turning automatic updates off: on a Mac run
CloudKit has no unique constraints, so two Macs can each create a record for the same thing; duplicate records are expected. See `docs/operations.md`, "CloudKit schema", before changing the SwiftData models. The store is named `byre.store` because the app isn't sandboxed, so SwiftData's default `default.store` would be shared with every other unsandboxed app. Deleting the local files while the app isn't running makes the next launch download the records again.
Each task's events are cached on disk per server, under `run.fc.byre.mac/events/<server host>/` in Application Support, so a launch fetches only the events newer than the cached ones. Events never change, so the cache is keyed on the one thing that rewrites them: the `schema` fingerprint in `/api/status` (the server's applied migrations), and the whole server's cache is dropped when it differs. A task's file goes when the task closes, and a file that stops decoding is cut at its last good line, with the rest fetched again. A server restart replaces the Store while the old one still shows the transcripts, so each connection's cache opens with a generation and takes appends only from feeds loaded under the current one; a file is only ever extended by a writer that read it first.
## Gaps in SwiftUI
Places where SwiftUI alone may fall short, each checked side by side against its fallback; the fallback is used only where the check failed: