Updates: the updater reports installing, ready, installed and failed, and installs at exit

craft-update moves from c5a1cbfb to c7c84230 on dotCooCoo/craft-libs, a
branch that merges storytold/craft-libs#687 and #696 into craft-libs main.

The check result window shows for every status but idle and stays closed
while the startup prompt is open. At the first start after an update it
reports that the update installed or why it failed. Its Restart to Update
calls Updater::restart_to_update. The install helper now starts when the
app exits and drops the updater.
This commit is contained in:
dotCooCoo committed 2026-11-08 12:46:13 -08:00
1 parent b0c3f85cc8
commit 076c6b1afc
3 files changed
+41 -10

No files matched your search

Generated
+1 -2
View File
@@ -1138,7 +1138,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7"
source = "git+https://github.com/dotCooCoo/craft-libs?rev=c7c84230631cbc01ee928f0a0e0d838b1ed612ae#c7c84230631cbc01ee928f0a0e0d838b1ed612ae"
dependencies = [
"chrono",
"dunce",
@@ -7945,7 +7945,6 @@ dependencies = [
"nix",
"typed-path",
"windows-sys 0.61.2",
"zopfli",
]
[[package]]
+1 -1
View File
@@ -18,7 +18,7 @@ craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "92d392c
# Separations, ink coverage and the ink manager; same revision as craft-pdf and the krilla patch.
craft-prepress = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", version = "=0.1.0", features = ["flatten"] }
# craft-update: app-specific pretend versions apply to startup and manual checks.
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] }
craft-update = { git = "https://github.com/dotCooCoo/craft-libs", version = "=0.1.0", rev = "c7c84230631cbc01ee928f0a0e0d838b1ed612ae", features = ["egui"] }
# internal
designcraft-geom = { path = "crates/geom" }
designcraft-color = { path = "crates/color" }
+39 -7
View File
@@ -4,7 +4,7 @@ use serde_json::Value;
use crate::DesignApp;
#[cfg(all(not(target_arch = "wasm32"), test))]
#[cfg(not(target_arch = "wasm32"))]
use craft_update::updater::Status;
#[cfg(not(target_arch = "wasm32"))]
use craft_update::updater::{Action, Updater};
@@ -84,10 +84,18 @@ pub(crate) fn tick(app: &mut DesignApp, ctx: &egui::Context) {
let _ = (app, ctx);
}
/// Whether the check result window shows: for every status but idle (a requested check, and the
/// first start after an update, which reports that it installed or why it failed), and never over
/// the startup prompt.
#[cfg(not(target_arch = "wasm32"))]
fn result_window_shows(status: &Status, prompt_open: bool) -> bool {
!prompt_open && !matches!(status, Status::Idle)
}
pub(crate) fn show(app: &mut DesignApp, ctx: &egui::Context) {
#[cfg(not(target_arch = "wasm32"))]
{
// The restart helper is scheduled before the app closes, so no update starts over unsaved work.
// The updater asks to close only when no document has unsaved changes; the install starts when the app exits.
let clean = !app.session.documents().iter().any(|d| d.is_dirty());
match app.updates_rt.updater.show_if(ctx, clean) {
Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)),
@@ -95,11 +103,15 @@ pub(crate) fn show(app: &mut DesignApp, ctx: &egui::Context) {
Action::None => {}
}
// Help ▸ Check for Updates answers in the shared dialog, which follows the updater's status.
let dialog = CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION"));
match dialog.show(ctx, app.updates_rt.updater.status()) {
CheckResultResponse::None => {}
CheckResultResponse::Close => app.updates_rt.updater.dismiss_status(),
CheckResultResponse::CheckAgain => app.updates_rt.check_requested = true,
if result_window_shows(app.updates_rt.updater.status(), app.updates_rt.updater.prompt_open()) {
let dialog = CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION"));
match dialog.show(ctx, app.updates_rt.updater.status()) {
CheckResultResponse::None => {}
CheckResultResponse::Close => app.updates_rt.updater.dismiss_status(),
CheckResultResponse::CheckAgain => app.updates_rt.check_requested = true,
// The next `show_if` asks the window to close once no document has unsaved changes.
CheckResultResponse::RestartToUpdate => app.updates_rt.updater.restart_to_update(),
}
}
}
@@ -165,4 +177,24 @@ mod tests {
output.textures_delta.clear();
assert!(app.updates_rt.updater.prompt_open());
}
#[test]
#[cfg(not(target_arch = "wasm32"))]
fn result_window_shows_every_status_but_idle() {
let shown = [
Status::Checking,
Status::UpToDate,
Status::Failed("no network".into()),
Status::Installing,
Status::Ready,
Status::Managed,
Status::Updated("0.2.0".into()),
Status::InstallFailed("disk full".into()),
];
for status in &shown {
assert!(result_window_shows(status, false), "{status:?}");
assert!(!result_window_shows(status, true), "{status:?} over the prompt");
}
assert!(!result_window_shows(&Status::Idle, false));
}
}