8 Commits

Author SHA1 Message Date
josh 9873dd258b fix(rigs): don't let starter overwrites be reverted by reseeding
External-review findings for 3.1.0:

- A starter rig can no longer be overwritten in place. Saving over a loaded
  starter previously stored the edited content under the rig's fixed factory
  id, so the next starter-catalog update (or Restore Starter Rigs) would
  silently revert it to the shipped version. The confirmation now offers only
  Save as New Rig / Cancel — a starter is managed content, and the player's
  changes are kept as their own rig (a new id) instead.
- restoreStarterRigs advances the seed-version marker only on success, matching
  start(), so a failed manual restore no longer suppresses the next launch's
  automatic catch-up seed.
- CHANGELOG: correct the starter-rig count (18, not 19).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-13 10:38:26 -07:00
josh 5decdd8693 fix(rigs): refresh stale starters on update; tab follows current rig
- Seeding now (re)installs every starter by stable id, so a corrected rig
  definition replaces the stale copy already in a library (save upserts by
  id, keeping its position) — user rigs untouched. Bumped seedVersion to 2
  so existing libraries pick up the two-board Garcia rig (the old router
  version showed "No board at index 0" because the builder UI renders boards,
  not routers, and the stale entry was never refreshed). "Restore Starter
  Rigs" likewise refreshes all starters, not just missing ones.
- The Mine/Starters toggle now opens on the group containing the currently
  loaded rig (Starters when a factory rig like Garcia is active, else Mine),
  and follows the selection when the current rig changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-09 17:57:57 -07:00
josh ad6ed41674 feat(ui): Mine/Starters rig toggle + seed starters into existing libraries
Two fixes so shipped starter rigs are actually reachable:

- Seeding no longer requires an empty library. On launch it installs any
  factory rigs whose stable ids are missing, once per FactoryRigLibrary
  .seedVersion (a per-device UserDefaults marker). Existing users therefore
  receive the starters on their next launch; a starter the user later
  deletes stays deleted (the marker has advanced); bumping seedVersion when
  new starters ship re-runs catch-up for just the new ones. Idempotent by id,
  so iCloud-synced devices never duplicate.
- Sidebar gains a segmented Mine / Starters toggle. "Mine" is the flat,
  reorderable user list; "Starters" groups the shipped rigs by category. A
  "Restore Starter Rigs" action (Starters empty-state button + library menu)
  re-installs missing starters on demand via RigLibraryBootstrap.restoreStarterRigs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-09 14:11:22 -07:00
josh 2c970aa344 refactor(rigs): address external-review findings
- Recall router state in applyState: the lightweight (no-rebuild) recall path
  now positionally applies router branch pedal params and the splitter/merger
  blend, instead of silently dropping them for routed rigs. Test added.
- Simplify first-run seeding: RigLibraryStore.save persists asynchronously
  (best-effort, logged not thrown), so the previous per-entry rollback could
  never fire for a real disk failure. Replaced with an honest best-effort
  save + working-rig fallback, and a comment stating the semantics.
- Move FactoryRigBuild to its own file (one public type per file).
- Document that a router's output master gain is intentionally not persisted,
  matching BoardState's treatment of board master gain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-09 13:32:58 -07:00
josh 4eb1cbdd61 feat(rigs): ship built-in factory starter rigs
Add a factory rig library: 8 curated starter pedalboard rigs seeded into
an empty rig library on first launch. Rigs are compile-checked builders
(construct concrete pedals, set typed @UIParam values, board.add) rather
than hand-written JSON, so a renamed pedal control is a build error, not a
silently corrupted preset.

Seeding builds each rig in a throwaway offline (never-started) engine,
captures a RigEntry with a stable per-rig UUID (idempotent re-seed), and
saves to the store. Bootstrap rolls back this run's saves if any store.save
fails, so a partial library can't freeze future seeding (gated on isEmpty).

Rigs are named/described by sound, not trademarked products or artists; a
test guards against brand names leaking into names/blurbs. Full ship-path
test loads and renders every rig to non-silent output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-09 12:37:34 -07:00
josh d4664b3c1f Persist the source rig id inside the autosave; single source of truth
The rig-highlight/graph mismatch kept returning because the highlight (a
UserDefault) and the working graph (the autosave file) were two separate stores
that could diverge — and once an earlier build failed to load and autosaved a
fallback Default over the real graph, the divergence was permanent.

Fix the class of bug: the loaded rig's id now lives on ShoeGaze.currentRigID and
is written *inside* the autosave envelope alongside the graph (one atomic file).
RigStore.restore sets it from the envelope (nil for pre-envelope files or a
fallback seed); the sidebar highlight reads it directly. The separate
UserDefault key, restoreCurrentRig, and persistCurrentRigID are removed. When
the app falls back to seeding Default, no rig is highlighted — honest, and it
can never mislabel the graph again.

339 tests pass; both app targets build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 17:11:20 -07:00
josh 9a8e5461c0 Make rig library loads/resolve fully off-main
Move the remaining synchronous main-thread I/O off the main actor:

- RigLibraryStore now constructs instantly with a local placeholder and
  exposes an awaitable async start(): it resolves the iCloud-or-local
  location off-main (the blocking ubiquity lookup), loads entries off-main
  via the shared ioQueue (so a reload can't drop a just-saved rig), then
  sets isLoaded. reload() is async; iCloud metadata updates re-read via it.
- Seeding moves into RigLibraryBootstrap.start(_:seedFrom:), which seeds a
  "Default" rig only AFTER the (possibly iCloud) library has loaded and is
  still empty — preventing a duplicate "Default" on every synced device on
  first launch.
- Sidebar shows a Loading state until isLoaded; the builder restores the
  persisted current-rig highlight when isLoaded flips true (initialRigID
  param dropped).
- Shells construct the store synchronously and start it asynchronously
  (macOS via Task in didFinishLaunching; iOS via .task). Codec + file
  helpers are nonisolated static so background work needs no actor hop.
- Tests await store.start().

Full suite: 206 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 19:50:38 -07:00
josh dc42db0c59 Add iCloud-synced rig library
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>
2026-06-27 17:56:10 -07:00