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>
This commit is contained in:
@@ -71,6 +71,12 @@ public final class ShoeGaze {
|
||||
/// Read and mutated by `MIDIController`; survives an input-source switch (same rig).
|
||||
public var midiMap: MIDIMap?
|
||||
|
||||
/// The id of the rig-library entry this working session derives from, or `nil` for an unsaved
|
||||
/// session. Session provenance only — NOT part of a saved/exported rig; it is written into the
|
||||
/// autosave envelope (see `RigStore`) alongside the graph so the sidebar highlight and the
|
||||
/// restored graph can never diverge. The UI mirrors this into the rig-library selection.
|
||||
public var currentRigID: UUID?
|
||||
|
||||
// MARK: - Recording state
|
||||
|
||||
/// The folder into which `startRecording()` writes timestamped WAV files.
|
||||
|
||||
Reference in New Issue
Block a user