feat(gui): one Another assistant card, a popover for Ask your assistant, one Books menu entry

The four untested tools shared one text four times: now one card. The
copied sentence no longer pushes the page down: a popover under the
button. The Books menu's two connect entries became one that opens the
Connect page. Link::Working has no glyph (it is a drawn arc). Shape
baselines re-blessed: assist_{working,none,connected,connect_page,ask}
in light and dark.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 10:16:26 -07:00
1 parent f58191c9de
commit e34b18ec73
15 files changed
+236 -215

No files matched your search

+171 -156
View File
@@ -234,6 +234,12 @@ pub fn asking_is_offered(ctx: &egui::Context) -> bool {
.is_some_and(|c| c.serves)
}
/// Ask the window to open the Connect page (the Books menu's "Connect an
/// assistant…"; the same as clicking the link under "Ask your assistant").
pub fn open_page(ctx: &egui::Context) {
ctx.data_mut(|d| d.insert_temp(go_key(), true));
}
/// Whether "Connect an assistant" was clicked on a page this frame.
pub fn take_go(ctx: &egui::Context) -> bool {
ctx.data_mut(|d| d.remove_temp::<bool>(go_key()))
@@ -257,7 +263,6 @@ pub fn ask_button(ui: &mut Ui, what: &str) {
return;
}
let p = pal(ui.ctx());
let id = ui.id().with("ask-your-assistant");
let button = egui::Button::new(
RichText::new(format!("{} Ask your assistant", icon::CHAT_CENTERED_TEXT))
.font(theme::semibold(13.0))
@@ -273,66 +278,81 @@ pub fn ask_button(ui: &mut Ui, what: &str) {
if resp.clicked() {
ui.ctx().copy_text(sentence(&c.company, what));
let now = ui.input(|i| i.time);
ui.ctx().data_mut(|d| d.insert_temp(id, now));
ui.ctx()
.data_mut(|d| d.insert_temp(ask_said_key(), (what.to_string(), now, resp.rect)));
}
resp.widget_info(|| {
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "Ask your assistant")
});
let said_at: Option<f64> = ui.ctx().data(|d| d.get_temp(id));
let now = ui.input(|i| i.time);
if let Some(at) = said_at
&& now - at < 8.0
{
ui.ctx()
.request_repaint_after(std::time::Duration::from_millis(500));
ui.ctx()
.data_mut(|d| d.insert_temp(ask_said_key(), (what.to_string(), at)));
}
}
fn ask_said_key() -> egui::Id {
egui::Id::new("wanderbooks-ask-said")
}
/// The line under a page's title that follows a click on "Ask your
/// assistant": what was copied, and, with no assistant connected, where to
/// connect one. Drawn by the page header; nothing while it has not been
/// clicked.
/// What follows a click on "Ask your assistant": a small popover under the
/// button (so nothing on the page moves) saying what was copied and, with
/// no assistant connected, where to connect one. It goes away after a few
/// seconds, or on the next click anywhere else. Drawn by the page header;
/// nothing while the button has not been clicked.
pub fn ask_feedback(ui: &mut Ui) {
let Some(c) = ui.ctx().data(|d| d.get_temp::<AskContext>(ask_key())) else {
let ctx = ui.ctx().clone();
let Some(c) = ctx.data(|d| d.get_temp::<AskContext>(ask_key())) else {
return;
};
let said: Option<(String, f64)> = ui.ctx().data(|d| d.get_temp(ask_said_key()));
let said: Option<(String, f64, egui::Rect)> = ctx.data(|d| d.get_temp(ask_said_key()));
let now = ui.input(|i| i.time);
let Some((what, at)) = said else { return };
let Some((what, at, button)) = said else {
return;
};
let forget = || ctx.data_mut(|d| d.remove::<(String, f64, egui::Rect)>(ask_said_key()));
if now - at >= 8.0 {
ui.ctx()
.data_mut(|d| d.remove_temp::<(String, f64)>(ask_said_key()));
forget();
return;
}
let p = pal(ui.ctx());
ui.add_space(6.0);
ui.label(
RichText::new(format!(
"{} Copied: “{}” Paste it into your assistant.",
icon::CHECK,
sentence(&c.company, &what)
))
.font(theme::regular(13.0))
.color(p.muted),
);
if c.link == Link::None {
ui.horizontal(|ui| {
ui.label(
RichText::new("No assistant is connected yet.")
.font(theme::regular(13.0))
.color(p.warning),
);
if ui.link("Connect an assistant").clicked() {
ui.ctx().data_mut(|d| d.insert_temp(go_key(), true));
}
let p = pal(&ctx);
let shown = egui::Area::new(egui::Id::new("wanderbooks-ask-popover"))
.order(egui::Order::Foreground)
.pivot(egui::Align2::RIGHT_TOP)
.fixed_pos(button.right_bottom() + vec2(0.0, 6.0))
.constrain(true)
.show(&ctx, |ui| {
Frame::popup(ui.style())
.fill(p.surface)
.stroke(Stroke::new(1.0, p.border))
.show(ui, |ui| {
ui.set_max_width(380.0);
ui.label(
RichText::new(format!(
"{} Copied: “{}” Paste it into your assistant.",
icon::CHECK,
sentence(&c.company, &what)
))
.font(theme::regular(13.0))
.color(p.muted),
);
if c.link == Link::None {
ui.horizontal_wrapped(|ui| {
ui.label(
RichText::new("No assistant is connected yet.")
.font(theme::regular(13.0))
.color(p.warning),
);
if ui.link("Connect an assistant").clicked() {
ui.ctx().data_mut(|d| d.insert_temp(go_key(), true));
}
});
}
});
});
// A click anywhere else puts it away; so does the click on its link.
let rect = shown.response.rect;
let (pressed, at_pos) = ctx.input(|i| (i.pointer.any_pressed(), i.pointer.interact_pos()));
let outside = at_pos.is_some_and(|pos| !rect.contains(pos) && !button.contains(pos));
if pressed && outside {
forget();
}
ctx.request_repaint_after(std::time::Duration::from_millis(500));
}
// ---- the Connect page -------------------------------------------------------
@@ -341,45 +361,25 @@ pub fn ask_feedback(ui: &mut Ui) {
struct Tool {
/// Its name.
name: &'static str,
/// The agent the owner can connect with one button, if it can.
agent: Option<crate::owner::Agent>,
/// The words that add it to the tool by hand (before the command), if
/// the repository documents them; None says: give the program and its
/// arguments (INVARIANT 4).
add_by_hand: Option<&'static str>,
/// The agent the owner can connect with one button.
agent: crate::owner::Agent,
/// The words that add it to the tool by hand (before the command), as
/// the tool's own documentation gives them.
add_by_hand: &'static str,
}
/// The tools of "On this computer", in the order of plan 3.3.
const TOOLS: [Tool; 6] = [
/// The tools of "On this computer" that have a button of their own; every
/// other assistant shares the "Another assistant" card.
const TOOLS: [Tool; 2] = [
Tool {
name: "Claude Code",
agent: Some(crate::owner::Agent::Claude),
add_by_hand: Some("claude mcp add --scope user"),
agent: crate::owner::Agent::Claude,
add_by_hand: "claude mcp add --scope user",
},
Tool {
name: "Codex",
agent: Some(crate::owner::Agent::Codex),
add_by_hand: Some("codex mcp add"),
},
Tool {
name: "Gemini CLI",
agent: None,
add_by_hand: None,
},
Tool {
name: "Grok Build",
agent: None,
add_by_hand: None,
},
Tool {
name: "Muse Code",
agent: None,
add_by_hand: None,
},
Tool {
name: "Cursor",
agent: None,
add_by_hand: None,
agent: crate::owner::Agent::Codex,
add_by_hand: "codex mcp add",
},
];
@@ -527,9 +527,7 @@ impl State {
want = Some(w);
}
}
if TOOLS.iter().any(|t| t.agent.is_none()) {
key_row(ui, status, book, &owner, busy, &mut want);
}
another_row(ui, status, book, &owner, &commands, busy, &mut want);
if let Some((what, keep, work)) = want {
self.start(ui, jobs, what, &keep, work);
}
@@ -665,7 +663,7 @@ fn tool_row(
);
}
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if let (Some(agent), Some(owner)) = (tool.agent, owner)
if let (agent, Some(owner)) = (tool.agent, owner)
&& ui
.add_enabled(!busy, egui::Button::new(format!("Connect {}", tool.name)))
.on_hover_text(format!(
@@ -708,96 +706,113 @@ fn tool_row(
fn by_hand(ui: &mut Ui, tool: &Tool, book: &str, bridge: &str) {
let p = pal(ui.ctx());
let name = format!("wanderbooks-{book}");
match tool.add_by_hand {
Some(add) => {
let line = format!("{add} {name} -- {bridge}");
egui::CollapsingHeader::new(
RichText::new("Or do it yourself, in a terminal")
.font(theme::regular(12.5))
.color(p.muted),
)
.id_salt(("by-hand", tool.name))
.show(ui, |ui| {
ui.label(
RichText::new("Run this once:")
.font(theme::regular(12.5))
.color(p.muted),
);
command_box(ui, &line);
ui.label(
RichText::new(format!(
"Then restart {}. It reaches the books as “{name}”.",
tool.name
))
.font(theme::regular(12.5))
.color(p.muted),
);
});
}
None => {
ui.label(
RichText::new(format!(
"In {}, add a local tool (a program it runs on this computer) named “{name}”, with this command:",
tool.name
))
.font(theme::regular(13.0))
.color(p.text),
);
command_box(ui, bridge);
ui.label(
RichText::new(format!(
"Then restart {}. If it asks for the program and its arguments separately, the program is the first word and the rest are its arguments. We haven't tested {} yet.",
tool.name, tool.name
))
let line = format!("{} {name} -- {bridge}", tool.add_by_hand);
egui::CollapsingHeader::new(
RichText::new("Or do it yourself, in a terminal")
.font(theme::regular(12.5))
.color(p.muted),
)
.id_salt(("by-hand", tool.name))
.show(ui, |ui| {
ui.label(
RichText::new("Run this once:")
.font(theme::regular(12.5))
.color(p.muted),
);
}
}
);
command_box(ui, &line);
ui.label(
RichText::new(format!(
"Then restart {}. It reaches the books as “{name}”.",
tool.name
))
.font(theme::regular(12.5))
.color(p.muted),
);
});
}
/// The step the tools without a button share: the key they read, made once.
fn key_row(
/// The one card for every other assistant: the command, the key it reads
/// (made once), and the names we have not tried.
fn another_row(
ui: &mut Ui,
status: &Status,
book: &str,
owner: &Option<Arc<dyn Owner>>,
commands: &Option<Result<Commands, String>>,
busy: bool,
want: &mut Want,
) {
let p = pal(ui.ctx());
ui.add_space(2.0);
ui.label(
RichText::new(format!(
"For the others, make {}'s key first (once):",
status.company
))
.font(theme::regular(13.0))
.color(p.muted),
);
if let Some(owner) = owner
&& ui
.add_enabled(!busy, egui::Button::new("Make the key"))
.on_hover_text(
"Makes the key these books give an assistant, and keeps it on this computer",
)
.clicked()
{
let (o, b) = (owner.clone(), book.to_string());
*want = Some((
"Make the key".to_string(),
"Making the key".to_string(),
Box::new(move || {
o.make_key(&b).map(|made| {
if made {
"made, and kept on this computer.".to_string()
} else {
"it was already made.".to_string()
}
})
}),
));
}
let name = format!("wanderbooks-{book}");
Frame::new()
.fill(p.surface)
.stroke(Stroke::new(1.0, p.border))
.corner_radius(CornerRadius::same(8))
.inner_margin(Margin::symmetric(12, 10))
.show(ui, |ui| {
ui.set_width(ui.available_width());
ui.label(RichText::new("Another assistant").font(theme::semibold(14.5)));
ui.add_space(4.0);
ui.label(
RichText::new(format!(
"Any assistant that can run a local tool (a program it runs on this computer) works. Add one named “{name}”, with this command:"
))
.font(theme::regular(13.0))
.color(p.text),
);
match commands {
Some(Ok(c)) => command_box(ui, &c.bridge),
Some(Err(why)) => {
ui.label(
RichText::new(format!("The command could not be worked out: {why}"))
.font(theme::regular(12.5))
.color(p.warning),
);
}
None => {}
}
ui.add_space(2.0);
ui.label(
RichText::new(format!(
"It reads {}'s key, made once:",
status.company
))
.font(theme::regular(13.0))
.color(p.muted),
);
if let Some(owner) = owner
&& ui
.add_enabled(!busy, egui::Button::new("Make the key"))
.on_hover_text(
"Makes the key these books give an assistant, and keeps it on this computer",
)
.clicked()
{
let (o, b) = (owner.clone(), book.to_string());
*want = Some((
"Make the key".to_string(),
"Making the key".to_string(),
Box::new(move || {
o.make_key(&b).map(|made| {
if made {
"made, and kept on this computer.".to_string()
} else {
"it was already made.".to_string()
}
})
}),
));
}
ui.add_space(2.0);
ui.label(
RichText::new(
"Then restart it. We haven't tested Gemini CLI, Grok Build, Muse Code or Cursor yet.",
)
.font(theme::regular(12.5))
.color(p.muted),
);
});
ui.add_space(6.0);
}
/// Text in a box, with a Copy button.
+3 -3
View File
@@ -63,14 +63,14 @@ pub enum Link {
impl Link {
/// The shape that stands for the state: a different silhouette for
/// each, so it reads without colour (plugs apart, plugs together, a
/// spinning arc).
/// each, so it reads without colour (plugs apart, plugs together; the
/// spinning arc of Working is drawn, so it has no glyph).
pub fn glyph(self) -> Option<&'static str> {
match self {
Link::Unknown => None,
Link::None => Some(icon::PLUGS),
Link::Connected => Some(icon::PLUGS_CONNECTED),
Link::Working => Some(icon::CIRCLE_NOTCH),
Link::Working => None,
}
}
}
+11 -23
View File
@@ -8,8 +8,8 @@
//! GOAL: the owner backs up, restores, starts new books, closes the books
//! and connects an agent from the viewer, without a terminal.
//! SOURCE: plan P2 ("Viewer menu (D-19)": "Back up now", "Restore…",
//! "New books…", "Close the books", "Connect Claude Code" and
//! "Connect Codex"; "Nothing in the viewer writes a book"); D-32
//! "New books…", "Close the books" and "Connect an assistant…"; the
//! page it opens carries the two connect buttons; "Nothing in the viewer writes a book"); D-32
//! (no confinement: the viewer asks the server itself, as the
//! command line does); plan 3.9 and D-39 (the format upgrade: the
//! go-ahead asked at every open until given, with the owner
@@ -709,25 +709,13 @@ impl OwnerMenu {
};
}
ui.separator();
for agent in [Agent::Claude, Agent::Codex] {
if ui
.button(format!("{} Connect {}", icon::PLUGS_CONNECTED, agent.label()))
.on_hover_text(format!(
"Let {} reach these books (it keeps their token in a file in the data root)",
agent.label()
))
.clicked()
{
let (o, b) = (owner.clone(), book.clone());
start = Some((
format!("Connect {}", agent.label()),
Effect::Changes(match agent {
Agent::Claude => "Connecting Claude Code to these books",
Agent::Codex => "Connecting Codex to these books",
}),
Box::new(move || o.connect(agent, &b)),
));
}
if ui
.button(format!("{} Connect an assistant…", icon::PLUGS_CONNECTED))
.on_hover_text("Open the page that connects Claude Code, Codex or another assistant to these books")
.clicked()
{
crate::connect::open_page(ui.ctx());
ui.close();
}
if let Some(upgrade) = &books.format_upgrade {
ui.separator();
@@ -768,7 +756,7 @@ impl OwnerMenu {
ui.separator();
if ui
.button(format!("{} Close the books", icon::POWER))
.on_hover_text("Close the books now: agents' sessions and every other holder let go")
.on_hover_text("Close the books now: assistants' sessions and every other holder let go")
.clicked()
{
self.dialog = Dialog::Close;
@@ -862,7 +850,7 @@ impl OwnerMenu {
Dialog::Close => {
egui::Modal::new(self.scope.unwrap_or(egui::Id::NULL).with("owner-close")).show(ctx, |ui| {
ui.heading("Close the books?");
ui.label("Agents' sessions and everything else holding them let go. They open again when something holds them.");
ui.label("Assistants' sessions and everything else holding them let go. They open again when something holds them.");
ui.horizontal(|ui| {
if ui.button("Close the books").clicked() {
let o = owner.clone();
+24 -10
View File
@@ -487,6 +487,7 @@ fn ask_your_assistant_copies_one_ready_sentence() {
refresh(&mut h);
h.state_mut().goto(Route::Transactions);
h.run_steps(3);
let below = h.get_by_label_contains("recorded, newest first").rect();
h.get_by_role_and_label(Role::Button, "Ask your assistant")
.click();
h.step();
@@ -495,6 +496,11 @@ fn ask_your_assistant_copies_one_ready_sentence() {
["In my Wanderbooks books for Wanderland Labs, please record a new transaction."]
);
h.run_steps(2);
assert_eq!(
h.get_by_label_contains("recorded, newest first").rect(),
below,
"the feedback is a popover: the page does not move"
);
// With none connected it says so, and where to connect one.
assert!(
h.query_by_label_contains("No assistant is connected yet.")
@@ -568,14 +574,7 @@ fn the_top_bar_state_opens_the_connect_page_which_lists_and_revokes() {
h.run_steps(3);
assert_eq!(h.state().route(), &Route::Connect);
// A row per tool, and the keys with who is on each.
for tool in [
"Claude Code",
"Codex",
"Gemini CLI",
"Grok Build",
"Muse Code",
"Cursor",
] {
for tool in ["Claude Code", "Codex", "Another assistant"] {
assert!(
h.query_all_by_label(tool).next().is_some(),
"a row for {tool}"
@@ -597,8 +596,8 @@ fn the_top_bar_state_opens_the_connect_page_which_lists_and_revokes() {
assert_eq!(
h.query_all_by_label("/opt/wanderbooks mcp --book alpha")
.count(),
4,
"the program and its arguments, for each tool that has no button"
1,
"the program and its arguments, once, on the card for any other assistant"
);
h.get_all_by_label("Or do it yourself, in a terminal")
.next()
@@ -671,6 +670,16 @@ fn the_connect_buttons_do_what_connect_does() {
h.query_by_label_contains("Codex reaches the books.")
.is_some()
);
until(&mut h, "the page is idle", |a| {
!a.views()[0].connect_state().busy()
});
h.run_steps(2);
h.get_by_role_and_label(Role::Button, "Connect Claude Code")
.click();
h.run_steps(2);
wait_for("connect ran for Claude Code", || {
owner.said().contains(&"connect claude alpha".to_string())
});
h.get_by_role_and_label(Role::Button, "Make the key")
.click();
h.run_steps(2);
@@ -1016,5 +1025,10 @@ fn pictures() {
// A short window, as the owner's laptop has.
let (_w2, mut small) = three_states(dark, 0, egui::vec2(1479.0, 519.0));
save(&mut small, &format!("8-short-window-{mode}"));
// The Connect page tall enough to show "Another assistant".
let (_w3, mut tall) = three_states(dark, 1, egui::vec2(1440.0, 1300.0));
tall.state_mut().goto(Route::Connect);
tall.run_steps(4);
save(&mut tall, &format!("9-connect-another-{mode}"));
}
}
+17 -13
View File
@@ -181,11 +181,15 @@ fn the_books_menu_hands_each_action_to_the_owner_and_writes_nothing() {
assert_eq!(f.asked.lock().unwrap()[start], "back up acme");
assert!(h.query_by_label_contains("is its disk connected").is_some());
// Connect Claude Code.
// Connect an assistant…: opens the Connect page, asks the owner nothing
// (the page's own buttons carry the connecting: tests/assistants.rs).
open_menu(&mut h);
h.get_by_label_contains("Connect Claude Code").click();
settle(&mut h, &f, start + 2);
assert_eq!(f.asked.lock().unwrap()[start + 1], "connect Claude acme");
h.get_by_label_contains("Connect an assistant…").click();
h.run_steps(4);
assert_eq!(h.state().route(), &Route::Connect);
assert_eq!(f.asked.lock().unwrap().len(), start + 1);
assert!(h.query_by_label_contains("Connect Claude Code").is_some());
assert!(h.query_by_label_contains("Connect Codex").is_some());
// New books: asked for, then made.
let page_fields = h
@@ -205,8 +209,8 @@ fn the_books_menu_hands_each_action_to_the_owner_and_writes_nothing() {
.type_text("beta");
h.run_steps(2);
h.get_by_label("Make them").click();
settle(&mut h, &f, start + 3);
assert_eq!(f.asked.lock().unwrap()[start + 2], "new beta USD");
settle(&mut h, &f, start + 2);
assert_eq!(f.asked.lock().unwrap()[start + 1], "new beta USD");
// Restore: previewed (the backup checked), then done for that plan.
open_menu(&mut h);
@@ -227,9 +231,9 @@ fn the_books_menu_hands_each_action_to_the_owner_and_writes_nothing() {
"not before it is checked"
);
h.get_by_label("Check it").click();
settle(&mut h, &f, start + 4);
settle(&mut h, &f, start + 3);
assert_eq!(
f.asked.lock().unwrap()[start + 3],
f.asked.lock().unwrap()[start + 2],
"plan /media/disk/acme.git None false"
);
assert!(
@@ -237,9 +241,9 @@ fn the_books_menu_hands_each_action_to_the_owner_and_writes_nothing() {
.is_some()
);
h.get_by_label("Restore it").click();
settle(&mut h, &f, start + 5);
settle(&mut h, &f, start + 4);
assert_eq!(
f.asked.lock().unwrap()[start + 4],
f.asked.lock().unwrap()[start + 3],
"restore /media/disk/acme.git acme 7"
);
@@ -249,13 +253,13 @@ fn the_books_menu_hands_each_action_to_the_owner_and_writes_nothing() {
h.run_steps(3);
h.get_by_label("Cancel").click();
h.run_steps(3);
assert_eq!(f.asked.lock().unwrap().len(), start + 5);
assert_eq!(f.asked.lock().unwrap().len(), start + 4);
open_menu(&mut h);
h.get_by_label_contains("Close the books").click();
h.run_steps(3);
h.get_by_label("Close the books").click();
settle(&mut h, &f, start + 6);
assert_eq!(f.asked.lock().unwrap()[start + 5], "close");
settle(&mut h, &f, start + 5);
assert_eq!(f.asked.lock().unwrap()[start + 4], "close");
// The viewer wrote nothing of the books.
drop(h);
@@ -1 +1 @@
554a45de5050b79d
d4672239e98f338e
@@ -1 +1 @@
fffc3e5adaa00db0
47a1f842b40cdf15
@@ -1 +1 @@
e8b3ce383a13c776
2abd53e6457106f8
@@ -1 +1 @@
3271d551e50db504
b990ac9586df492a
@@ -1 +1 @@
9530691dfcdedf6b
6642f21a3644e1f4
@@ -1 +1 @@
5f60b24231b7a370
e425621386ec002f
@@ -1 +1 @@
9bc7803073cd0434
79ee857f24de8131
@@ -1 +1 @@
fea19947b5c1a09e
d236cd60218a8061
@@ -1 +1 @@
334251b6f2666663
8d565039aff8c64c
@@ -1 +1 @@
31ed42032e1844c9
7014f0d713dbc1d8