font size setting

This commit is contained in:
Ian Gulliver
2026-10-20 19:32:27 -07:00
parent f2188c53eb
commit adb9424e66
9 changed files with 95 additions and 4 deletions
+5 -1
View File
@@ -171,7 +171,11 @@ A Mac that runs the server but not the app is updated by `byre-update` (`mac/Sou
## Persistence
`Persistence.swift` holds the app's state in SwiftData, synced through CloudKit to the private database of container `iCloud.run.fc.byre.mac`, so it follows the iCloud account to every Mac: `ServerRecord` (one per saved server: its origin and `color`, an index into the task colours), `DraftRecord` (drafts, see "Drafts") and `VisitRecord` (one per task: when it was last selected, read by the task switcher). Each load of the saved servers deletes every `ServerRecord` saved before `tailnetServersSince` in `Startup.swift` (on every Mac, through iCloud): those are `tailscale serve` origins from before byre had its own node, and servers are added again by their node's origin. Records saved later, on any Mac, are kept. CloudKit has no unique constraints, so two Macs can each create a record for the same thing; readers take the oldest `ServerRecord` per origin, the newest `DraftRecord` and the latest `VisitRecord` per task; the next draft or visit write keeps one and deletes the rest, and Forget Server deletes every record for its origin. The store is `byre.store` in `run.fc.byre.mac` under Application Support (the app isn't sandboxed, so SwiftData's default `default.store` would be shared with every other unsandboxed app). It opens at launch and the app exits if it can't, which is what an unsigned build without the iCloud entitlement does. `Servers.sync` is the iCloud sync state, from the latest finished CloudKit setup, import and export, which Settings shows under iCloud sync and every connection reports to its server (`docs/operations.md`, "Storage"). Forget Server (in the app menu) flushes that server's drafts, reports pane focus false, drops its store and streams, and shows the connection screen again, its field holding the forgotten origin. Quitting does the same flush and report for every server at once, waiting up to 2 s for the reports before exiting (`applicationShouldTerminate` in `ByreApp.swift`).
`Persistence.swift` holds the app's state in SwiftData, synced through CloudKit to the private database of container `iCloud.run.fc.byre.mac`, so it follows the iCloud account to every Mac: `ServerRecord` (one per saved server: its origin and `color`, an index into the task colours), `DraftRecord` (drafts, see "Drafts"), `VisitRecord` (one per task: when it was last selected, read by the task switcher) and `PrefsRecord` (the user's font size, see "Font size"). Each load of the saved servers deletes every `ServerRecord` saved before `tailnetServersSince` in `Startup.swift` (on every Mac, through iCloud): those are `tailscale serve` origins from before byre had its own node, and servers are added again by their node's origin. Records saved later, on any Mac, are kept. CloudKit has no unique constraints, so two Macs can each create a record for the same thing; readers take the oldest `ServerRecord` per origin, the newest `PrefsRecord`, the newest `DraftRecord` and the latest `VisitRecord` per task; the next draft or visit write keeps one and deletes the rest, and Forget Server deletes every record for its origin. The store is `byre.store` in `run.fc.byre.mac` under Application Support (the app isn't sandboxed, so SwiftData's default `default.store` would be shared with every other unsandboxed app). It opens at launch and the app exits if it can't, which is what an unsigned build without the iCloud entitlement does. `Servers.sync` is the iCloud sync state, from the latest finished CloudKit setup, import and export, which Settings shows under iCloud sync and every connection reports to its server (`docs/operations.md`, "Storage"). Forget Server (in the app menu) flushes that server's drafts, reports pane focus false, drops its store and streams, and shows the connection screen again, its field holding the forgotten origin. Quitting does the same flush and report for every server at once, waiting up to 2 s for the reports before exiting (`applicationShouldTerminate` in `ByreApp.swift`).
## Font size
Settings' Font size stepper sets the body text size, within `FontSize.range`, defaulting to `PrefsRecord.defaultFontSize`. It is one value for every server and every Mac: the newest `PrefsRecord`, which `FontSize` in `Fonts.swift` reads at launch and after each iCloud import, and which the stepper writes. Call sites give their sizes for a 13-point body (`Fonts.font(13)`, `Fonts.font(11)` for captions), and `Fonts` shifts every one by the chosen size minus 13, so captions, headings, Markdown, diagrams and the terminal move together. `Fonts.font` and `Fonts.ns` read `FontSize.shared` on the main actor, so Observation re-renders every view that drew text when it changes; the terminal sets its new font in `updateNSView`.
## Gaps in SwiftUI