From 5d1e7d9a3dda0a703d69f233ba046d4106319bc3 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:49 +0300 Subject: [PATCH] fix(player): the mix card's arm rides the mix door's own answer `Player::nudge_mix` called `mark_dirty()` before it asked the session anything, so every press armed autosave -- the ledger's `unsaved` ghost, a sidecar write, the close prompt -- whether or not a value moved. Both doors it goes through already answer the question: `set_lane_gain_db` and `set_limiter` each return false for a value already in force. So a fader held against its wall (the clamp is reached, the number written is the number there), a ceiling already at its clamp, and a re-tapped limiter switch all lit `unsaved` over a project whose bytes had not moved, and asked the user to save work nobody did. The arm moves inside the match, on the bool the door returned. The nudge's own math is untouched: the mixer is still handed the value on every press, so what the ear hears while the arrow is held is unchanged -- a no-op press is simply no longer an edit. The scan case joins the family in `every_click_door_that_writes_the_project_arms_autosave`, in the same `fn_body` shape, and asserts both halves: the arm is after the gate and absent before it. Shown RED against the pre-fix source. --- crates/app/src/player/cards.rs | 83 +++++++++++++++--------------- crates/app/src/tests/cards.rs | 92 +++++++++++++++++++++++++++++++--- 2 files changed, 127 insertions(+), 48 deletions(-) diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 5b42d90..4b35920 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -1,8 +1,8 @@ //! The cards the window opens over itself: the pickers, colour, speed, //! silence, the mixer and the equalizer. -use crate::*; use crate::ui::settings_stance::SettingsTab; +use crate::*; impl Player { /// Cycles the *project's* resolution through [`RESOLUTIONS`], starting from @@ -279,10 +279,7 @@ impl Player { match caption_media_half(session, (lane, idx), LaneKind::Video) { Some(half) => Some(half), None => { - self.notify_user( - "NOTHING TO GRADE — a caption has no picture" - .into(), - ); + self.notify_user("NOTHING TO GRADE — a caption has no picture".into()); cx.notify(); return; } @@ -426,10 +423,7 @@ impl Player { match caption_media_half(session, (lane, idx), LaneKind::Video) { Some(half) => Some(half), None => { - self.notify_user( - "NOTHING TO PLACE — a caption has no picture" - .into(), - ); + self.notify_user("NOTHING TO PLACE — a caption has no picture".into()); cx.notify(); return; } @@ -567,8 +561,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO RE-TIME — a caption has no speed of its own" - .into(), + "NOTHING TO RE-TIME — a caption has no speed of its own".into(), ); cx.notify(); return; @@ -734,8 +727,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO SCAN — a caption has no sound of its own" - .into(), + "NOTHING TO SCAN — a caption has no sound of its own".into(), ); cx.notify(); return; @@ -856,14 +848,20 @@ impl Player { if self.session.is_none() { return; } - self.mark_dirty(); let Some(session) = self.session.as_mut() else { return; }; - match lanes.get(self.mix_field) { + // The arm rides the door's answer, not the press: a fader already + // against its wall, a ceiling already at its clamp and a limiter + // switch that did not move are *not* edits, and `set_lane_gain_db` / + // `set_limiter` each answer `false` for exactly those (an unchanged + // value). Arming before the ask lit the ledger's `unsaved` ghost, + // wrote an autosave sidecar and put the close prompt up over a + // project whose bytes had not moved. + let took = match lanes.get(self.mix_field) { Some(&lane) => { let at = session.lane_gain_db(lane) + steps as f32 * MIX_DB_STEP; - session.set_lane_gain_db(lane, at); + session.set_lane_gain_db(lane, at) } None => { let limiter = session.limiter(); @@ -878,8 +876,11 @@ impl Player { ..limiter }, }; - session.set_limiter(at); + session.set_limiter(at) } + }; + if took { + self.mark_dirty(); } cx.notify(); } @@ -1246,17 +1247,15 @@ impl Player { /// nothing. pub(crate) fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec)> { if self.silence_marks.is_empty() { - self.notify_user( - if self.silence_keep_only { - "NO SPEECH TO CUT — keep-only-silence needs silence and speech".into() - } else { - format!( - "NO SILENCE — under {:.0} dBFS lasting {:.2} s", - self.silence.threshold_db, self.silence.min_silence - ) - .into() - }, - ); + self.notify_user(if self.silence_keep_only { + "NO SPEECH TO CUT — keep-only-silence needs silence and speech".into() + } else { + format!( + "NO SILENCE — under {:.0} dBFS lasting {:.2} s", + self.silence.threshold_db, self.silence.min_silence + ) + .into() + }); return None; } Some((self.silence_marks.clone(), self.silence_lanes())) @@ -1302,7 +1301,11 @@ impl Player { // moves indexes (a delete, a paste, an undo). self.selected.clear(); self.reset_after_reseek(); - let what = if self.silence_keep_only { "SPEECH" } else { "SILENCES" }; + let what = if self.silence_keep_only { + "SPEECH" + } else { + "SILENCES" + }; self.notify_user( format!( "{count} {what} CUT {reach} — {} shorter · undo {}", @@ -1342,7 +1345,11 @@ impl Player { // goes with them. self.selected.clear(); self.reset_after_reseek(); - let what = if self.silence_keep_only { "SPEECH" } else { "SILENCES" }; + let what = if self.silence_keep_only { + "SPEECH" + } else { + "SILENCES" + }; self.notify_user( format!( "{count} {what} AT {rate} {reach} · undo {}", @@ -1494,9 +1501,9 @@ impl Player { "NOTHING SELECTED · select all {}", self.keymap.display(ActionId::Select) )), - (Some((lane, _)), _) if lane.kind != LaneKind::Audio => Some( - "NOT AN AUDIO CLIP — the equalizer works on sound".to_string(), - ), + (Some((lane, _)), _) if lane.kind != LaneKind::Audio => { + Some("NOT AN AUDIO CLIP — the equalizer works on sound".to_string()) + } _ => None, }; if let Some(refusal) = refusal { @@ -1538,9 +1545,6 @@ impl Player { 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. - self.reset_after_reseek(); cx.notify(); } @@ -1590,12 +1594,7 @@ impl Player { /// band that was just made. Refused rather than silently ignored at the cap. pub(crate) fn add_band(&mut self, cx: &mut Context) { if self.eq_params.bands.len() >= EQ_BANDS_MAX { - self.notify_user( - format!( - "EQUALIZER FULL — {EQ_BANDS_MAX} bands" - ) - .into(), - ); + self.notify_user(format!("EQUALIZER FULL — {EQ_BANDS_MAX} bands").into()); cx.notify(); return; } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index db43f74..5f1c6e1 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -1172,7 +1172,7 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { /// and can't turn it back to video"). One cycle, and it wraps. #[test] fn the_picture_cycle_wraps_out_of_the_sound_only_formats() { - use crate::ui::settings_stance::{next_picture, PICTURE_CYCLE}; + use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture}; // Nothing refused: every stop is the next one, and the last wraps to the // first -- OGG, the tail of the list, back to MP4. let mut at = PICTURE_CYCLE[0]; @@ -1710,6 +1710,84 @@ fn every_click_door_that_writes_the_project_arms_autosave() { one for the same step" ); } + // The mix card's own doors. Both answer "the value moved" -- a fader + // already against its wall, a ceiling already at its clamp, a limiter + // switch whose value is the one in force are each `false` -- so the arm + // rides the bool, and `nudge_mix` does not arm before the ask the way it + // did: a held arrow key at the top of the fader lit `unsaved`, wrote a + // sidecar and put the close prompt up over a project whose bytes had not + // moved. + let body = fn_body("nudge_mix"); + for door in ["set_lane_gain_db", "set_limiter"] { + assert!( + body.contains(door), + "nudge_mix no longer goes through {door}" + ); + } + let arm = body + .split_once("if took {") + .expect("the mix arm no longer rides the door's own answer") + .1; + assert!( + arm.contains("mark_dirty()"), + "nudge_mix arms outside its gate, so a fader held against its wall \ + would dirty the project" + ); + let before = body.split_once("if took {").unwrap().0; + assert!( + !before.contains("mark_dirty()"), + "nudge_mix still arms ahead of the door, so a clamped no-op nudge \ + leaves the project looking edited" + ); +} + +/// The transition doors, which are the class's other shape: both engine +/// setters ([`engine::project::Project::set_transition_out`], +/// [`engine::project::Project::crossfade`]) answer `true` for any two +/// adjacent clips, snapshot and clamp included -- so a step past the +/// successor's length, or a number retyped into the field, wrote the value the +/// join already carried and still said yes. [`Player::set_transition_frames`] +/// reads the join's own edges back and rides those, and the crossfade side +/// compares *both* edges: it writes the anchor's `fade_out` and the +/// neighbour's `fade_in`, and a comparison of the anchor alone would miss a +/// neighbour-side no-op. +#[test] +fn a_transition_step_or_a_retyped_number_arms_only_what_moved() { + let body = fn_body("set_transition_frames"); + for door in ["set_transition_out", "crossfade"] { + assert!( + body.contains(door), + "the duration doors no longer include {door}" + ); + } + let gate = "if ok && self.transition_edges(lane, idx) != before {"; + let arm = body + .split_once(gate) + .unwrap_or_else(|| panic!("the transition arm no longer rides the join's own edges")) + .1; + assert!( + arm.contains("mark_dirty()"), + "the transition arm is outside its gate, so a step past the cap or a \ + retyped number would dirty an unchanged project" + ); + let before = body.split_once(gate).unwrap().0; + assert!( + !before.contains("mark_dirty()"), + "the transition arm is still ahead of the comparison" + ); + assert!( + body.contains("let before = self.transition_edges(lane, idx);"), + "the join's edges are no longer read before the write" + ); + // The helper both sides call, and the pair it must compare: an anchor-only + // comparison cannot see the neighbour's `fade_in` not moving. + let helper = fn_body("transition_edges"); + assert!( + helper.contains("clips.get(idx)?.fade_out") + && helper.contains("clips.get(idx + 1)?.fade_in"), + "the edge reader no longer reads both sides of the join, so a \ + crossfade that only moves the neighbour is invisible" + ); } /// [`crate::ui::dock_stance::transition_of`]: the dock's duration row @@ -1928,9 +2006,11 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { assert!(native_detail.ends_with(" source"), "{native_detail}"); // A project at a size nobody listed still gets the whole list, with // nothing marked rather than a wrong row marked. - assert!(resolution_choices((1000, 1000), native) - .iter() - .all(|(.., picked)| !picked)); + assert!( + resolution_choices((1000, 1000), native) + .iter() + .all(|(.., picked)| !picked) + ); // Picking a row means that row, and stepping means the next one: the // list and the stroke read the same ladder. assert_eq!(next_resolution(ladder[1], native), ladder[2]); @@ -2387,8 +2467,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() { /// inside the dock, or hands it the dock's width again, fails this. #[test] fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { - use crate::layout::{split_size, Split}; use crate::SPLIT_W; + use crate::layout::{Split, split_size}; // `layout::SPLIT_W` is the one divider between `stance-centre` and the // dock; the 56px rail that used to eat the centre's left edge is gone @@ -2435,7 +2515,7 @@ fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { /// assumption. #[test] fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() { - use crate::ui::stance::{below_picture_floor, LEDGER_H, TIME_BAND_H}; + use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor}; let viewport_h = 1080.; for bench_h in [140., 200., 400.] { assert_eq!(