From f5a6c8fa5182cba7421a512f07e772b8748aaad7 Mon Sep 17 00:00:00 2001 From: rlartot <94693724+rlartot@users.noreply.github.com> Date: Sun, 25 Oct 2026 01:25:51 +0000 Subject: [PATCH] Link the version number to its release notes (#5488) (#5765) * claim: #5488 Co-Authored-By: Claude Sonnet 5.5 * Link the version number in the title bar to its release notes (#5488) The version at the right of the title bar opens the release page of this build (v, which exists for stable, candidate and nightly releases) in the browser; a development build opens the release history. Its click area stops at the report button, which the long version strings of candidates and nightlies overlap. Co-Authored-By: Claude Sonnet 5.5 --------- Co-authored-by: Claude Sonnet 5.5 --- crates/ui-egui/src/toolbar.rs | 39 +++++++++++++++++++++++++----- crates/ui-egui/src/update.rs | 12 +++++++++ crates/ui-egui/src/update/tests.rs | 12 +++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index d6d08ff4e..c821a1aff 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -475,13 +475,25 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) { crate::prefs::open_at(app, 0); } if r.width() >= 640.0 { - ui.painter().text( - pos2(r.right() - 12.0 - captions, r.center().y), - Align2::RIGHT_CENTER, - format!("v{}", crate::update::current_version()), - FontId::proportional(t.font_small), - t.app_bar_text, + // The version links to its release notes. + let galley = + ui.painter().layout_no_wrap(format!("v{}", crate::update::current_version()), FontId::proportional(t.font_small), t.app_bar_text); + let vrect = Align2::RIGHT_CENTER.anchor_size(pos2(r.right() - 12.0 - captions, r.center().y), galley.size()); + let vresp = ui.interact( + vrect.expand2(vec2(2.0, 4.0)).intersect(Rect::everything_right_of(report.right())), + ui.id().with("sc_version_link"), + Sense::click(), ); + let url = crate::update::release_notes_url(crate::update::current_version(), crate::update::release_build()); + let vresp = vresp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(&url); + if vresp.hovered() || vresp.has_focus() { + ui.painter().hline(vrect.x_range(), vrect.bottom(), Stroke::new(1.0, t.app_bar_text)); + } + ui.painter().galley(vrect.min, galley, t.app_bar_text); + crate::scenario::publish_handle("titlebar:version", vrect.center()); + if vresp.clicked() { + ui.ctx().open_url(egui::OpenUrl::new_tab(url)); + } } } if app.custom_titlebar { @@ -2548,6 +2560,21 @@ mod header_report_tests { assert!(ru > en + 10.0, "{ru}"); } + #[test] + fn the_version_link_never_covers_the_report_button() { + for width in [700.0, 900.0, 1400.0] { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + h.app.custom_titlebar = true; + h.call("ui.resize", json!({"width":width,"height":720})); + h.frames(3); + let version = crate::scenario::handle_at("titlebar:version").expect("the version is drawn as a link"); + let report = crate::scenario::handle_at("titlebar:report").expect("the report button is drawn"); + // Its click area starts where the report button ends, so a click on that button reaches the report. + assert!(version.x > report.x, "width {width}"); + } + } + #[test] fn header_report_actual_click_opens_capture_without_changing_healthy_design() { for width in [450.0, 700.0, 900.0, 1400.0] { diff --git a/crates/ui-egui/src/update.rs b/crates/ui-egui/src/update.rs index 3c0cde845..1bf5b1744 100644 --- a/crates/ui-egui/src/update.rs +++ b/crates/ui-egui/src/update.rs @@ -102,6 +102,18 @@ pub fn comparable(v: &semver::Version) -> semver::Version { v } +/// Where the release notes of `version` are: its own release page for a release build (stable, +/// candidate and nightly releases are all tagged `v`), else, for a development build or +/// a string that is not a version, the release history. +pub fn release_notes_url(version: &str, release_build: bool) -> String { + const HISTORY: &str = "https://github.com/tangency-labs/solidcraft/releases"; + if release_build && parse_version(version).is_some() && version.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '-' | '+')) { + format!("{HISTORY}/tag/v{version}") + } else { + HISTORY.to_string() + } +} + /// `latest` (a release tag) is a stable release newer than the `current` build. pub fn is_newer(latest: &str, current: &str) -> bool { let (Some(latest), Some(current)) = (parse_version(latest), parse_version(current)) else { return false }; diff --git a/crates/ui-egui/src/update/tests.rs b/crates/ui-egui/src/update/tests.rs index e4724c578..0e31bc494 100644 --- a/crates/ui-egui/src/update/tests.rs +++ b/crates/ui-egui/src/update/tests.rs @@ -517,3 +517,15 @@ fn releases_under_either_owner_are_accepted() { assert!(!is_release_url("https://github.com.evil.example/tangency-labs/solidcraft/releases/x")); assert!(!is_release_url("https://github.com/tangency-labs/solidcraft/issues/1")); } + +#[test] +fn the_version_links_to_its_release_notes() { + // A release build opens the page of its own release; stable, candidate and nightly tags all exist. + for v in ["0.17.0", "0.21.0-rc.2", "0.20.0-nightly.20261023.69.1"] { + assert_eq!(release_notes_url(v, true), format!("https://github.com/tangency-labs/solidcraft/releases/tag/v{v}")); + } + // A development build has no release of its own: the release history, which is what the issue asks for. + assert_eq!(release_notes_url("0.17.0", false), "https://github.com/tangency-labs/solidcraft/releases"); + // Anything that is not a version never ends up in a URL. + assert_eq!(release_notes_url("0.1/../../x", true), "https://github.com/tangency-labs/solidcraft/releases"); +}