feat(gui): the person is asked when a web assistant wants to connect (P15 B1, D-83)

The window shows a card, over any page of the company and on the Connect page,
that says in plain words who is asking (the product by where it is sent back
to, never by what it calls itself), where it will be sent back to, the
internet address it asked from and what it will be able to do: read and draft,
and post only if the box is ticked. Allow and Don't allow answer through the
owner and the admin socket (ledger-host AppServer::web_decide); nothing on the
web page approves. Each web connection shows what it may do, with a button to
let it post or stop. Revoke stays the one row of 'Who can reach these books'.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 11:39:38 -07:00
1 parent 4c36c1f020
commit c9b6614688
7 files changed
+688 -12

No files matched your search

+47 -1
View File
@@ -149,7 +149,53 @@ impl ledger_gui::owner::Owner for ViewerOwner {
created: t.created,
})
.collect();
Ok(Roster { assistants, tokens })
// The web assistants waiting, and those allowed: nothing when the
// remote door was never turned on.
let web = self
.server
.web_roster(std::time::Duration::from_secs(3))
.unwrap_or_default();
let web_pending = web
.pending
.into_iter()
.map(|p| ledger_gui::owner::WebRequest {
id: p.id,
book: p.book,
client_name: p.client_name,
recognised: p.product.is_some(),
redirect: p.redirect,
redirect_host: p.redirect_host,
from: p.from,
wants_post: p.wants_post,
expires_in_secs: p.expires_in_secs,
})
.collect();
let web_approvals = web
.approvals
.into_iter()
.map(|a| ledger_gui::owner::WebApproval {
id: a.id,
book: a.book,
label: a.label,
token_id: a.token_id,
may_post: a.may_post,
last_used: a.last_used,
})
.collect();
Ok(Roster {
assistants,
tokens,
web_pending,
web_approvals,
})
}
fn web_decide(&self, id: &str, approve: bool, post: bool) -> Result<String, String> {
self.server.web_decide(id, approve, post)
}
fn web_set_post(&self, approval: &str, post: bool) -> Result<String, String> {
self.server.web_set_post(approval, post)
}
fn serve_revoke(&self, book: &str, name: &str, id: &str) -> Result<String, String> {
+7
View File
@@ -574,6 +574,13 @@ impl CompanyView {
if crate::connect::take_go(ui.ctx()) {
self.nav.go(Route::Connect);
}
// A web assistant asking to connect is asked about over
// whatever page this is (the Connect page has its own card).
if route != Route::Connect {
let spawner = self.jobs.spawner();
self.connect
.web_prompt(ui, &self.assist, &self.owner.clone(), &spawner);
}
if let Some(to) = self.palette.show(ui.ctx(), &books) {
self.nav.go(to);
}
+241 -8
View File
@@ -44,8 +44,16 @@
//! off the UI thread; what is shown while it is not known is "not
//! known", never a guess.
//! 7. The web half of the page (the switch, the address, the steps for
//! Claude and ChatGPT) is unit B3's: `State::web_section` is its
//! place, and it draws nothing until then.
//! Claude and ChatGPT) is unit B3's. Unit B1's part of it is here: a
//! web assistant that asks to connect is shown to the person, in
//! words, as a card that says who is asking, where it is sent back
//! to, the address it asked from and what it will be able to do, with
//! Allow and Don't allow; it appears over any page of the company
//! (`State::web_prompt`) and on this page (`State::web_section`).
//! Nothing on the web page can approve: only these buttons do, through
//! the owner. What the assistant calls itself is shown in quotes and
//! is never what names the product. Posting is off unless the person
//! ticks it, per assistant, and can be turned on or off later.
//! ```
use crate::connections::{Connection, Link, Status, describe, program_name};
@@ -400,6 +408,9 @@ pub struct State {
confirm: Option<String>,
/// A revoke ended: the state is read again.
refresh: bool,
/// The waiting web assistants the person has ticked "let it post
/// entries too" for.
post_asked: std::collections::BTreeSet<String>,
}
/// The two lines an assistant set up by hand needs.
@@ -433,10 +444,228 @@ impl State {
self.confirm.as_deref()
}
/// The web half of the page: "Allow web assistants", the address with
/// Copy, and the steps for Claude and ChatGPT. Unit B3 draws it here;
/// nothing until then (INVARIANT 7).
fn web_section(&mut self, _ui: &mut Ui, _status: &Status) {}
/// What the person is asked of a web assistant, and what they may do
/// about the web connections already allowed (INVARIANT 7). Unit B3
/// draws the switch, the address and the steps above this.
fn web_section(
&mut self,
ui: &mut Ui,
status: &Status,
owner: &Option<Arc<dyn Owner>>,
jobs: &crate::jobs::Spawner,
) {
if status.web_pending.is_empty() && status.web_approvals.is_empty() {
return;
}
let p = pal(ui.ctx());
ui.add_space(24.0);
section(ui, "Assistants on the web");
let mut want: Want = None;
for request in &status.web_pending {
if let Some(w) = self.pending_card(ui, status, request, owner) {
want = Some(w);
}
ui.add_space(6.0);
}
for a in &status.web_approvals {
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.horizontal(|ui| {
ui.vertical(|ui| {
ui.label(RichText::new(&a.label).font(theme::semibold(13.5)));
ui.label(
RichText::new(if a.may_post {
"Can read, draft and post entries."
} else {
"Can read and draft entries. It can't post them."
})
.font(theme::regular(12.5))
.color(p.muted),
);
});
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if owner.is_none() || self.job.is_some() {
return;
}
let (label, to) = if a.may_post {
("Stop letting it post", false)
} else {
("Let it post entries", true)
};
if ui.button(label).clicked() {
let (o, id) = (owner.clone(), a.id.clone());
if let Some(o) = o {
want = Some((
format!("Posting for {}", a.label),
"Changing what an assistant may do".to_string(),
Box::new(move || o.web_set_post(&id, to)),
));
}
}
});
});
});
ui.add_space(6.0);
}
if let Some((what, keep, work)) = want {
self.start(ui, jobs, what, &keep, work);
}
}
/// One assistant asking to connect: who, from where, what it will be
/// able to do, and Allow and Don't allow. The answer to ask for, if
/// the person gave one.
fn pending_card(
&mut self,
ui: &mut Ui,
status: &Status,
request: &crate::owner::WebRequest,
owner: &Option<Arc<dyn Owner>>,
) -> Want {
let can_answer = owner.is_some();
let p = pal(ui.ctx());
let mut answer: Option<(bool, bool)> = None;
Frame::new()
.fill(p.surface)
.stroke(Stroke::new(1.5, p.accent))
.corner_radius(CornerRadius::same(8))
.inner_margin(Margin::symmetric(14, 12))
.show(ui, |ui| {
ui.set_width(ui.available_width());
ui.label(
RichText::new(format!(
"{} wants to connect to {}. Allow?",
request.client_name, status.company
))
.font(theme::semibold(15.0)),
);
ui.add_space(4.0);
if request.recognised {
ui.label(
RichText::new(
"Only allow it if you just asked this assistant to connect.",
)
.font(theme::regular(13.0))
.color(p.muted),
);
} else {
ui.label(
RichText::new(
"Wanderbooks doesn't recognise this assistant: it only gave this name for itself. Don't allow it unless you just set it up yourself.",
)
.font(theme::regular(13.0))
.color(p.warning),
);
}
ui.label(
RichText::new(format!(
"After you answer, it is sent back to {}. The request came from the internet address {}.",
request.redirect_host, request.from
))
.font(theme::regular(12.5))
.color(p.muted),
);
ui.label(
RichText::new(
"If you allow it, it can read these books and draft entries. It can't post entries unless you tick the box below.",
)
.font(theme::regular(12.5))
.color(p.muted),
);
let mut post = self.post_asked.contains(&request.id);
if ui
.checkbox(
&mut post,
if request.wants_post {
"Also let it post entries (it asked to)"
} else {
"Also let it post entries"
},
)
.changed()
{
if post {
self.post_asked.insert(request.id.clone());
} else {
self.post_asked.remove(&request.id);
}
}
ui.add_space(6.0);
ui.horizontal(|ui| {
let enabled = can_answer && self.job.is_none();
if ui.add_enabled(enabled, egui::Button::new("Allow")).clicked() {
answer = Some((true, post));
}
if ui
.add_enabled(enabled, egui::Button::new("Don't allow"))
.clicked()
{
answer = Some((false, false));
}
ui.label(
RichText::new(format!(
"Waiting {} more minute(s)",
request.expires_in_secs.div_ceil(60)
))
.font(theme::regular(12.0))
.color(p.muted),
);
});
});
let (approve, post) = answer?;
self.post_asked.remove(&request.id);
let owner = owner.clone()?;
let id = request.id.clone();
let what = if approve {
format!("Allow {}", request.client_name)
} else {
format!("Don't allow {}", request.client_name)
};
Some((
what,
"Answering an assistant".to_string(),
Box::new(move || owner.web_decide(&id, approve, post)),
))
}
/// The question over any page of the company: a web assistant asking
/// to connect is not something to find by looking for it (INVARIANT 7).
/// Not drawn on the Connect page, which has the same card.
pub fn web_prompt(
&mut self,
ui: &Ui,
status: &Status,
owner: &Option<Arc<dyn Owner>>,
jobs: &crate::jobs::Spawner,
) {
self.collect();
if status.web_pending.is_empty() {
return;
}
ui.ctx()
.request_repaint_after(std::time::Duration::from_millis(500));
let mut want: Want = None;
egui::Window::new("An assistant wants to connect")
.collapsible(false)
.resizable(false)
.anchor(egui::Align2::CENTER_CENTER, vec2(0.0, 0.0))
.show(ui.ctx(), |win| {
for request in &status.web_pending {
if let Some(w) = self.pending_card(win, status, request, owner) {
want = Some(w);
}
win.add_space(6.0);
}
});
if let Some((what, keep, work)) = want {
self.start(ui, jobs, what, &keep, work);
}
}
fn collect(&mut self) {
if let Some((what, rx)) = &self.job
@@ -444,7 +673,11 @@ impl State {
{
// Whatever came of it (a key already gone, a file left behind),
// the list is read again.
if what.starts_with("Revoke") {
if what.starts_with("Revoke")
|| what.starts_with("Allow")
|| what.starts_with("Don't allow")
|| what.starts_with("Posting")
{
self.refresh = true;
}
self.done = Some((what.clone(), result));
@@ -558,7 +791,7 @@ impl State {
),
};
}
self.web_section(ui, status);
self.web_section(ui, status, &owner, jobs);
ui.add_space(24.0);
self.connections(ui, status, book, &owner, jobs);
});
+17 -1
View File
@@ -34,7 +34,7 @@
//! 5. Nothing here holds a token's text: the server never sends one.
//! ```
use crate::owner::{Assistant, LastCall, Owner, Roster, TokenRow};
use crate::owner::{Assistant, LastCall, Owner, Roster, TokenRow, WebApproval, WebRequest};
use chrono::{DateTime, Utc};
use egui_phosphor::regular as icon;
use std::sync::{Arc, Mutex, MutexGuard};
@@ -94,6 +94,10 @@ pub struct Status {
pub assistants: Vec<Assistant>,
/// The tokens of this company: who may connect.
pub tokens: Vec<TokenRow>,
/// Web assistants waiting for the person to allow them.
pub web_pending: Vec<WebRequest>,
/// The web connections the person allowed.
pub web_approvals: Vec<WebApproval>,
/// "Now", for "10 seconds ago" (fixed in tests and screenshots).
pub now: DateTime<Utc>,
}
@@ -108,6 +112,8 @@ impl Status {
link: Link::Unknown,
assistants: Vec::new(),
tokens: Vec::new(),
web_pending: Vec::new(),
web_approvals: Vec::new(),
now: Utc::now(),
}
}
@@ -561,6 +567,16 @@ impl Connections {
.into_iter()
.filter(|t| t.book == book)
.collect();
status.web_pending = roster
.web_pending
.into_iter()
.filter(|r| r.book == book)
.collect();
status.web_approvals = roster
.web_approvals
.into_iter()
.filter(|a| a.book == book)
.collect();
status.link = if status.assistants.is_empty() {
Link::None
} else if status.assistants.iter().any(|a| a.running > 0) {
+58
View File
@@ -203,6 +203,50 @@ pub struct TokenRow {
pub created: String,
}
/// A web assistant waiting for the person to allow it (plan P15 D-83): who
/// is asking, as the server saw it. What it calls itself is its own word,
/// cleaned and never trusted; where it is sent back to and the address it
/// asked from are what the server saw.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WebRequest {
/// What an answer names.
pub id: String,
/// The company it asks to reach.
pub book: String,
/// The product recognised by where it is sent back to ("Claude on
/// the web"), else what it calls itself.
pub client_name: String,
/// Whether the product is one Wanderbooks recognises.
pub recognised: bool,
/// The address it is sent back to, in full.
pub redirect: String,
/// That address's host.
pub redirect_host: String,
/// The caller's address, as the relay said it.
pub from: String,
/// It asked to post entries too.
pub wants_post: bool,
/// Seconds until it is turned away unanswered.
pub expires_in_secs: u64,
}
/// A web connection the person allowed.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WebApproval {
/// Its id.
pub id: String,
/// The company.
pub book: String,
/// What it is called.
pub label: String,
/// The key that carries it: what "Who can reach these books" revokes.
pub token_id: String,
/// It may post entries (else read and draft).
pub may_post: bool,
/// When it last did anything (unix seconds).
pub last_used: Option<i64>,
}
/// Who is connected and who may connect, across the open companies.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Roster {
@@ -210,6 +254,10 @@ pub struct Roster {
pub assistants: Vec<Assistant>,
/// Every live token.
pub tokens: Vec<TokenRow>,
/// Web assistants waiting for the person.
pub web_pending: Vec<WebRequest>,
/// Web connections the person allowed.
pub web_approvals: Vec<WebApproval>,
}
/// The owner's actions, done by the program the viewer runs in (ledger-cli
@@ -272,6 +320,16 @@ pub trait Owner: Send + Sync {
fn serve_revoke(&self, _book: &str, _name: &str, _id: &str) -> Result<String, String> {
Err("not here".into())
}
/// The person's answer to a web assistant waiting to be allowed:
/// `approve` it or refuse it; `post` lets it post entries too, not
/// only read and draft. `Ok` says what was done, in words. Blocks.
fn web_decide(&self, _id: &str, _approve: bool, _post: bool) -> Result<String, String> {
Err("not here".into())
}
/// Let a web connection post entries, or take that away. Blocks.
fn web_set_post(&self, _approval: &str, _post: bool) -> Result<String, String> {
Err("not here".into())
}
/// This program run with `words`, as a line to type in a terminal (the
/// program's own path, the words, the data root if one was named): what
/// the Connect page shows for an assistant it has no button for.
+230 -2
View File
@@ -42,7 +42,9 @@ use ledger_core::{AccountType, Currency};
use ledger_gui::connections::Link;
use ledger_gui::data::Source;
use ledger_gui::nav::Route;
use ledger_gui::owner::{Agent, Assistant, LastCall, Owner, RestorePlan, Roster, TokenRow};
use ledger_gui::owner::{
Agent, Assistant, LastCall, Owner, RestorePlan, Roster, TokenRow, WebApproval, WebRequest,
};
use ledger_gui::{App, Start};
use ledger_store::root::{BookId, Root};
use std::collections::HashMap;
@@ -196,6 +198,44 @@ impl Owner for Fake {
}
Ok(format!("Ended {name:?}'s access to {book}."))
}
fn web_decide(&self, id: &str, approve: bool, post: bool) -> Result<String, String> {
self.note(format!("web_decide {id} {approve} {post}"));
// As the server does: it is no longer waiting, and an allowed one
// is a connection.
if let Some(Ok(r)) = self.roster.lock().unwrap().as_mut() {
let gone: Vec<_> = r
.web_pending
.iter()
.filter(|p| p.id == id)
.cloned()
.collect();
r.web_pending.retain(|p| p.id != id);
if approve {
for p in gone {
r.web_approvals.push(WebApproval {
id: format!("apr_{id}"),
book: p.book,
label: p.client_name,
token_id: "tok_1".into(),
may_post: post,
last_used: None,
});
}
}
}
Ok("done".into())
}
fn web_set_post(&self, approval: &str, post: bool) -> Result<String, String> {
self.note(format!("web_set_post {approval} {post}"));
if let Some(Ok(r)) = self.roster.lock().unwrap().as_mut() {
for a in &mut r.web_approvals {
if a.id == approval {
a.may_post = post;
}
}
}
Ok("done".into())
}
fn command_line(&self, words: &[&str]) -> Result<String, String> {
Ok(format!("/opt/wanderbooks {}", words.join(" ")))
}
@@ -257,7 +297,11 @@ fn token(book: &str, name: &str) -> TokenRow {
}
fn roster(assistants: Vec<Assistant>, tokens: Vec<TokenRow>) -> Result<Roster, String> {
Ok(Roster { assistants, tokens })
Ok(Roster {
assistants,
tokens,
..Roster::default()
})
}
/// The app over `ids` as tabs (the first in front), served by `owner`.
@@ -1033,3 +1077,187 @@ fn pictures() {
save(&mut tall, &format!("9-connect-another-{mode}"));
}
}
// ---- 7: a web assistant asks to connect (plan P15 D-83, unit B1) --------------
fn asking(id: &str, name: &str, recognised: bool) -> WebRequest {
WebRequest {
id: id.into(),
book: "alpha".into(),
client_name: name.into(),
recognised,
redirect: "https://claude.ai/api/mcp/auth_callback".into(),
redirect_host: "claude.ai".into(),
from: "203.0.113.9".into(),
wants_post: false,
expires_in_secs: 240,
}
}
fn with_pending(owner: &Fake, pending: Vec<WebRequest>, approvals: Vec<WebApproval>) {
owner.answer(Ok(Roster {
web_pending: pending,
web_approvals: approvals,
..Roster::default()
}));
}
#[test]
fn a_web_assistant_asking_is_put_to_the_person_over_any_page_in_plain_words() {
let w = World::new(&[("alpha", "Wanderland Labs")]);
let owner = Fake::new();
with_pending(
&owner,
vec![asking("p_1", "Claude on the web", true)],
vec![],
);
let mut h = start(&w, &["alpha"], &owner);
refresh(&mut h);
// On the company's own page, not the Connect page.
assert_ne!(h.state().route(), &Route::Connect);
assert!(
h.query_by_label_contains("Claude on the web wants to connect to Wanderland Labs. Allow?")
.is_some()
);
// Who, where it goes, from where: in words, nothing about OAuth.
assert!(
h.query_by_label_contains("sent back to claude.ai")
.is_some()
);
assert!(h.query_by_label_contains("203.0.113.9").is_some());
assert!(
h.query_by_label_contains("can't post entries unless you tick")
.is_some()
);
for word in ["OAuth", "token", "MCP"] {
assert!(
h.query_by_label_contains(word).is_none(),
"{word} is not a word for the person"
);
}
// Nothing is decided by looking at it.
assert!(!owner.said().iter().any(|s| s.starts_with("web_decide")));
h.get_by_role_and_label(Role::Button, "Allow").click();
h.run_steps(2);
wait_for("the answer was given", || {
owner
.said()
.contains(&"web_decide p_1 true false".to_string())
});
// Posting stayed off. The question goes away once the server stops
// listing it.
refresh(&mut h);
assert!(h.query_by_label_contains("wants to connect").is_none());
drop(h);
}
#[test]
fn refusing_and_allowing_with_posting_are_their_own_answers() {
let w = World::new(&[("alpha", "Wanderland Labs")]);
let owner = Fake::new();
with_pending(
&owner,
vec![asking("p_7", "Someone's assistant", false)],
vec![],
);
let mut h = start(&w, &["alpha"], &owner);
refresh(&mut h);
// A product that is not recognised is said not to be.
assert!(
h.query_by_label_contains("doesn't recognise this assistant")
.is_some()
);
h.get_by_role_and_label(Role::Button, "Don't allow").click();
h.run_steps(2);
wait_for("the refusal was given", || {
owner
.said()
.contains(&"web_decide p_7 false false".to_string())
});
refresh(&mut h);
assert!(h.query_by_label_contains("wants to connect").is_none());
// Another asks; this time posting is ticked, then allowed.
with_pending(
&owner,
vec![asking("p_8", "Claude on the web", true)],
vec![],
);
refresh(&mut h);
h.get_by_label("Also let it post entries").click();
h.run_steps(2);
h.get_by_role_and_label(Role::Button, "Allow").click();
h.run_steps(2);
wait_for("the answer with posting was given", || {
owner
.said()
.contains(&"web_decide p_8 true true".to_string())
});
drop(h);
}
#[test]
fn a_request_that_ran_out_goes_away_and_posting_is_turned_on_and_off_on_the_connect_page() {
let w = World::new(&[("alpha", "Wanderland Labs")]);
let owner = Fake::new();
with_pending(
&owner,
vec![asking("p_2", "Claude on the web", true)],
vec![],
);
let mut h = start(&w, &["alpha"], &owner);
refresh(&mut h);
assert!(
h.query_all_by_label_contains("wants to connect")
.next()
.is_some()
);
// The server turned it away unanswered: it is not listed any more, and
// the window never keeps what the server has dropped.
with_pending(&owner, vec![], vec![]);
refresh(&mut h);
assert!(h.query_by_label_contains("wants to connect").is_none());
// A connection that was allowed shows on the Connect page, with what
// it may do, and the person raises and lowers it.
with_pending(
&owner,
vec![],
vec![WebApproval {
id: "apr_1".into(),
book: "alpha".into(),
label: "Claude on the web".into(),
token_id: "tok_1".into(),
may_post: false,
last_used: None,
}],
);
refresh(&mut h);
h.state_mut().view_mut(0).unwrap().goto(Route::Connect);
h.run_steps(3);
assert!(h.query_by_label_contains("Assistants on the web").is_some());
assert!(
h.query_by_label_contains("Can read and draft entries. It can't post them.")
.is_some()
);
h.get_by_role_and_label(Role::Button, "Let it post entries")
.click();
h.run_steps(2);
wait_for("posting was turned on", || {
owner
.said()
.contains(&"web_set_post apr_1 true".to_string())
});
refresh(&mut h);
assert!(
h.query_by_label_contains("Can read, draft and post entries.")
.is_some()
);
h.get_by_role_and_label(Role::Button, "Stop letting it post")
.click();
h.run_steps(2);
wait_for("posting was turned off", || {
owner
.said()
.contains(&"web_set_post apr_1 false".to_string())
});
drop(h);
}
+88
View File
@@ -154,6 +154,16 @@ pub struct Roster {
pub tokens: Vec<admin::TokenInfo>,
}
/// The web assistants waiting to be allowed, and the web connections that
/// are (plan P15 B1): what the window's "Allow?" shows.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct WebRoster {
/// Assistants waiting for the person.
pub pending: Vec<admin::PendingInfo>,
/// Connections the person allowed.
pub approvals: Vec<admin::ApprovalInfo>,
}
/// The books server, a child process of this one.
pub struct AppServer {
run: PathBuf,
@@ -419,6 +429,69 @@ impl AppServer {
Ok(Roster { sessions, tokens })
}
/// The web assistants waiting for the person, and the web connections
/// allowed: two quick requests, an `Err` while the server is starting or
/// gone. A server whose remote door was never turned on answers both
/// with nothing.
pub fn web_roster(&self, wait: Duration) -> Result<WebRoster, String> {
if !self.is_ready() {
return Err(match self.exited() {
Some(why) => why,
None => "the books server is still starting".into(),
});
}
let pending = match self.ask(Request::RemotePending, Some(wait))? {
Response::RemotePending(p) => p,
Response::Refused(why) => return Err(why),
other => return Err(format!("the books server answered oddly: {other:?}")),
};
let approvals = match self.ask(Request::RemoteApprovals { book: None }, Some(wait))? {
Response::RemoteApprovals(a) => a,
Response::Refused(why) => return Err(why),
other => return Err(format!("the books server answered oddly: {other:?}")),
};
Ok(WebRoster { pending, approvals })
}
/// The person's answer to one waiting assistant: `Ok` says what was
/// done, in words. `post` lets it post entries too, not only read and
/// draft.
pub fn web_decide(&self, id: &str, approve: bool, post: bool) -> Result<String, String> {
self.wait_ready(READY_WAIT)?;
match self.ask(
Request::RemoteDecide {
id: id.into(),
approve,
post,
},
Some(Duration::from_secs(30)),
)? {
Response::RemoteDecided { said, .. } => Ok(said),
Response::Refused(why) => Err(why),
other => Err(format!("the books server answered oddly: {other:?}")),
}
}
/// Raise a web connection to posting, or lower it.
pub fn web_set_post(&self, approval: &str, post: bool) -> Result<String, String> {
self.wait_ready(READY_WAIT)?;
match self.ask(
Request::RemoteSetPost {
approval: approval.into(),
post,
},
Some(Duration::from_secs(30)),
)? {
Response::RemoteApprovals(_) => Ok(if post {
"It can post entries now.".into()
} else {
"It can read and draft, but not post.".into()
}),
Response::Refused(why) => Err(why),
other => Err(format!("the books server answered oddly: {other:?}")),
}
}
/// End the key `id`, named `name`, of the company `book`, as
/// `wanderbooks token revoke` does (INVARIANT 12): the server ends that
/// key and the sessions it opened, and the token file's copy is
@@ -723,6 +796,21 @@ impl AppHost {
self.running()?.revoke_token(book, name, id)
}
/// The web assistants waiting, and the web connections allowed.
pub fn web_roster(&self, wait: Duration) -> Result<WebRoster, String> {
self.running()?.web_roster(wait)
}
/// The person's answer to a waiting assistant.
pub fn web_decide(&self, id: &str, approve: bool, post: bool) -> Result<String, String> {
self.running()?.web_decide(id, approve, post)
}
/// Raise a web connection to posting, or lower it.
pub fn web_set_post(&self, approval: &str, post: bool) -> Result<String, String> {
self.running()?.web_set_post(approval, post)
}
/// The format upgrade of the company `id` (INVARIANT 10).
pub fn upgrade_format(&self, id: &str, passphrase: &str) -> Result<Vec<String>, String> {
match self.running() {