From a5f4c04283ba4577fac800872e16dd44203698c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 30 Sep 2026 15:34:59 +0300 Subject: [PATCH] fix(player): the equalizer commit arms on the curve having moved `Player::commit_eq` called `session.set_eq(...)` and then armed, dropping the door's answer entirely. Worse, that answer is the weak shape the family already knows about: `Project::set_eq` returns false only for an index that is not there and a curve that is not finite, and otherwise snapshots and rewrites the very slot the clip already holds -- so it says true for a re-commit of the curve already in force. The "Flatten all" button reaches `commit_eq` with every gain already at zero, and the card's own close armed autosave, the `unsaved` ghost and the close prompt over a project nothing had changed. The arm now rides the same pair `apply_fit` already rides for `set_fit`: the curve having moved, read back with `eq_of`, and then the door's own answer. A missing index, a non-finite curve and a no-op commit are all unarmed; a real change arms exactly once. `reset_after_reseek` moves inside the gate with the arm rather than staying outside it: it exists because `set_eq` reseeks inside the engine, so on a write that did not take there is no reseek whose flags need clearing. The scan case joins `every_click_door_that_writes_the_project_arms_autosave` in the family's `fn_body` shape, and holds the two-part gate: without the `eq_of` comparison the door's bool alone would pass. Shown RED against the pre-fix source with the arm and the comparison reverted separately. --- crates/app/src/player/cards.rs | 18 ++++++++++++++++-- crates/app/src/tests/cards.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 4b35920..19e03db 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -1542,8 +1542,22 @@ impl Player { }; let params = (!self.eq_params.is_identity()).then(|| self.eq_params.clone()); if let Some(session) = &mut self.session { - session.set_eq(lane, idx, params); - self.mark_dirty(); + // `set_eq` answers "the index was there and the curve is finite" + // -- it snapshots and rewrites the very slot it already holds for + // a curve that is already in force -- so on its own bool a + // re-commit of the same curve armed autosave, the ledger's + // `unsaved` ghost and the close prompt over a project whose bytes + // had not moved. The arm rides the curve having moved, the + // comparison `apply_fit` reads for `set_fit` + // ([`Player::apply_fit`]), and then the door's own answer. + let moved = session.eq_of(lane, idx).cloned() != params; + if moved && session.set_eq(lane, idx, params) { + self.mark_dirty(); + // `set_eq` reseeks inside the engine -- that is what makes the + // change audible at once -- and a reseek is what these flags + // are about. Nothing was written, so nothing was reseeked. + self.reset_after_reseek(); + } } cx.notify(); } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 5f1c6e1..246ad07 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -1739,6 +1739,39 @@ fn every_click_door_that_writes_the_project_arms_autosave() { "nudge_mix still arms ahead of the door, so a clamped no-op nudge \ leaves the project looking edited" ); + // The equalizer card's commit, the same rule against a door whose bool is + // the WEAKER of the two shapes: `set_eq` answers "the index was there and + // the curve is finite" and rewrites the very slot it already holds for a + // curve already in force, so the arm needs the comparison too -- the same + // pair of conditions `apply_fit` rides. + let body = fn_body("commit_eq"); + let arm = body + .split_once("if moved && session.set_eq(lane, idx, params) {") + .expect("the EQ commit no longer rides the curve having moved and then the door") + .1; + assert!( + arm.contains("mark_dirty()"), + "commit_eq arms outside its gate, so re-committing the curve already \ + in force would dirty the project" + ); + assert!( + body.contains("session.eq_of(lane, idx).cloned() != params"), + "commit_eq rides the engine's bool alone, which is true for a \ + re-commit of the curve already in force" + ); + // ...and the reseek bookkeeping rides with the arm, not instead of it. + assert!( + arm.contains("reset_after_reseek()"), + "commit_eq's reseek flags no longer clear on a write that took" + ); + let before = body + .split_once("if moved && session.set_eq(lane, idx, params) {") + .unwrap() + .0; + assert!( + !before.contains("mark_dirty()"), + "commit_eq still arms ahead of the door" + ); } /// The transition doors, which are the class's other shape: both engine