SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Link the version number to its release notes (#5488) (#5765)
rlartotf5a6c8fa5182
diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rsindex d6d08ff4ef..c821a1aff5 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.rsindex 3c0cde8451..1bf5b17448 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<version>`), 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.rsindex e4724c5787..0e31bc4940 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");+}