// PedalRebuildEnvironment.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import SwiftUI import LyrebirdShoeGaze /// Environment action a leaf pedal control can call to ask the host to rebuild the board that /// contains the given pedal — needed when a pedal setting that is *not* a live `@UIParam` (e.g. /// the Neural Amp's model file, stored in ``Pedal/resourcePath``) changes and only takes effect /// after the pedal's graph is rebuilt. Set once near the builder root; defaults to a no-op. private struct PedalRebuildActionKey: EnvironmentKey { static let defaultValue: @MainActor @Sendable (Pedal) -> Void = { _ in } } extension EnvironmentValues { /// Rebuilds the board containing the passed pedal. No-op unless the host installs it. var pedalRebuildAction: @MainActor @Sendable (Pedal) -> Void { get { self[PedalRebuildActionKey.self] } set { self[PedalRebuildActionKey.self] = newValue } } }