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