From 26cac8cd2d87e604de80bdcf0ec256c1e581d9c9 Mon Sep 17 00:00:00 2001 From: Valentin Millet Date: Fri, 27 Nov 2026 18:39:38 +0100 Subject: [PATCH 1/2] Unlock screen: an available update is offered there, not in a popup While the gate is shown no update dialog opens; the card says the version under its form, with Install now. Unlocking with the offer unanswered leaves it to the About menu. --- crates/i18n/translations/en.json | 1 + crates/i18n/translations/fr.json | 1 + crates/ui/src/app.rs | 16 +++- crates/ui/src/app/captures.rs | 21 +++++ crates/ui/src/app/gate_update_tests.rs | 100 +++++++++++++++++++++++ crates/ui/src/app/update_prompt_tests.rs | 7 ++ crates/ui/src/banners/update_prompt.rs | 2 +- crates/ui/src/gate/draw.rs | 59 ++++++++++++- crates/ui/src/gate/mod.rs | 2 +- crates/ui/src/gate/tests.rs | 8 +- crates/ui/src/services/updates.rs | 7 ++ crates/ui/src/state/mod.rs | 6 +- crates/ui/src/titlebar/about_menu/mod.rs | 5 +- docs/architecture.md | 6 +- 14 files changed, 229 insertions(+), 12 deletions(-) create mode 100644 crates/ui/src/app/gate_update_tests.rs diff --git a/crates/i18n/translations/en.json b/crates/i18n/translations/en.json index e1d8351d..8e86a090 100644 --- a/crates/i18n/translations/en.json +++ b/crates/i18n/translations/en.json @@ -1214,6 +1214,7 @@ "close": "Close" }, "vault": { + "updateAvailable": "{{app}} {{version}} is available", "library": "Library", "switchLibrary": "Open another library", "createTitle": "Protect this library", diff --git a/crates/i18n/translations/fr.json b/crates/i18n/translations/fr.json index e51d83a5..e08cc2f8 100644 --- a/crates/i18n/translations/fr.json +++ b/crates/i18n/translations/fr.json @@ -1214,6 +1214,7 @@ "close": "Fermer" }, "vault": { + "updateAvailable": "{{app}} {{version}} est disponible", "library": "Bibliothèque", "switchLibrary": "Ouvrir une autre bibliothèque", "createTitle": "Protéger cette bibliothèque", diff --git a/crates/ui/src/app.rs b/crates/ui/src/app.rs index d75ecf0d..68c03ff1 100644 --- a/crates/ui/src/app.rs +++ b/crates/ui/src/app.rs @@ -371,16 +371,26 @@ impl eframe::App for DevNotesApp { } } else { let mut asked = Vec::new(); - gate::show( + let updates = &self.state.updates; + let offer = updates.offered().map(|update| gate::Offer { + version: &update.version, + status: updates.status(), + percent: updates.progress(), + }); + let install = gate::show( ui, &self.state.gate, &mut self.state.gate_view, - language, + (language, offer), &mut asked, ); for action in asked { actions.push(Action::Gate(action)); } + if install { + let asked = crate::banners::update_prompt::Ask::Install; + actions.push(Action::Menu(crate::titlebar::Action::Update(asked))); + } } }); if self.state.gate.is_open() { @@ -438,6 +448,8 @@ mod area_switch_tests; #[cfg(test)] mod library_panel_tests; +#[cfg(test)] +mod gate_update_tests; #[cfg(test)] mod rail_toggle_tests; #[cfg(test)] diff --git a/crates/ui/src/app/captures.rs b/crates/ui/src/app/captures.rs index d54ccd16..04d3aa09 100644 --- a/crates/ui/src/app/captures.rs +++ b/crates/ui/src/app/captures.rs @@ -2085,3 +2085,24 @@ fn a_wrapped_list_selected_whole() { settle(&mut harness); capture(&mut harness, "note-menu"); } + +#[test] +fn an_update_found_at_the_gate() { + use crate::services::updates::UpdateState; + use crate::services::updates::fake::FakeUpdater; + let profile = tempfile::tempdir().unwrap(); + let mut creating = launch(profile.path()); + type_into(&mut creating, "vault-passphrase", PASSPHRASE); + type_into(&mut creating, "vault-confirmation", PASSPHRASE); + click(&mut creating, "vault-submit"); + settle(&mut creating); + crate::testing::close_library(&creating.state().backend); + drop(creating); + + let mut harness = launch(profile.path()); + harness.state_mut().state.updates = UpdateState::with(FakeUpdater::offering("1.2.2")); + let app = harness.state_mut(); + app.state.updates.check(&app.backend, true); + settle(&mut harness); + capture(&mut harness, "gate-update"); +} diff --git a/crates/ui/src/app/gate_update_tests.rs b/crates/ui/src/app/gate_update_tests.rs new file mode 100644 index 00000000..33f84884 --- /dev/null +++ b/crates/ui/src/app/gate_update_tests.rs @@ -0,0 +1,100 @@ +//! An update found while the passphrase is asked: said on the unlock card, never a dialog +//! taking the keys from the field. + +use std::path::Path; +use std::sync::Arc; + +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; + +use super::DevNotesApp; +use super::tests::{click, open_library, present, settle, startup}; +use crate::services::updates::UpdateState; +use crate::services::updates::fake::FakeUpdater; + +/// A library made, then the window launched again over it: the unlock card, the launch's +/// check answered by `fake` while it is shown. +fn at_the_gate(directory: &Path, fake: Arc) -> Harness<'static, DevNotesApp> { + let first = open_library(directory); + crate::testing::close_library(first.state().backend()); + drop(first); + let startup = startup(directory); + let mut harness = Harness::builder() + .with_size(egui::vec2(1100.0, 720.0)) + .build_eframe(|cc| DevNotesApp::new(cc, startup).unwrap()); + harness + .ctx + .set_missing_glyph_policy(egui::epaint::text::MissingGlyphPolicy::Tofu); + settle(&mut harness); + harness.state_mut().state.updates = UpdateState::with(fake); + let app = harness.state_mut(); + app.state.updates.check(&app.backend, true); + settle(&mut harness); + harness +} + +fn focused(harness: &Harness<'_, DevNotesApp>) -> Option { + let node = harness.query_by(|node| node.is_focused() && node.author_id().is_some())?; + node.accesskit_node().author_id().map(str::to_owned) +} + +#[test] +fn an_update_found_at_the_gate_is_said_on_the_card_and_the_field_keeps_the_keys() { + let directory = tempfile::tempdir().unwrap(); + let mut harness = at_the_gate(directory.path(), FakeUpdater::offering("0.26.0")); + + assert!(!harness.state().state().gate.is_open()); + assert!( + !present(&harness, "update-prompt"), + "no dialog over the field" + ); + assert!(present(&harness, "gate-update")); + assert_eq!(focused(&harness).as_deref(), Some("vault-passphrase")); + + harness + .get_by(|node| node.author_id() == Some("vault-passphrase")) + .type_text(crate::testing::PASSPHRASE); + harness.key_press(egui::Key::Enter); + settle(&mut harness); + + assert!( + harness.state().state().gate.is_open(), + "Enter still unlocks" + ); + assert!(!present(&harness, "update-prompt"), "nor once unlocked"); + click(&mut harness, "about-open"); + let entry = harness.get_by(|node| node.author_id() == Some("about-check-updates")); + let label = entry.accesskit_node().label().unwrap_or_default(); + assert!(label.contains("0.26.0"), "{label}"); +} + +#[test] +fn install_now_from_the_gate_downloads_the_update() { + let directory = tempfile::tempdir().unwrap(); + let fake = FakeUpdater::offering("0.26.0"); + let mut harness = at_the_gate(directory.path(), Arc::clone(&fake)); + + click(&mut harness, "gate-update-install"); + settle(&mut harness); + + assert!( + harness.state().state().quitting, + "downloaded, it leaves for the installer" + ); + eframe::App::on_exit(harness.state_mut()); + assert!(*fake.relaunched.lock().unwrap()); +} + +#[test] +fn an_update_silenced_is_not_said_at_the_gate() { + let directory = tempfile::tempdir().unwrap(); + let mut harness = at_the_gate(directory.path(), Arc::new(FakeUpdater::default())); + harness.state_mut().state.settings.update_notifications = false; + harness.state_mut().state.updates = UpdateState::with(FakeUpdater::offering("0.26.0")); + let app = harness.state_mut(); + app.state.updates.check(&app.backend, true); + settle(&mut harness); + + assert!(!present(&harness, "gate-update")); + assert!(!present(&harness, "update-prompt")); +} diff --git a/crates/ui/src/app/update_prompt_tests.rs b/crates/ui/src/app/update_prompt_tests.rs index 85c7f588..793340d9 100644 --- a/crates/ui/src/app/update_prompt_tests.rs +++ b/crates/ui/src/app/update_prompt_tests.rs @@ -180,3 +180,10 @@ fn an_update_known_is_named_by_its_entry_drawn_clear_of_the_next() { click(&mut harness, "about-check-updates"); assert!(present(&harness, "update-prompt"), "the offer reopened"); } + +#[test] +fn an_update_found_with_the_library_open_still_opens_its_dialog() { + let directory = tempfile::tempdir().unwrap(); + let harness = launched(directory.path(), FakeUpdater::offering("0.26.0")); + assert!(present(&harness, "update-prompt")); +} diff --git a/crates/ui/src/banners/update_prompt.rs b/crates/ui/src/banners/update_prompt.rs index 05641c64..09ec4a35 100644 --- a/crates/ui/src/banners/update_prompt.rs +++ b/crates/ui/src/banners/update_prompt.rs @@ -49,7 +49,7 @@ pub(crate) fn show( view: &mut UpdateView, actions: &mut Actions, ) { - let Some(update) = state.updates.offered() else { + let Some(update) = state.updates.offered().filter(|_| state.gate.is_open()) else { return; }; let cross = i18n::translate(state.language, i18n::keys::dialog::CLOSE, &[]); diff --git a/crates/ui/src/gate/draw.rs b/crates/ui/src/gate/draw.rs index 8eb565ca..24336871 100644 --- a/crates/ui/src/gate/draw.rs +++ b/crates/ui/src/gate/draw.rs @@ -8,17 +8,28 @@ use i18n::{Key, Language, Message, keys}; use super::passphrase::PassphraseField; use super::{Action, Gate, GateView}; +use crate::services::updates::Status; use crate::theme::palette; use crate::widgets::{self, Button, ChoiceMenu, Kind}; +use engine::app_info::METADATA; -/// The whole window while the library is not open. +/// An update found while the library is closed, as the caller knows it. +pub struct Offer<'a> { + pub version: &'a str, + pub status: Status, + pub percent: Option, +} + +/// The whole window while the library is not open. `true` when the update offered is to be +/// installed: the gate only says it. pub fn show( ui: &mut Ui, gate: &Gate, view: &mut GateView, - language: Language, + (language, offer): (Language, Option>), actions: &mut Vec, -) { +) -> bool { + let mut install = false; let p = palette(ui.ctx()); let tr = |key: Key| i18n::translate(language, key, &[]); let height_id = ui.scope_id().with("gate-height"); @@ -63,10 +74,52 @@ pub fn show( } else { form(ui, gate, view, language, actions); } + if let Some(offer) = &offer { + install = update_line(ui, offer, language); + } }); }); ui.data_mut(|data| data.insert_temp(height_id, shown.response.rect.height())); }); + install +} + +/// Under the form, at the card's bottom: the version found and « Install now », then how far +/// its download is. The field keeps the keys: nothing here asks for the focus. +fn update_line(ui: &mut Ui, offer: &Offer<'_>, language: Language) -> bool { + let p = palette(ui.ctx()); + let said = match (offer.status, offer.percent) { + (Status::Installed, _) => Message::new(keys::update::RESTARTING) + .with("app", METADATA.name) + .text(language), + (Status::Installing, Some(percent)) => Message::new(keys::update::DOWNLOADING_PERCENT) + .with("percent", percent) + .text(language), + (Status::Installing, None) => i18n::translate(language, keys::update::DOWNLOADING, &[]), + _ => Message::new(keys::vault::UPDATE_AVAILABLE) + .with("app", METADATA.name) + .with("version", offer.version) + .text(language), + }; + let top = ui.cursor().top(); + ui.painter() + .hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.line_soft)); + ui.horizontal(|ui| { + let shown = ui.label(small(&said, p.text_2)); + widgets::address(ui, &shown, "gate-update"); + if offer.status != Status::Available { + return false; + } + ui.with_layout(Layout::right_to_left(Align::Center), |ui| { + let install = i18n::translate(language, keys::update::INSTALL, &[]); + Button::new(&install, "gate-update-install") + .kind(Kind::Quiet) + .show(ui) + .clicked() + }) + .inner + }) + .inner } /// Which library the panel is about, above what it asks: several can be asked for here. diff --git a/crates/ui/src/gate/mod.rs b/crates/ui/src/gate/mod.rs index 4fbfd760..20de3b5d 100644 --- a/crates/ui/src/gate/mod.rs +++ b/crates/ui/src/gate/mod.rs @@ -5,7 +5,7 @@ mod draw; pub mod passphrase; pub mod prompt; -pub use draw::show; +pub use draw::{Offer, show}; use engine::error::{AppError, ErrorCode}; use engine::libraries::registry::Registry; diff --git a/crates/ui/src/gate/tests.rs b/crates/ui/src/gate/tests.rs index 2bdd8a35..2c0b7509 100644 --- a/crates/ui/src/gate/tests.rs +++ b/crates/ui/src/gate/tests.rs @@ -29,7 +29,13 @@ fn screen(backend: Backend, profile: tempfile::TempDir) -> Harness<'static, Scre .gate .update(&screen.backend, &mut screen.status, &mut screen.errors); let mut asked = Vec::new(); - show(ui, &screen.gate, &mut screen.view, Language::En, &mut asked); + show( + ui, + &screen.gate, + &mut screen.view, + (Language::En, None), + &mut asked, + ); for action in asked { screen.gate.apply(action, &mut screen.view, &screen.backend); } diff --git a/crates/ui/src/services/updates.rs b/crates/ui/src/services/updates.rs index 47ffe7cf..76bcaffa 100644 --- a/crates/ui/src/services/updates.rs +++ b/crates/ui/src/services/updates.rs @@ -108,6 +108,13 @@ impl UpdateState { .filter(|_| self.status != Status::Installed) } + /// The offer said on the unlock card and left unanswered: the menu keeps it, no dialog opens. + pub fn put_away(&mut self) { + if self.status == Status::Available { + self.status = Status::Idle; + } + } + /// The offer put away by « Later », shown again: no new check. pub fn reopen(&mut self) { if self.update.is_some() && self.status == Status::Idle { diff --git a/crates/ui/src/state/mod.rs b/crates/ui/src/state/mod.rs index de83d0ff..0f079f51 100644 --- a/crates/ui/src/state/mod.rs +++ b/crates/ui/src/state/mod.rs @@ -282,13 +282,17 @@ impl AppState { self.dialogs.begin_frame(ctx); self.help.update(); self.updates.update(&self.settings, &mut self.errors); - let offered = self.updates.offered().is_some(); + // The unlock card says the offer: no dialog takes the keys from the passphrase. + let offered = self.updates.offered().is_some() && self.gate.is_open(); let prompt = crate::banners::update_prompt::id(); self.dialogs.follow(ctx, Layer::Update, prompt, offered); if self .gate .update(backend, &mut self.status, &mut self.errors) { + if self.gate.is_open() { + self.updates.put_away(); + } self.reset_library_scope(ctx, backend); } if self.autostart.update(backend, &mut self.settings) { diff --git a/crates/ui/src/titlebar/about_menu/mod.rs b/crates/ui/src/titlebar/about_menu/mod.rs index 506f688b..67b29215 100644 --- a/crates/ui/src/titlebar/about_menu/mod.rs +++ b/crates/ui/src/titlebar/about_menu/mod.rs @@ -62,8 +62,9 @@ pub(super) fn show(ui: &mut Ui, state: &AppState, view: &mut View, actions: &mut if state.updates.has_pending() { dot(ui, &anchor, state, "update-dot"); } - // The check keeps the menu open for its answer; an offer is answered in its own dialog. - if state.updates.offered().is_some() { + // The check keeps the menu open for its answer; an offer is answered in its own dialog, which + // the unlock card does without. + if state.updates.offered().is_some() && state.gate.is_open() { Popup::close_id(ui.ctx(), Popup::default_response_id(&anchor)); } let shown = Popup::menu(&anchor) diff --git a/docs/architecture.md b/docs/architecture.md index 5e7479f7..663ff2ea 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -6221,7 +6221,11 @@ key can produce an installable update. It is the key the Tauri releases were sig it back. ⚠️ Only the **silent** check at launch is silenced; the one asked from the menu always answers. - **The dot on the About menu** says « an update exists and is not installed », and outlives the - prompt it was raised with. + prompt it was raised with; the menu's entry then names the version and opens the offer again. + The menu says what a check found only when it was asked from it, and forgets it once closed. +- **No dialog over the passphrase.** While the unlock card is shown, the offer is a line at its + bottom with « Install now »: a dialog would take the keys from someone typing their phrase. + Unlocking with the offer unanswered puts it away (`put_away`): the dot and the entry keep it. - **The notes the prompt shows** are the release's changelog section less what the user cannot see, carried by `latest.json` (→ "The update prompt shows the release's notes"). - **The manifest** (`latest.json`, `scripts/latest-json.mjs`) carries the NSIS installer, the From fb549cfa1623f6c93d3e98a1ea720b2faf7490d4 Mon Sep 17 00:00:00 2001 From: Valentin Millet Date: Fri, 27 Nov 2026 21:06:03 +0100 Subject: [PATCH 2/2] Unlock screen: the update line in amber, its button outlined At the owner's word: the line and Install now drawn in the accent, the button an outline, to be seen under the form. --- crates/ui/src/gate/draw.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/ui/src/gate/draw.rs b/crates/ui/src/gate/draw.rs index 24336871..9bd8a1e0 100644 --- a/crates/ui/src/gate/draw.rs +++ b/crates/ui/src/gate/draw.rs @@ -84,8 +84,8 @@ pub fn show( install } -/// Under the form, at the card's bottom: the version found and « Install now », then how far -/// its download is. The field keeps the keys: nothing here asks for the focus. +/// Under the form, at the card's bottom, in amber to be seen: the version found and « Install +/// now », then how far its download is. The field keeps the keys: nothing here asks for the focus. fn update_line(ui: &mut Ui, offer: &Offer<'_>, language: Language) -> bool { let p = palette(ui.ctx()); let said = match (offer.status, offer.percent) { @@ -104,8 +104,11 @@ fn update_line(ui: &mut Ui, offer: &Offer<'_>, language: Language) -> bool { let top = ui.cursor().top(); ui.painter() .hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.line_soft)); - ui.horizontal(|ui| { - let shown = ui.label(small(&said, p.text_2)); + ui.add_space(gap::TIGHT); + // A row of the button's height: `horizontal` centres on egui's smaller default. + let row = Vec2::new(ui.available_width(), widgets::MIN_TARGET + gap::TIGHT); + ui.allocate_ui_with_layout(row, Layout::left_to_right(Align::Center), |ui| { + let shown = ui.label(small(&said, p.amber_text)); widgets::address(ui, &shown, "gate-update"); if offer.status != Status::Available { return false; @@ -113,7 +116,7 @@ fn update_line(ui: &mut Ui, offer: &Offer<'_>, language: Language) -> bool { ui.with_layout(Layout::right_to_left(Align::Center), |ui| { let install = i18n::translate(language, keys::update::INSTALL, &[]); Button::new(&install, "gate-update-install") - .kind(Kind::Quiet) + .kind(Kind::Accent) .show(ui) .clicked() })