From 9e93f65a1b65885306ac90f50910a750624647c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 9 Sep 2026 17:50:55 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style(app):=20the=20ledger=20rep?= =?UTF-8?q?orts=20state,=20and=20never=20cuts=20a=20word=20to=20do=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notices lose their instructional tails (DESIGN §8): a remedy is a verb and its chord (`V2 ADDED · undo z`), never a sentence. The strip ellipsises at its end and elides a long name through its middle first, so the state word at the front is never what a narrow window drops. --- crates/app/src/files.rs | 4 +- crates/app/src/notices.rs | 47 +++++++++++++ crates/app/src/player/actions.rs | 6 +- crates/app/src/player/cards.rs | 36 +++++----- crates/app/src/player/export.rs | 4 +- crates/app/src/player/library.rs | 44 +++++------- crates/app/src/player/timeline_edit.rs | 33 +++++---- crates/app/src/player/view.rs | 7 +- crates/app/src/subs.rs | 11 ++- crates/app/src/tests/layout.rs | 97 ++++++++++++++++++++++++++ crates/app/src/tests/view.rs | 6 +- crates/app/src/timeline_math.rs | 4 +- crates/app/src/transport.rs | 2 +- crates/app/src/ui/stance.rs | 9 ++- 14 files changed, 222 insertions(+), 88 deletions(-) diff --git a/crates/app/src/files.rs b/crates/app/src/files.rs index 1cc039e..d8a0ee7 100644 --- a/crates/app/src/files.rs +++ b/crates/app/src/files.rs @@ -92,7 +92,7 @@ pub(crate) fn pick_file(title: &str) -> Result, &'static str> { ("kdialog", vec!["--getopenfilename".into()]), ]) .ok_or( - "NO FILE CHOOSER — install zenity or kdialog, or drag the file onto this window to import it", + "NO FILE CHOOSER — install zenity or kdialog", ) } @@ -116,7 +116,7 @@ pub(crate) fn pick_save(default: &std::path::Path) -> Result, &' ("kdialog", vec!["--getsavefilename".into(), default]), ]) .ok_or( - "NO FILE CHOOSER — install zenity or kdialog to choose where; exporting beside the source", + "NO FILE CHOOSER — exporting beside the source", ) } diff --git a/crates/app/src/notices.rs b/crates/app/src/notices.rs index 7d1aa8d..299d54f 100644 --- a/crates/app/src/notices.rs +++ b/crates/app/src/notices.rs @@ -51,6 +51,37 @@ pub(crate) fn audio_notice(session: &PlaybackSession) -> Option { .map(|reason| format!(" — NO AUDIO: {reason}")) } +/// The strip's own width is finite and its message is one line: what a +/// too-long line must never do is lose its *state* word, which sits at the +/// front, or stop mid-word with nothing saying it stopped (user report, +/// `OPENED he_is_not_the_only_one.mp4 — 1 subtitle track(s) in `). Every +/// message is a handful of words plus a file name now (DESIGN §8), so the one +/// part long enough to overflow the strip alone is the name -- elided through +/// its middle here, head and tail kept, before gpui's own end ellipsis +/// ([`crate::ui::stance`]) ever has to cut a word. +pub(crate) const LEDGER_WORD_MAX: usize = 28; + +pub(crate) fn ledger_line(message: &str) -> String { + message + .split(' ') + .map(|word| match word.chars().count() > LEDGER_WORD_MAX { + false => word.to_string(), + // Chars, not bytes: a name is whatever the filesystem holds. + true => { + let chars: Vec = word.chars().collect(); + let head = LEDGER_WORD_MAX / 2 - 1; + let tail = LEDGER_WORD_MAX - head - 1; + format!( + "{}…{}", + chars[..head].iter().collect::(), + chars[chars.len() - tail..].iter().collect::() + ) + } + }) + .collect::>() + .join(" ") +} + #[cfg(test)] mod tests { use super::*; @@ -83,4 +114,20 @@ mod tests { // message's text. assert_eq!(notices.back().unwrap().as_ref(), refusal); } + + /// The line the strip paints keeps its state word and never stops + /// mid-word without a sign: a long name loses its middle, everything + /// short is untouched, and the count at the end survives. + #[test] + fn a_long_name_loses_its_middle_rather_than_the_state_word() { + assert_eq!(ledger_line("SNAP OFF"), "SNAP OFF"); + let long = ledger_line("OPENED he_is_not_the_only_one_at_all_here.mp4 · 1 subtitle track(s)"); + assert!(long.starts_with("OPENED "), "{long}"); + assert!(long.ends_with(" · 1 subtitle track(s)"), "{long}"); + assert!(long.contains('…'), "{long}"); + assert!( + long.split(' ').all(|w| w.chars().count() <= LEDGER_WORD_MAX), + "{long}" + ); + } } diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 53851c5..55750ee 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -251,8 +251,8 @@ impl Player { self.snap_cue = None; self.ghost.clear(); self.notify_user(match self.snap { - true => "SNAP ON — drags land on clip edges, the playhead and the start".into(), - false => "SNAP OFF — drags land exactly where the hand leaves them".into(), + true => "SNAP ON".into(), + false => "SNAP OFF".into(), }); cx.notify(); } @@ -649,7 +649,7 @@ impl Player { }; self.loop_trim = self.cut_span(lane, idx); if self.loop_trim.is_some() { - self.notify_user("LOOP-TRIM ON — looping the subject cut while you trim".into()); + self.notify_user("LOOP-TRIM ON".into()); } cx.notify(); } diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index c48163a..e4d7e31 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -244,7 +244,7 @@ impl Player { return; } let Some(session) = &self.session else { - self.notify_user("no timeline to grade — open a file first".into()); + self.notify_user("no timeline to grade — no file open".into()); cx.notify(); return; }; @@ -262,8 +262,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO GRADE — a caption has no picture; group it with a clip \ - first (ctrl-click both, then Group)" + "NOTHING TO GRADE — a caption has no picture" .into(), ); cx.notify(); @@ -400,7 +399,7 @@ impl Player { return; } let Some(session) = &self.session else { - self.notify_user("no timeline to place — open a file first".into()); + self.notify_user("no timeline to place — no file open".into()); cx.notify(); return; }; @@ -410,8 +409,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO PLACE — a caption has no picture; group it with a clip \ - first (ctrl-click both, then Group)" + "NOTHING TO PLACE — a caption has no picture" .into(), ); cx.notify(); @@ -533,7 +531,7 @@ impl Player { return; } let Some(session) = &self.session else { - self.notify_user("no timeline to re-time — open a file first".into()); + self.notify_user("no timeline to re-time — no file open".into()); cx.notify(); return; }; @@ -551,8 +549,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO RE-TIME — a caption has no speed of its own; group it \ - with a clip first (ctrl-click both, then Group)" + "NOTHING TO RE-TIME — a caption has no speed of its own" .into(), ); cx.notify(); @@ -696,7 +693,7 @@ impl Player { return; } let Some(session) = &self.session else { - self.notify_user("no timeline to scan — open a file first".into()); + self.notify_user("no timeline to scan — no file open".into()); cx.notify(); return; }; @@ -714,8 +711,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO SCAN — a caption has no sound of its own; group it with \ - the take's sound first (ctrl-click both, then Group)" + "NOTHING TO SCAN — a caption has no sound of its own" .into(), ); cx.notify(); @@ -1161,7 +1157,7 @@ impl Player { if self.silence_marks.is_empty() { self.notify_user( format!( - "no silence under {:.0} dBFS lasting {:.2} s — raise the threshold or forgive less", + "no silence under {:.0} dBFS lasting {:.2} s", self.silence.threshold_db, self.silence.min_silence ) .into(), @@ -1213,7 +1209,7 @@ impl Player { self.reset_after_reseek(); self.notify_user( format!( - "{count} SILENCES CUT {reach} — {} shorter, {} takes it back", + "{count} SILENCES CUT {reach} — {} shorter · undo {}", secs_label(saved), self.keymap.display(ActionId::Undo) ) @@ -1252,7 +1248,7 @@ impl Player { self.reset_after_reseek(); self.notify_user( format!( - "{count} SILENCES AT {rate} {reach} — {} takes it back", + "{count} SILENCES AT {rate} {reach} · undo {}", self.keymap.display(ActionId::Undo) ) .into(), @@ -1392,13 +1388,13 @@ impl Player { _ => self.selected.anchor(), }; let refusal = match (anchor, &self.session) { - (_, None) => Some("NO TIMELINE — open a file first".to_string()), + (_, None) => Some("NO TIMELINE — no file open".to_string()), (None, _) => Some(format!( - "NOTHING SELECTED — click an audio clip or press {}, then ask again", + "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 the sound, so pick a clip in an audio lane".to_string(), + "NOT AN AUDIO CLIP — the equalizer works on sound".to_string(), ), _ => None, }; @@ -1495,7 +1491,7 @@ impl Player { if self.eq_params.bands.len() >= EQ_BANDS_MAX { self.notify_user( format!( - "EQUALIZER FULL — {EQ_BANDS_MAX} bands is all this card holds; move one instead" + "EQUALIZER FULL — {EQ_BANDS_MAX} bands" ) .into(), ); @@ -1512,7 +1508,7 @@ impl Player { /// is a card with nothing to edit, and flattening is what "off" means here. pub(crate) fn remove_band(&mut self, cx: &mut Context) { if self.eq_params.bands.len() <= 1 { - self.notify_user("LAST BAND — flatten it instead (r), or close the card".into()); + self.notify_user("LAST BAND · flatten r".into()); cx.notify(); return; } diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index ae1ed39..5bfe293 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -451,7 +451,7 @@ impl Player { // Nothing to write out, and a refusal rather than a card about it: the // window is empty and the export path is not even chosen yet. if self.session.is_none() { - self.notify_user("NOTHING TO EXPORT — open a file first".into()); + self.notify_user("NOTHING TO EXPORT — no file open".into()); cx.notify(); return; } @@ -722,7 +722,7 @@ impl Player { settings.subtitles = self.export_subs(); settings.range = self.range; let Some(session) = &mut self.session else { - self.notify_user("NOTHING TO EXPORT — open a file first".into()); + self.notify_user("NOTHING TO EXPORT — no file open".into()); cx.notify(); return; }; diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index e9a428e..11c671a 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -180,7 +180,7 @@ impl Player { true => { self.close_session(); format!( - "REMOVED {} — the library is empty; import a file to start again", + "REMOVED {} — the library is empty", file_name(path) ) } @@ -194,7 +194,7 @@ impl Player { } } Some(Err(e)) => format!("NOT REMOVED — {e}"), - None => "NO TIMELINE — open a file first".to_string(), + None => "NO TIMELINE — no file open".to_string(), }; self.notify_user(text.into()); cx.notify(); @@ -218,7 +218,7 @@ impl Player { return; } let Some(session) = self.session.as_mut() else { - self.notify_user("NO TIMELINE — open a file first".into()); + self.notify_user("NO TIMELINE — no file open".into()); return; }; let Some(idx) = session @@ -732,7 +732,7 @@ impl Player { // and the film has a stand-in now. Some(Proxy::Ready) if showed_stop => { let text = format!( - "PROXY READY for {} — it finished before the stop; click again to delete it", + "PROXY READY for {} — it finished before the stop", file_name(path) ); eprintln!("{text}"); @@ -904,9 +904,9 @@ impl Player { let text = match (on, ready, making) { (false, ..) => "PROXIES OFF — the films themselves are what play".to_string(), (true, 0, 0) => { - "PROXIES ON — no film here has one, so the films themselves play".to_string() + "PROXIES ON — no film here has one".to_string() } - (true, 0, n) => format!("PROXIES ON — {n} still being made; the films play until then"), + (true, 0, n) => format!("PROXIES ON — {n} still being made"), (true, n, 0) => format!("PROXIES ON — cutting on {n}"), (true, n, m) => format!("PROXIES ON — cutting on {n}, {m} still being made"), }; @@ -951,8 +951,8 @@ impl Player { session.set_auto_proxies(on); } let text = match on { - true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives", - false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them", + true => "AUTO PROXIES ON — every import gets a stand-in", + false => "AUTO PROXIES OFF — no import makes one", }; eprintln!("{text}"); // Kept for the next launch, not only the next project -- a flip made @@ -1114,7 +1114,7 @@ impl Player { .and_then(|session| subtitle_tail(session, subs)) .unwrap_or_default(); format!( - "IMPORTED {} to the library — drag it onto a lane to place it{tail}{}", + "IMPORTED {} to the library{tail}{}", file_name(path), audio_import_tail(path, self.has_video(path) && !no_video) ) @@ -1207,7 +1207,7 @@ impl Player { let what = match place { true => format!("OPENED {name}"), false => { - format!("IMPORTED {name} to the library — drag it onto a lane to place it") + format!("IMPORTED {name} to the library") } }; let audio = match place { @@ -1396,7 +1396,7 @@ impl Player { self.keymap.display(ActionId::ToggleSubtitles) ), Some(Err(e)) => format!("SUBTITLE IMPORT FAILED: {e}"), - None => "NO SUBTITLES ADDED — open a file for them to run against first".to_string(), + None => "NO SUBTITLES ADDED — no file open".to_string(), }; eprintln!("{text}"); self.notify_user(text.into()); @@ -1461,7 +1461,7 @@ impl Player { ) } Some(Err(e)) => format!("NO SUBTITLES REMOVED — {e}"), - None => "NO SUBTITLES REMOVED — open a file first".to_string(), + None => "NO SUBTITLES REMOVED — no file open".to_string(), }; eprintln!("{text}"); self.notify_user(text.into()); @@ -1587,7 +1587,7 @@ impl Player { format!("SAVED {}", file_name(&self.project_path)) } Some(Err(e)) => format!("SAVE FAILED: {e}"), - None => "NOTHING TO SAVE — open a file first".to_string(), + None => "NOTHING TO SAVE — no file open".to_string(), }; eprintln!("{text}"); self.notify_user(text.into()); @@ -1751,22 +1751,14 @@ impl Player { let lane = session.add_lane(kind); self.notify_user( format!( - "{} ADDED — drag {} onto it, {} takes it back", + "{} ADDED · undo {}", lane.label(), - // A subtitle lane takes no clip at all: what lands on it - // is a palette row, so the notice names the panel the - // hand has to go to rather than "a clip", which is the - // one thing that will never work here. - match kind { - LaneKind::Subtitle => "a subtitle from the panel", - _ => "a clip", - }, self.keymap.display(ActionId::Undo) ) .into(), ); } - None => self.notify_user("NO TRACK ADDED — open a file first".into()), + None => self.notify_user("NO TRACK ADDED — no file open".into()), } cx.notify(); } @@ -1809,7 +1801,7 @@ impl Player { ) } Some(Err(e)) => format!("NO TRACK REMOVED — {e}"), - None => "NO TRACK REMOVED — open a file first".to_string(), + None => "NO TRACK REMOVED — no file open".to_string(), }; self.notify_user(text.into()); cx.notify(); @@ -1863,7 +1855,7 @@ impl Player { } self.notify_user( format!( - "{} IS TRACK {} NOW — {} puts it back", + "{} IS TRACK {} NOW · undo {}", moved.label(), to + 1, self.keymap.display(ActionId::Undo) @@ -1901,7 +1893,7 @@ impl Player { LaneKind::Subtitle => "subtitle", } ), - false => "NO TRACK REMOVED — open a file first".to_string(), + false => "NO TRACK REMOVED — no file open".to_string(), } .into(), ); diff --git a/crates/app/src/player/timeline_edit.rs b/crates/app/src/player/timeline_edit.rs index 5a93948..c878660 100644 --- a/crates/app/src/player/timeline_edit.rs +++ b/crates/app/src/player/timeline_edit.rs @@ -73,7 +73,7 @@ impl Player { self.selected.clear(); } else { self.notify_user( - "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart" + "NOTHING TO REGROUP — no cut under the playhead" .into(), ); } @@ -98,7 +98,7 @@ impl Player { } } (Some(_), None) => { - self.notify_user("NOTHING DETACHED — click the take to take apart first".into()) + self.notify_user("NOTHING DETACHED — nothing selected".into()) } (None, _) => {} } @@ -127,7 +127,7 @@ impl Player { let picks = self.marks().0; match (&mut self.session, self.selected.anchor(), picks.len()) { (_, None, _) => { - self.notify_user("NOTHING GROUPED — click one of the halves first".into()) + self.notify_user("NOTHING GROUPED — nothing selected".into()) } // The hand's group: every pick, one id. (Some(session), _, 2..) => { @@ -147,8 +147,7 @@ impl Player { } } None => self.notify_user( - "NOTHING TO GROUP WITH — no clip on another track covers exactly these \ - frames; ctrl-click the clips to group instead" + "NOTHING TO GROUP WITH — no clip covers these frames" .into(), ), }, @@ -239,7 +238,7 @@ impl Player { } } (Some(_), None) => { - self.notify_user("NOTHING LIFTED — click the half to remove first".into()) + self.notify_user("NOTHING LIFTED — nothing selected".into()) } (None, _) => {} } @@ -407,7 +406,7 @@ impl Player { // cannot be dragged. false if from.kind != to.kind => self.notify_user( format!( - "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane", + "NOT ON {} — a {kind} clip takes a {lanes} lane", to.label() ) .into(), @@ -530,10 +529,10 @@ impl Player { // The row is greyed and says why in the list; here it says why at // the moment somebody tried to use it anyway. (None, Some(_)) => Some( - "NOT PLACED — that subtitle track has no cues to place; the list says why" + "NOT PLACED — that subtitle track has no cues" .to_string(), ), - (_, None) => Some("NOT PLACED — open a file first".to_string()), + (_, None) => Some("NOT PLACED — no file open".to_string()), }; match (text, marked) { (Some(text), _) => self.notify_user(text.into()), @@ -679,7 +678,7 @@ impl Player { .is_some_and(|session| session.lift_sub(lane, idx)); let text = match lifted { true => format!( - "CAPTION LIFTED — {} puts it back", + "CAPTION LIFTED · undo {}", self.keymap.display(ActionId::Undo) ), false => "NOTHING LIFTED — that caption is not there any more".to_string(), @@ -1254,7 +1253,7 @@ impl Player { }; self.notify_user( format!( - "GAP CLOSED on {where_} — {} takes it back", + "GAP CLOSED on {where_} · undo {}", self.keymap.display(ActionId::Undo) ) .into(), @@ -1291,12 +1290,12 @@ impl Player { let notice = match (report.closed, skipped) { (0, 0) => format!("NO GAPS TO CLOSE on {}", lane.label()), (0, 1) => format!( - "NO GAPS CLOSED on {} — 1 skipped at {}; match linked gaps or detach", + "NO GAPS CLOSED on {} — 1 linked gap skipped at {}", lane.label(), report.skipped[0].start ), (0, n) => format!( - "NO GAPS CLOSED on {} — {n} skipped; match linked gaps or detach", + "NO GAPS CLOSED on {} — {n} linked gaps skipped", lane.label() ), (n, 0) => format!( @@ -1592,7 +1591,7 @@ impl Player { _ => self.selected.anchor(), }) else { self.notify_user( - "NOTHING TO CROSSFADE — select an audio clip that has a neighbour".into(), + "NOTHING TO CROSSFADE — no audio clip selected".into(), ); cx.notify(); return; @@ -1601,7 +1600,7 @@ impl Player { if let Some(session) = &mut self.session { if !session.crossfade(lane, idx, frames) { self.notify_user( - "NOTHING TO CROSSFADE — it takes two audio clips sitting end to end on one lane" + "NOTHING TO CROSSFADE — no neighbour end to end" .into(), ); } @@ -1624,7 +1623,7 @@ impl Player { _ => self.selected.anchor(), }) else { self.notify_user( - "NOTHING TO DISSOLVE — select a video clip that has a neighbour".into(), + "NOTHING TO DISSOLVE — no video clip selected".into(), ); cx.notify(); return; @@ -1641,7 +1640,7 @@ impl Player { }; if !session.set_transition_out(lane, idx, frames) { self.notify_user( - "NOTHING TO DISSOLVE — it takes two video clips sitting end to end on one lane" + "NOTHING TO DISSOLVE — no neighbour end to end" .into(), ); } else if removing { diff --git a/crates/app/src/player/view.rs b/crates/app/src/player/view.rs index e7df591..0e5f60e 100644 --- a/crates/app/src/player/view.rs +++ b/crates/app/src/player/view.rs @@ -55,7 +55,7 @@ impl Player { pub(crate) fn select_under_playhead(&mut self, cx: &mut Context) { let under = self.under_playhead(); let Some(&first) = under.first() else { - self.notify_user("NOTHING UNDER THE PLAYHEAD — move it onto a clip first".into()); + self.notify_user("NOTHING UNDER THE PLAYHEAD".into()); cx.notify(); return; }; @@ -133,7 +133,7 @@ impl Player { return; } let Some(session) = &mut self.session else { - self.notify_user("no timeline to fit — open a file first".into()); + self.notify_user("no timeline to fit — no file open".into()); cx.notify(); return; }; @@ -151,8 +151,7 @@ impl Player { Some(half) => Some(half), None => { self.notify_user( - "NOTHING TO FIT — a caption has no picture; group it with a clip \ - first (ctrl-click both, then Group)" + "NOTHING TO FIT — a caption has no picture" .into(), ); cx.notify(); diff --git a/crates/app/src/subs.rs b/crates/app/src/subs.rs index 7e8776e..57ac839 100644 --- a/crates/app/src/subs.rs +++ b/crates/app/src/subs.rs @@ -320,10 +320,10 @@ pub(crate) type Subs = engine::Result>; /// argv named, an import, and an import into an empty window cannot say the same /// thing differently, whichever thread read the cues. /// -/// Worded for where they actually land: a *list* beside the media and nothing -/// over the picture -- a track shows when it is dragged onto a subtitle lane -/// ([`Player::subtitle_overlay`]), so the tail says the next move rather than -/// letting a count read as "and there they are on screen". +/// A count and nothing else (DESIGN §8: the room never explains itself in +/// prose). The tracks land in a *list* beside the media, not over the picture +/// ([`Player::subtitle_overlay`] shows one once it is on a subtitle lane) -- +/// where they went is the list's own geography to say, not this line's. /// /// `None` for a file that gave none and for one whose tracks are on the timeline /// already -- an import that adds nothing says nothing about subtitles. A @@ -334,8 +334,7 @@ pub(crate) fn subtitle_tail(session: &mut PlaybackSession, subs: Subs) -> Option Ok(tracks) => match session.add_subtitle_tracks(tracks) { 0 => None, n => Some(format!( - " — {n} subtitle track(s) in the file, in the subtitle list: drag one onto a \ - subtitle track to show it" + " · {n} subtitle track(s)" )), }, Err(e) => Some(format!(" — SUBTITLES UNREAD: {e}")), diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index aaaa842..6586f57 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2814,3 +2814,100 @@ fn the_lane_bed_clips_its_clips_at_the_pinned_heads() { pinned lane heads: {bed}" ); } + +/// DESIGN §8's rejected pattern, swept over the source rather than argued +/// per message: "the room never explains itself in prose ... any new string +/// over ~4 words that instructs rather than reports state is a defect". The +/// notices are what the ledger strip paints, and a sentence there is what cut +/// mid-word in the user's own screenshot (`OPENED ... 1 subtitle track(s) in `). +/// +/// The scan reads every notice-shaped literal -- one whose first word is a +/// state word in capitals, which is how every message this window pushes +/// opens -- and refuses one that is both long (over eight words) and +/// instructional (an imperative tell). A refusal *claim* may still be long: +/// those are the allowlist below, each one naming a genuine absent capability, +/// never a lesson in how to use the room. +#[test] +fn no_notice_teaches_the_room_in_prose() { + // Long refusal claims that report a capability genuinely absent from this + // machine (DESIGN §8, "a refusal string is a claim"), kept whole on + // purpose: the remedy is not a chord in this room because the missing + // thing is not in this room. + const ALLOWED: &[&str] = &["NO FILE CHOOSER"]; + const TELLS: &[&str] = &[ + "drag ", + "press ", + "pick ", + "type ", + "click ", + "to show", + "to use", + "takes it back", + "puts it back", + "first", + "instead", + ]; + let mut offenders = Vec::new(); + for path in source_files() { + let text = std::fs::read_to_string(&path).expect("a source file"); + for literal in string_literals(&text) { + // A notice opens with its state in capitals -- placeholders in + // front of it (`{count} SILENCES CUT`) are stepped over. + let head = literal + .split_whitespace() + .find(|word| !word.starts_with('{')) + .unwrap_or(""); + let shouty = head.len() >= 2 + && head + .chars() + .all(|c| c.is_ascii_uppercase() || c == '-' || c == ':'); + if !shouty || ALLOWED.iter().any(|allowed| literal.starts_with(allowed)) { + continue; + } + let long = literal.split_whitespace().count() > 8; + if long && TELLS.iter().any(|tell| literal.contains(tell)) { + offenders.push(format!("{}: {literal}", path.display())); + } + } + } + assert!( + offenders.is_empty(), + "a notice that instructs instead of reporting state (DESIGN §8):\n{}", + offenders.join("\n") + ); +} + +/// Every string literal in `text`, comments dropped first so the prose about +/// a message is never read as the message. +fn string_literals(text: &str) -> Vec { + let code: String = text + .lines() + .filter(|line| !line.trim_start().starts_with("//")) + .collect::>() + .join("\n"); + let mut out = Vec::new(); + let mut chars = code.chars().peekable(); + while let Some(c) = chars.next() { + if c != '"' { + continue; + } + let mut literal = String::new(); + while let Some(c) = chars.next() { + match c { + // A line continuation joins the halves of a wrapped message; + // every other escape is not a word either way. + '\\' => { + if chars.next() == Some('\n') { + while chars.peek() == Some(&' ') { + chars.next(); + } + } + } + '"' => break, + _ => literal.push(c), + } + } + out.push(literal); + } + out +} diff --git a/crates/app/src/tests/view.rs b/crates/app/src/tests/view.rs index de6fe56..d6face9 100644 --- a/crates/app/src/tests/view.rs +++ b/crates/app/src/tests/view.rs @@ -111,11 +111,11 @@ fn a_lane_refuses_the_files_it_cannot_hold_before_the_release_says_so() { let movie = Path::new("/media/take.mp4"); assert_eq!( lane_refuses(sound, video, false).as_deref(), - Some("NOT ON V1 — take.mp3 has no picture; drop it on an audio lane") + Some("NOT ON V1 — take.mp3 has no picture") ); assert_eq!( lane_refuses(still, audio, true).as_deref(), - Some("NOT ON A1 — card.png is a still image; drop it on a video lane") + Some("NOT ON A1 — card.png is a still image") ); // ...and every lane a file *can* go on says nothing at all, which is a // ghost drawn in the file's own colour. @@ -131,7 +131,7 @@ fn a_lane_refuses_the_files_it_cannot_hold_before_the_release_says_so() { // twin above got -- `has_video` is what decides it now, not the suffix. assert_eq!( lane_refuses(movie, video, false).as_deref(), - Some("NOT ON V1 — take.mp4 has no picture; drop it on an audio lane") + Some("NOT ON V1 — take.mp4 has no picture") ); // ...and a subtitle lane holds none of the three: a caption comes off the // Subtitles list, which is where the refusal points. diff --git a/crates/app/src/timeline_math.rs b/crates/app/src/timeline_math.rs index 22a52eb..c566853 100644 --- a/crates/app/src/timeline_math.rs +++ b/crates/app/src/timeline_math.rs @@ -659,10 +659,10 @@ pub(crate) fn lane_refuses(path: &Path, lane: Lane, has_video: bool) -> Option Some(format!( - "NOT ON {label} — {name} has no picture; drop it on an audio lane" + "NOT ON {label} — {name} has no picture" )), LaneKind::Audio if engine::is_image(path) => Some(format!( - "NOT ON {label} — {name} is a still image; drop it on a video lane" + "NOT ON {label} — {name} is a still image" )), // A subtitle lane holds words and no media at all: the refusal is here // rather than at the engine's door so the shadow is tinted red on the diff --git a/crates/app/src/transport.rs b/crates/app/src/transport.rs index 355beb9..7acb3c0 100644 --- a/crates/app/src/transport.rs +++ b/crates/app/src/transport.rs @@ -8,7 +8,7 @@ pub(crate) const NO_FILE: &str = "no file open"; /// What a press of play says when there is nothing to play: no timeline at all /// and an emptied one are the same answer to the user, so they are one line. -pub(crate) const NOTHING_TO_PLAY: &str = "NOTHING TO PLAY — put a clip on the timeline first"; +pub(crate) const NOTHING_TO_PLAY: &str = "NOTHING TO PLAY — the timeline is empty"; /// Whether a press of play would have anything to play. No timeline at all and /// one every clip has been taken off are the same state to a transport, and the diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index c47a5af..e400a78 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -783,13 +783,18 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { div() .flex_1() .min_w(px(0.)) - .truncate() + // Ellipsis, not a bare cut: `.truncate()` stops mid-word with + // nothing saying it stopped (user report, `… 1 subtitle track(s) + // in `). The name inside the message is elided through its + // middle first ([`ledger_line`]) so the state word at the front + // is never what the strip drops. + .text_ellipsis() .type_style(type_scale::mono( type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM, )) .text_color(rgb(action_ink)) - .child(last_action), + .child(ledger_line(&last_action)), ) .children(export.map(|e| { div()