fix(rigs): don't flag a rig dirty over input/channel differences

Switching between starter rigs prompted "save changes?" even when nothing
was edited. The unsaved-changes check compared full ShoeGazeState snapshots
(`captureState() != entry.state`), which include the live input source and
engine channel counts — and those legitimately differ from a factory rig's
saved values now that a rig switch preserves the player's current input
instead of adopting the rig's saved one.

Add ShoeGazeState.hasSameRigContent(as:) comparing only rig content (boards,
routers, MIDI map, tempo) and use it for the dirty check, so session/engine
settings no longer register as unsaved changes. Test added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-10 16:40:35 -07:00
parent 5decdd8693
commit 44e6c35550
3 changed files with 44 additions and 1 deletions
@@ -1677,12 +1677,16 @@ public struct ShoeGazeBuilderView: View {
/// Whether the working rig differs from the library entry it was loaded from. A working rig with
/// no backing entry counts as dirty when it has any boards.
///
/// Compares rig content only (boards, routers, MIDI, tempo) — not the live input source or engine
/// channel counts, which are intentionally kept across a rig switch and so must not register as
/// unsaved changes (otherwise switching between rigs always prompts to save).
private func isCurrentRigDirty() -> Bool {
guard let id: UUID = currentRigID,
let entry: RigEntry = library.entries.first(where: { $0.id == id }) else {
return !shoeGaze.boards.isEmpty
}
return shoeGaze.captureState() != entry.state
return !shoeGaze.captureState().hasSameRigContent(as: entry.state)
}
/// Saves the current session over the loaded library entry, or prompts for a name when no entry