From 9b31be792101ee9c621992de5f23319ad61c8b9e Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Tue, 23 Jun 2026 20:57:34 -0700 Subject: [PATCH] Resync EngineConfigView channel/rate fields on engine rebuild EngineConfigView seeds its pending In/Out/Rate fields from @State(initialValue:), which runs only once. After the iOS live-input rebuild swaps in a new engine with one input channel, the stepper kept showing In: 0 even though audio read the input. Resync the pending fields in a .task keyed on the engine's object identity so a rebuilt engine's actual counts are reflected. Co-Authored-By: Claude Opus 4.8 --- Sources/LyrebirdShoeGazeUI/EngineConfigView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift b/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift index c40414a..d96e8c6 100644 --- a/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift +++ b/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift @@ -113,6 +113,16 @@ public struct EngineConfigView: View { } message: { Text(alertText) } + // Resync the pending fields whenever the engine is rebuilt out from under this view (e.g. + // the iOS live-input rebuild swaps in a new engine with a different input-channel count). + // Keyed on the engine's object identity so it re-runs on every swap; the @State initial + // values are seeded only once, so without this the stepper would keep showing the old + // engine's channel counts even though audio reads the new one. + .task(id: ObjectIdentifier(shoeGaze.engine)) { + pendingSampleRate = shoeGaze.engine.sampleRate + pendingInputs = shoeGaze.engine.numInputChannels + pendingOutputs = shoeGaze.engine.numOutputChannels + } } private func label(_ text: String) -> some View {