forge
Explore
Log in

Don't you dare go Hollow

The equalizer commit arms on the curve having moved

Browse files at this commit

a5f4c04283ba4577fac800872e16dd44203698c7Ahmet Kaan GümüşParent: 5d1e7d9
  • fix
    • the equalizer commit arms on the curve having moved
Show full message
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.rsmodified+16 -2
@@ -1542,8 +1542,22 @@ impl Player {
1542 };1542 };
1543 let params = (!self.eq_params.is_identity()).then(|| self.eq_params.clone());1543 let params = (!self.eq_params.is_identity()).then(|| self.eq_params.clone());
1544 if let Some(session) = &mut self.session {1544 if let Some(session) = &mut self.session {
1545- session.set_eq(lane, idx, params);1545+ // `set_eq` answers "the index was there and the curve is finite"
1546- self.mark_dirty();1546+ // -- it snapshots and rewrites the very slot it already holds for
1547+ // a curve that is already in force -- so on its own bool a
1548+ // re-commit of the same curve armed autosave, the ledger's
1549+ // `unsaved` ghost and the close prompt over a project whose bytes
1550+ // had not moved. The arm rides the curve having moved, the
1551+ // comparison `apply_fit` reads for `set_fit`
1552+ // ([`Player::apply_fit`]), and then the door's own answer.
1553+ let moved = session.eq_of(lane, idx).cloned() != params;
1554+ if moved && session.set_eq(lane, idx, params) {
1555+ self.mark_dirty();
1556+ // `set_eq` reseeks inside the engine -- that is what makes the
1557+ // change audible at once -- and a reseek is what these flags
1558+ // are about. Nothing was written, so nothing was reseeked.
1559+ self.reset_after_reseek();
1560+ }
1547 }1561 }
1548 cx.notify();1562 cx.notify();
1549 }1563 }
crates/app/src/tests/cards.rsmodified+33 -0
@@ -1739,6 +1739,39 @@ fn every_click_door_that_writes_the_project_arms_autosave() {
1739 "nudge_mix still arms ahead of the door, so a clamped no-op nudge \1739 "nudge_mix still arms ahead of the door, so a clamped no-op nudge \
1740 leaves the project looking edited"1740 leaves the project looking edited"
1741 );1741 );
1742+ // The equalizer card's commit, the same rule against a door whose bool is
1743+ // the WEAKER of the two shapes: `set_eq` answers "the index was there and
1744+ // the curve is finite" and rewrites the very slot it already holds for a
1745+ // curve already in force, so the arm needs the comparison too -- the same
1746+ // pair of conditions `apply_fit` rides.
1747+ let body = fn_body("commit_eq");
1748+ let arm = body
1749+ .split_once("if moved && session.set_eq(lane, idx, params) {")
1750+ .expect("the EQ commit no longer rides the curve having moved and then the door")
1751+ .1;
1752+ assert!(
1753+ arm.contains("mark_dirty()"),
1754+ "commit_eq arms outside its gate, so re-committing the curve already \
1755+ in force would dirty the project"
1756+ );
1757+ assert!(
1758+ body.contains("session.eq_of(lane, idx).cloned() != params"),
1759+ "commit_eq rides the engine's bool alone, which is true for a \
1760+ re-commit of the curve already in force"
1761+ );
1762+ // ...and the reseek bookkeeping rides with the arm, not instead of it.
1763+ assert!(
1764+ arm.contains("reset_after_reseek()"),
1765+ "commit_eq's reseek flags no longer clear on a write that took"
1766+ );
1767+ let before = body
1768+ .split_once("if moved && session.set_eq(lane, idx, params) {")
1769+ .unwrap()
1770+ .0;
1771+ assert!(
1772+ !before.contains("mark_dirty()"),
1773+ "commit_eq still arms ahead of the door"
1774+ );
1742 }1775 }
1743 1776
1744 /// The transition doors, which are the class's other shape: both engine1777 /// The transition doors, which are the class's other shape: both engine