From 07d3b8b21f81ed2424541b13e19064e1c7c30b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 24 Sep 2026 15:19:59 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(player):=20the=20write-back=20?= =?UTF-8?q?a=20history=20step=20makes=20is=20pinned,=20and=20the=20plate's?= =?UTF-8?q?=20motive=20said=20right?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app-level half of a history step -- the three session caches, the pick, and the drop of the plate -- lives in `Player::step_history`, which is unreachable from this binary: `Player` needs a `TestAppContext` the test build cannot make (gpui's own test module is behind `feature = "test-support"`, which nothing enables). The verifier deleted the whole write-back and the suite stayed green, so it is pinned the way this repo pins an unreachable surface: a source scan that both keyboard doors route through `step_history` and that its body still carries every one of those writes. Non-vacuous by the lane's own recipe -- deleting `self.proxies_on = caches.proxies_on;` turns it red by name. `Player::sub_image` is keyed by *where* a cue sits (`(lane, start_us)`), never by the pick, and the drop of it is conservative; three comments said the plate "was drawn through the pick that no longer stands", which would send a reader looking for a key that does not exist. Reworded to the real key and motive here, at the removal door, in `sub_pick_after_removal` (which now names what actually reads the pick: the dock's picked-row comparison, the heading and its notices), and in the test that covers it. --- crates/app/src/player/actions.rs | 11 +++++-- crates/app/src/player/library.rs | 8 +++-- crates/app/src/subs.rs | 14 +++++---- crates/app/src/tests/editing.rs | 50 ++++++++++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 82bd7d6..3edc3d9 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -774,9 +774,14 @@ impl HistoryBefore { #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) struct HistoryOutcome { pub(crate) sub_track: usize, - /// The plate the pick drew (`Player::sub_image`) was drawn through a pick - /// that no longer stands -- the palette moved under it, or it names another - /// row -- so it has to go. + /// The plate over the picture (`Player::sub_image`) has to go. Its tile is + /// keyed by *where* a cue sits ([`Player::sub_picture`]'s `(lane, + /// start_us)`) and carries no track, so a step that moves captions, takes + /// one off, or renumbers the track a placement names + /// ([`engine::Project::remove_subtitles`] walks `SubClip::track` down) + /// cannot be asked of that cache -- the tile at a key can be served for a + /// cue it was not drawn from. Conservative on purpose: at most one plate is + /// redrawn by the next repaint. pub(crate) drop_sub_image: bool, } diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index 716047b..16efa54 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -1751,8 +1751,12 @@ impl Player { .as_ref() .map_or(0, |session| session.subtitles().len()); self.sub_track = sub_pick_after_removal(self.sub_track, track, left); - // The drawn cue is keyed by that index ([`Player::sub_picture`]) - // and the index now stands for another track. + // The cue over the picture goes with the pick: its tile is + // keyed by *where* the cue sits ([`Player::sub_picture`]'s + // `(lane, start_us)`) and never by the track it shows, so the + // index that moved here is not something that cache can be + // asked about. Conservative, and the same drop a history step + // makes for the same reason ([`Player::step_history`]). // // corner-cut: its atlas tile is not released -- `close_session`'s // note, for its reason and with its upgrade path. diff --git a/crates/app/src/subs.rs b/crates/app/src/subs.rs index dd482f5..10e42b6 100644 --- a/crates/app/src/subs.rs +++ b/crates/app/src/subs.rs @@ -623,11 +623,15 @@ pub(crate) fn subtitle_rows(tracks: &[engine::subtitle::SubtitleTrack]) -> Vec usize { let picked = match removed < picked { true => picked - 1, diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 88d9988..e3dcec0 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -2018,9 +2018,9 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() { /// Rows above the picked subtitle move the pick down with them /// ([`sub_pick_after_removal`]), and a `^z` of that removal has to move it back /// up: the palette comes home out of the entry, the pick is an *index* into it, -/// and an index left where it was names a different track -- the plate over the -/// picture would change language on its own, and the one already drawn was -/// drawn through the pick that no longer stands. +/// and an index left where it was highlights one row and names another. The +/// plate over the picture goes too, not because it is keyed by the pick -- it is +/// keyed by where a cue sits -- but because the step moves the cues under it. #[test] fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { use crate::player::actions::{history_step, HistoryBefore, SessionCaches}; @@ -2095,6 +2095,50 @@ fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { assert!(out.drop_sub_image, "and the plate goes with it"); } +/// The app-level write-back of a history step is not reachable from this binary +/// -- `Player` needs a `TestAppContext` this one has none of -- so the wiring is +/// pinned where it can be read: both keyboard doors route through +/// [`Player::step_history`], and its body still keeps the three session caches +/// and the pick, and still drops the plate. What those values *are* is pinned +/// against a real session by the two tests above ([`history_step`] is the free +/// function they drive); this is the copy back into the window's own fields, +/// which no test can call. +#[test] +fn a_history_step_still_takes_its_settings_and_its_pick_back_up() { + let actions = src_text("player/actions.rs"); + for needle in [ + "self.step_history(PlaybackSession::undo);", + "self.step_history(PlaybackSession::redo);", + ] { + assert!( + actions.contains(needle), + "a history door stopped routing through Player::step_history: {needle}" + ); + } + let body = fn_body("step_history"); + // The state the step is asked about, and the answer taken back up: every one + // of these deleted leaves a cache or the pick stale for the next cut, the + // next frame count, or the next repaint. + for needle in [ + "let mut caches = SessionCaches {", + "HistoryBefore::of(", + "self.fps = caches.fps;", + "self.proxies_on = caches.proxies_on;", + "self.auto_proxies_on = caches.auto_proxies_on;", + "self.sub_track = outcome.sub_track;", + "if outcome.drop_sub_image {", + "self.sub_image = None;", + "self.reset_after_reseek();", + ] { + assert!( + body.contains(needle), + "Player::step_history no longer carries `{needle}` -- a history step \ + leaves it behind (the app suite cannot see this: it has no \ + TestAppContext to call the door)" + ); + } +} + /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and* /// the playhead actually resting on it, unlike the nudge pair above it which /// only needs a cut -- the "spot" a keyless drag would snap to has to be on