Review fixes: reindex activeBoardIndex; safer live-input rebuild

- moveBoard/removeBoard now keep activeBoardIndex pointing at the soloed board
  (track by identity on move; shift down or clear on remove), so the Solo
  highlight no longer lights the wrong cell after reorder or delete.
- rebuildWithLiveInput snapshots the rig before any teardown and aborts if the
  snapshot fails, instead of tearing down then seeding a fallback (no silent
  rig loss). The engine-already-has-input early return now also persists the
  live-input selection, via a shared selectLiveInputAndPersist helper.
- Test: activeBoardIndex tracks reorder and removal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 21:22:44 -07:00
parent 652a5a76ca
commit 6ad813601f
3 changed files with 84 additions and 12 deletions
@@ -86,6 +86,49 @@ struct ShoeGazeMultiBoardTests {
}
}
@Test func activeBoardIndexTracksReorderAndRemoval() throws {
let renderDuration: Double = 0.05
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
duration: renderDuration,
numAudioBuses: 64
)
defer { try? FileManager.default.removeItem(at: url) }
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
let board1: PedalBoard = try shoeGaze.addBoard()
try board1.add(OverdrivePedal())
try shoeGaze.finalizeBoard(board1)
let board2: PedalBoard = try shoeGaze.addBoard()
try board2.add(DelayPedal())
try shoeGaze.finalizeBoard(board2)
let board3: PedalBoard = try shoeGaze.addBoard()
try board3.add(OverdrivePedal())
try shoeGaze.finalizeBoard(board3)
// Solo board3 (index 2), then move it to the front — index must follow the board.
shoeGaze.soloBoard(board3, crossfadeSeconds: 0.0)
#expect(shoeGaze.activeBoardIndex == 2)
shoeGaze.moveBoard(board3, to: 0)
#expect(shoeGaze.boards.first === board3)
#expect(shoeGaze.activeBoardIndex == 0)
// Now order is [board3, board1, board2], soloed index 0. Removing a later board
// leaves the soloed index unchanged.
shoeGaze.removeBoard(board2)
#expect(shoeGaze.activeBoardIndex == 0)
// Re-solo board1 (now index 1), then remove the earlier board3 (index 0):
// the soloed index shifts down to 0.
shoeGaze.soloBoard(board1, crossfadeSeconds: 0.0)
#expect(shoeGaze.activeBoardIndex == 1)
shoeGaze.removeBoard(board3)
#expect(shoeGaze.activeBoardIndex == 0)
// Removing the soloed board clears the index.
shoeGaze.removeBoard(board1)
#expect(shoeGaze.activeBoardIndex == nil)
}
@Test func soloBlendAndAllControlBoardAudibility() throws {
let renderDuration: Double = 0.05
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(