feat(gui): the notice for a host that holds the books has a button that closes it
Plan P15 unit A5, fix round. When an older build's detached host (or `wanderbooks serve`) holds the books, the app's start is refused, and the notice said to run `wanderbooks close`. A packaged Mac or Windows install may have no command line on the path. The notice now says what will happen, and carries a "Close it" button that asks the host to close the books and waits until it has (`commands::close_the_host`, what `wanderbooks close` does, over the unchanged lease protocol, which an older host speaks), then starts the app's own server and takes the notice away. The line to type stays in the words as the fallback. A close that fails says why and offers the button again; a start refused for any other reason offers none. The `Owner` trait gets two methods with default bodies (`serve_host_holds`, `serve_close_host`), so existing implementations, test mocks included, are untouched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6164d0fa68
commit
c47144a401
6 files changed
+388
-1
No files matched your search
@@ -535,12 +535,20 @@ impl App {
|
||||
self.notices.extend(self.serving.take_notices());
|
||||
let starting = self.serving.is_starting();
|
||||
let down = self.serving.is_down();
|
||||
// The refusal by a host is over once the start is on its way again
|
||||
// (the host was closed): its words go, whether or not they were
|
||||
// dismissed.
|
||||
if !down {
|
||||
self.notices.retain(|n| n != crate::serving::HOST_HOLDS);
|
||||
}
|
||||
if self.notices.is_empty() && !starting && !down {
|
||||
return;
|
||||
}
|
||||
let p = pal(ui.ctx());
|
||||
let mut dismiss = None;
|
||||
let mut retry = false;
|
||||
let mut close_host = false;
|
||||
let host_blocks = self.serving.host_blocks();
|
||||
egui::Panel::top("server_notices")
|
||||
.resizable(false)
|
||||
.frame(
|
||||
@@ -563,6 +571,9 @@ impl App {
|
||||
for (i, words) in self.notices.iter().enumerate() {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(RichText::new(words).color(p.text));
|
||||
if host_blocks && ui.button("Close it").clicked() {
|
||||
close_host = true;
|
||||
}
|
||||
if down && ui.button("Try again").clicked() {
|
||||
retry = true;
|
||||
}
|
||||
@@ -578,6 +589,9 @@ impl App {
|
||||
if retry {
|
||||
self.serving.retry();
|
||||
}
|
||||
if close_host {
|
||||
self.serving.close_host();
|
||||
}
|
||||
if let Some(i) = dismiss {
|
||||
self.notices.remove(i);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user