Control channel: a failed app.open answers with the error and opens no alert

An alert waits for a click that a control client can't give. app.open
reports the error in its response, as engine.execute does; File › Open,
drops and the command line still show the alert.
This commit is contained in:
aiongg
2026-10-09 22:13:15 +00:00
parent 1ccf4fbfbe
commit ea4740cbc8
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -334,7 +334,7 @@ pub fn handle(app: &mut DesignApp, ctx: &egui::Context, req: &ControlRequest) ->
None => ok(json!({"width": img.width, "height": img.height, "pngBase64": designcraft_engine::cmd::base64_encode(&png)})),
}
}
"app.open" => wrap(app.open_file("file.open", json!({"path": s("path")}))),
"app.open" => wrap(app.run("file.open", json!({"path": s("path")}))),
"app.save" => wrap(app.run("file.save", json!({"path": s("path")}))),
"app.export" => wrap(app.run("app.exportPng", json!({"path": s("path"), "page": p.get("page"), "scale": p.get("scale")}))),
"app.quit" => {
+5
View File
@@ -977,5 +977,10 @@ mod tests {
assert!(app.run("file.open", json!({"path": "/nonexistent/x.designcraft"})).is_err());
assert!(app.ui.dialog.is_none(), "a scripted file.open doesn't raise an alert");
assert!(!app.ui.status.is_empty());
// The control channel's app.open answers with the error; no alert waits for a click.
let (req, _rx) = control::ControlRequest::new("app.open", json!({"path": "/nonexistent/x.designcraft"}));
let control::Outcome::Done(r) = control::handle(&mut app, &egui::Context::default(), &req) else { panic!("app.open answers") };
assert_eq!(r["ok"], json!(false), "{r}");
assert!(app.ui.dialog.is_none(), "a control-channel app.open doesn't raise an alert");
}
}