Release 2.0.0: metronome, rig mute + shortcuts, set-list ordering, per-rig persistence

- Visual metronome tempo indicator (pendulum playhead) replacing the flashing LED
- Rig Mute (Cmd-Z) hard-silence, distinct from Bypass Rig; wired to header, board menu, MIDI
- Keyboard shortcuts: Cmd-1..9 board switch, Cmd-Shift-1..0 set-list rig load, Cmd-Z mute
  (macOS native menus + iOS/iPadOS hardware keyboards)
- Rig set-list ordering: drag or Move Up/Down in the picker; order saved and archive-portable
- Persist tempo, input selection, and engine I/O with a rig (I/O applied via opt-in
  applyChannelLayout, not forced on load)
- Fix archive import colliding set-list positions with existing rigs
- Remove ShoeGazeDemo / ShoeGazeiOSDemo apps and projects; keep the two Builder apps
- Bump marketing version to 2.0.0 on both Builder projects; pin Lyrebird 1.2.3
- Add CHANGELOG.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 12:30:45 -07:00
parent 4b0cf65a2b
commit e051521c04
52 changed files with 991 additions and 2166 deletions
@@ -176,14 +176,17 @@ public final class RigLibraryStore {
/// asynchronously on a background queue and only logs on failure — call
/// ``flushPendingWrites()`` to wait for it (e.g. in tests or at app termination).
public func save(_ entry: RigEntry) throws {
// Place the entry in the set list first (new rigs append; overwrites keep their position),
// so the persisted file carries a stable `sortIndex`.
let placed: RigEntry = placedForSave(entry)
// Encode synchronously (cheap, CPU) so an encoding failure is surfaced to the caller; then
// update the in-memory list immediately and push the disk write to the background queue.
let data: Data = try encode(entry)
let target: URL = fileURL(for: entry)
let data: Data = try encode(placed)
let target: URL = fileURL(for: placed)
let directory: URL = self.directory
let id: UUID = entry.id
let id: UUID = placed.id
let coordinated: Bool = isICloud
upsert(entry)
upsert(placed)
ioQueue.async {
// Remove any prior file for this id first (a rename changes the name-prefixed filename).
if let stale: URL = RigLibraryStore.existingFileURL(for: id, in: directory),
@@ -198,6 +201,87 @@ public final class RigLibraryStore {
}
}
// MARK: - Reordering
/// Moves entries within the set list (SwiftUI `onMove` semantics), renumbers every entry's
/// `sortIndex` to its new dense position, and persists the changed files.
///
/// - Parameters:
/// - source: The indices being moved, into the current `entries` order.
/// - destination: The insertion offset, per SwiftUI `List.onMove`.
public func move(fromOffsets source: IndexSet, toOffset destination: Int) {
var ordered: [RigEntry] = entries
ordered.move(fromOffsets: source, toOffset: destination)
renumberAndPersist(ordered)
}
/// Moves `entry` one slot earlier in the set list. No-op if it is already first or absent.
public func moveUp(_ entry: RigEntry) {
guard let index: Int = entries.firstIndex(where: { $0.id == entry.id }), index > 0 else { return }
var ordered: [RigEntry] = entries
ordered.swapAt(index, index - 1)
renumberAndPersist(ordered)
}
/// Moves `entry` one slot later in the set list. No-op if it is already last or absent.
public func moveDown(_ entry: RigEntry) {
guard let index: Int = entries.firstIndex(where: { $0.id == entry.id }),
index < entries.count - 1 else { return }
var ordered: [RigEntry] = entries
ordered.swapAt(index, index + 1)
renumberAndPersist(ordered)
}
/// Reorders the set list to match `orderedIDs`, renumbers every entry, and persists the changes.
/// Any entry not named in `orderedIDs` is appended in its current relative order (a safety net;
/// drag reorder always passes the full id list). Used by the sidebar's drag-to-reorder.
///
/// - Parameter orderedIDs: The desired full ordering, by entry id.
public func applyOrder(_ orderedIDs: [UUID]) {
let byID: [UUID: RigEntry] = Dictionary(entries.map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first })
var ordered: [RigEntry] = orderedIDs.compactMap { byID[$0] }
for entry: RigEntry in entries where !orderedIDs.contains(entry.id) {
ordered.append(entry)
}
renumberAndPersist(ordered)
}
/// Renumbers `ordered` so each entry's `sortIndex` equals its position, updates the in-memory
/// list, and writes only the files whose index actually changed.
private func renumberAndPersist(_ ordered: [RigEntry]) {
var renumbered: [RigEntry] = []
var changed: [RigEntry] = []
for (position, entry) in ordered.enumerated() {
if entry.sortIndex == position {
renumbered.append(entry)
} else {
let moved: RigEntry = entry.reordered(to: position)
renumbered.append(moved)
changed.append(moved)
}
}
entries = RigLibraryStore.sorted(renumbered)
for entry: RigEntry in changed { persistToDisk(entry) }
}
/// Writes `entry`'s JSON file on the background queue without touching the in-memory list or
/// re-sorting — the reorder path already updated `entries` in one shot.
private func persistToDisk(_ entry: RigEntry) {
guard let data: Data = try? encode(entry) else { return }
let target: URL = fileURL(for: entry)
let directory: URL = self.directory
let id: UUID = entry.id
let coordinated: Bool = isICloud
ioQueue.async {
if let stale: URL = RigLibraryStore.existingFileURL(for: id, in: directory),
stale.standardizedFileURL != target.standardizedFileURL {
try? RigLibraryStore.removeFile(at: stale, coordinated: coordinated)
}
do { try RigLibraryStore.writeData(data, to: target, coordinated: coordinated) }
catch { print("[RigLibraryStore] reorder write failed: \(error)") }
}
}
/// Deletes `entry` from memory immediately and removes its file on the background queue.
///
/// - Parameter entry: The rig entry to remove.
@@ -328,10 +412,13 @@ public final class RigLibraryStore {
let existingIDs: Set<UUID> = Set(entries.map(\.id))
var added: Int = 0
for entry: RigEntry in imported {
// Avoid clobbering an existing rig that happens to share this id.
// Avoid clobbering an existing rig that happens to share this id. Either way, clear the
// set-list position so the import appends after the existing entries (in archive order)
// rather than colliding with their indices — `duplicated` already unplaces; a
// non-colliding entry is explicitly unplaced via `reordered(to: nil)`.
let toSave: RigEntry = existingIDs.contains(entry.id)
? entry.duplicated(name: entry.name, date: entry.savedAt)
: entry
: entry.reordered(to: nil)
try save(toSave)
added += 1
}
@@ -549,14 +636,31 @@ public final class RigLibraryStore {
entries = RigLibraryStore.sorted(next)
}
/// Sorts entries by name (case-insensitive), then most-recently-saved first, then id for a
/// fully deterministic order.
/// Sorts entries by manual set-list position first (placed entries, ascending), then — for
/// unplaced entries or ties — by name (case-insensitive), most-recently-saved first, and id,
/// for a fully deterministic order.
private static func sorted(_ entries: [RigEntry]) -> [RigEntry] {
entries.sorted { lhs, rhs in
let lhsIndex: Int = lhs.sortIndex ?? Int.max
let rhsIndex: Int = rhs.sortIndex ?? Int.max
if lhsIndex != rhsIndex { return lhsIndex < rhsIndex }
let byName: ComparisonResult = lhs.name.localizedCaseInsensitiveCompare(rhs.name)
if byName != .orderedSame { return byName == .orderedAscending }
if lhs.savedAt != rhs.savedAt { return lhs.savedAt > rhs.savedAt }
return lhs.id.uuidString < rhs.id.uuidString
}
}
/// Assigns a set-list position to an entry about to be saved so every stored rig is placed:
/// an explicit index is kept as-is; overwriting an existing rig with an unplaced snapshot
/// preserves that rig's current position; a brand-new unplaced rig appends after the last one.
private func placedForSave(_ entry: RigEntry) -> RigEntry {
if entry.sortIndex != nil { return entry }
if let existing: RigEntry = entries.first(where: { $0.id == entry.id }),
let existingIndex: Int = existing.sortIndex {
return entry.reordered(to: existingIndex)
}
let nextIndex: Int = (entries.compactMap { $0.sortIndex }.max() ?? -1) + 1
return entry.reordered(to: nextIndex)
}
}