From a9fc7b98fe9488ee6f01a257c6b3a55055108b40 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 27 Nov 2026 01:57:37 +0300 Subject: [PATCH] =?UTF-8?q?opening=20session:=20summary=20shows=20new=20mo?= =?UTF-8?q?ves=20left=20and=20the=20next=20review=20separately;=20no=20?= =?UTF-8?q?=C2=AB=C3=97=20Finish=C2=BB=20on=20the=20summary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src/i18n.rs | 29 +++++++++++----- apps/desktop/src/opening_session.rs | 42 +++++++++++++---------- apps/desktop/src/opening_session_tests.rs | 3 ++ 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/apps/desktop/src/i18n.rs b/apps/desktop/src/i18n.rs index 70dd1c9..da94988 100644 --- a/apps/desktop/src/i18n.rs +++ b/apps/desktop/src/i18n.rs @@ -811,15 +811,26 @@ const ROWS: &[[&str; 9]] = &[ "Тармақ: {path}", ], [ - "today, {n} more", - "сегодня, ещё {n}", - "aujourd’hui, encore {n}", - "heute, noch {n}", - "hoy, {n} más", - "oggi, altre {n}", - "hoje, mais {n}", - "bugun, yana {n} ta", - "бүгін, тағы {n}", + "New moves left", + "Новых ходов осталось", + "Nouveaux coups restants", + "Neue Züge übrig", + "Jugadas nuevas restantes", + "Mosse nuove rimaste", + "Lances novos restantes", + "Qolgan yangi yurishlar", + "Қалған жаңа жүрістер", + ], + [ + "nothing scheduled", + "нет запланированных", + "rien de prévu", + "nichts geplant", + "nada programado", + "niente in programma", + "nada agendado", + "rejalashtirilmagan", + "жоспарланған жоқ", ], [ "{k} of {n}", diff --git a/apps/desktop/src/opening_session.rs b/apps/desktop/src/opening_session.rs index 6d5a174..425e372 100644 --- a/apps/desktop/src/opening_session.rs +++ b/apps/desktop/src/opening_session.rs @@ -210,6 +210,8 @@ enum State { /// Computed once when the result is shown. struct Summary { next_review: String, + /// Moves never shown yet, all of them (the «more new» button takes up to 10). + unseen: usize, more_new: usize, } @@ -1597,30 +1599,26 @@ impl OpeningSessionUi { .iter() .map(|item| (&item.key, item)) .collect(); - let today = layout::end_of_today(); let now = layout::now(); - let mut due_today = 0usize; let mut next: Option = None; let mut unseen = 0usize; for key in &self.repertoire_keys { match items.get(key) { Some(item) if item.introduced => { - if item.is_due(today) { - due_today += 1; - } else if let Some(at) = item.next_review_at { + if let Some(at) = item.next_review_at { next = Some(next.map_or(at, |old| old.min(at))); } } _ => unseen += 1, } } - let next_review = if due_today > 0 { - trf("today, {n} more", &[("n", &due_today)]) - } else { - next.map(|at| layout::when(at, now)).unwrap_or_default() + let next_review = match next { + Some(at) => layout::when(at.max(now), now), + None => tr("nothing scheduled").to_owned(), }; self.summary = Some(Summary { next_review, + unseen, more_new: unseen.min(layout::NEW_PER_SESSION), }); } @@ -1903,9 +1901,10 @@ impl OpeningSessionUi { ui.add_space(4.0); ui.separator(); ui.add_space(4.0); - if let Some(summary) = &self.summary - && !summary.next_review.is_empty() - { + if let Some(summary) = &self.summary { + if self.kind == SessionKind::Daily && summary.unseen > 0 { + row(ui, tr("New moves left"), summary.unseen.to_string()); + } row(ui, tr("Next review"), summary.next_review.clone()); } if self.tally.missed.is_empty() { @@ -2007,6 +2006,8 @@ impl OpeningSessionUi { left, right, *state == State::Summary || matches!(state, State::SaveError(_)), + // The summary has its own way out; «× Finish» there would be a second one. + *state != State::Summary, ); match clicked { Some(Clicked::Left) => match state { @@ -2222,6 +2223,7 @@ pub fn show_preparing( Some((tr("Hint (H)").to_owned(), false)), None, false, + true, ); if clicked == Some(Clicked::Finish) { actions.push(SessionAction::Back); @@ -2321,6 +2323,7 @@ fn side_panel( left: Option<(String, bool)>, right: Option<(String, bool)>, right_primary: bool, + finish: bool, ) -> Option { let mut clicked = None; let rect = ui.available_rect_before_wrap(); @@ -2391,13 +2394,14 @@ fn side_panel( clicked = Some(Clicked::Flip); } ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if ui - .add( - egui::Button::new(RichText::new(tr("× Finish")).size(14.0)) - .min_size(vec2(0.0, TOOL_H)), - ) - .on_hover_text(tr("Finish the session (Esc)")) - .clicked() + if finish + && ui + .add( + egui::Button::new(RichText::new(tr("× Finish")).size(14.0)) + .min_size(vec2(0.0, TOOL_H)), + ) + .on_hover_text(tr("Finish the session (Esc)")) + .clicked() { clicked = Some(Clicked::Finish); } diff --git a/apps/desktop/src/opening_session_tests.rs b/apps/desktop/src/opening_session_tests.rs index 13f8d31..0b51aa8 100644 --- a/apps/desktop/src/opening_session_tests.rs +++ b/apps/desktop/src/opening_session_tests.rs @@ -2205,4 +2205,7 @@ fn a_mistake_on_the_first_move_returns_it_once_and_keeps_the_count() { assert!(f.ui.is_finished()); assert_eq!(asked, ["g1f3", "f1b5", "e2e4"]); assert_eq!(f.ui.session.remaining(), 0); + let summary = f.ui.summary.as_ref().unwrap(); + assert_eq!((summary.unseen, summary.more_new), (0, 0)); + assert!(!summary.next_review.is_empty()); }