dc42db0c59
Replace the single hand-saved rig file with a managed library of named rigs persisted in app storage and synced across devices and both builder apps via a shared iCloud container (iCloud.net.realizedsound.ShoeGazeData), falling back to local storage when iCloud is unavailable. Core (LyrebirdShoeGaze/Presets): - RigEntry: named, timestamped ShoeGazeState (a whole multi-board rig). - RigArchive: portable multi-rig JSON bundle for backup/transfer; legacy single-rig files import as a one-rig archive. - RigLibraryStore (@MainActor @Observable): one JSON file per rig, with NSFileCoordinator writes and NSMetadataQuery live remote-change watching. - RigLibraryLocation: iCloud-or-local directory resolver (skips the slow ubiquity lookup when no iCloud account is signed in). - ShoeGaze.loadRig(from: ShoeGazeState) + captureEntry; shared filename sanitizer factored out of BoardVersionStore. UI (LyrebirdShoeGazeUI): - RigLibrarySidebarView: persistent left listing with new/save/save-as/ duplicate/rename/delete/erase-all and archive import/export. - RigNamePrompt; RigLibraryBootstrap one-call shell setup. - ShoeGazeBuilderView: sidebar wired in; selecting a rig replaces the session; File menu / sidebar do whole-library archive import/export. Shells/entitlements: both builder targets own+start the store and carry the iCloud Documents entitlement; NSUbiquitousContainers exposes the rigs in the Files app. (macOS pbxproj also carries a pre-existing 1.0->1.1.1 version bump.) Tests: RigEntry/RigArchive round-trip + RigLibraryStore CRUD/import/export (15 new; full suite 206 passing). Provisioning (manual, not done here): enable the iCloud container on both App IDs and select it in Signing & Capabilities for both targets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4.2 KiB
4.2 KiB
Rig Library (iCloud-synced rigs)
Replaces the single hand-saved rig file with a managed library of named rigs persisted in app
storage and synced across devices and both apps via a shared iCloud container. A rig is a whole
session (ShoeGazeState) and may contain multiple boards.
What shipped
Core (LyrebirdShoeGaze/Presets/)
RigEntry— a named, timestampedShoeGazeState(rig-level analogue ofBoardVersion).RigArchive— a portable bundle of manyRigEntryin one JSON file (Export/Import Archive). A legacy single-rig file (bareShoeGazeState) imports as a one-rig archive.RigLibraryLocation— resolves the library directory: shared iCloud containerDocuments/Rigs/when available, else local Application Support (LyrebirdShoeGaze/Rigs/).RigLibraryStore(@MainActor @Observable) — one JSON file per rig (<sanitized-name>-<uuid>.json); save/delete/duplicate/rename/eraseAll/import/export. iCloud reads/writes are coordinated viaNSFileCoordinator; remote changes are watched withNSMetadataQueryso a rig saved on one device appears on another live.ShoeGaze.loadRig(from: ShoeGazeState)overload +ShoeGaze.captureEntry(name:id:).sanitizePresetFilenamefactored out ofBoardVersionStoreand shared.
UI (LyrebirdShoeGazeUI/)
RigLibrarySidebarView— persistent left listing; rows show name + timestamp, context menu (Rename / Duplicate / Delete), bottom bar (New / Save / Save As / ⋯ → Import / Export / Erase All), and an iCloud status glyph.RigNamePrompt— shared name-entry alert (New / Save As / Rename / Duplicate).RigLibraryBootstrap— one-call shell setup: resolve location, start the store, seed it from the working rig on first run, resolve the launch highlight.ShoeGazeBuilderViewgains the sidebar; selecting a rig replaces the current session (engine stopped/restarted around the rebuild). The old single-rig Save/Load is gone; the File menu / sidebar now do whole-library Archive import/export.
Shells / entitlements
- macOS
AppDelegateand iOS app model own + start the store and pass it to the view; macOS File menu = Export/Import Archive. - Both builder targets carry the iCloud entitlement for container
iCloud.net.realizedsound.ShoeGazeData;NSUbiquitousContainersexposesDocuments/Rigsin the Files app.
Manual provisioning (required before iCloud sync works)
Code is in place but signing is not provisionable from here. In Xcode, for both builder targets
(ShoeGazeBuilder, ShoeGazeBuilderiOS), under Signing & Capabilities:
- Confirm the iCloud capability is present with iCloud Documents checked and the container
iCloud.net.realizedsound.ShoeGazeDataselected (entitlement files already declare it). - Register that container on both App IDs in the developer account (same Team
HE5VJFE9E4). - Build signed to a device/Mac signed into iCloud to verify cross-device sync.
If iCloud is unavailable the library transparently falls back to local storage (no sync) — the app
still works; the sidebar shows the icloud.slash glyph.
Notes / follow-ups
- Editing a loaded rig does not auto-save to its library entry — Save is explicit.
RigStoreautosave still preserves unsaved working state across restarts.
Known limitations / deferred (from pre-PR review)
- Main-thread iCloud I/O.
RigLibraryLocation.resolve()does a blocking ubiquity lookup, andRigLibraryStore'sNSFileCoordinatorreads/writes run on the main actor. Mitigated for the common case:resolve()short-circuits to local (no blocking call) when no iCloud account is signed in, and coordinated writes only happen on explicit, occasional user saves. A full fix needs an async resolve + a loading state in the builder, and must move seeding after the iCloud state is known — otherwise a first-launch seed races the synced library and creates a spurious "Default" rig on every device. Deferred deliberately. eraseAll()clears the in-memory list even if a file deletion fails (it still throws the first error). A re-start()re-scans and re-surfaces any undeleted rigs, so state self-heals.- Possible later work: conflict UI for simultaneous multi-device edits; the async-resolve redesign above.