feat(host,gui): the window can ask the books server who is connected, and end a token

Unit A4 of plan P15 needs the window to read who is connected to each
open company and to end a token. Both go through admin requests the
server already answers (Sessions, TokenList, TokenRevoke): the window's
server handle gains a quick roster (an Err in words while the server is
starting, gone or slow; never a wait) and a revoke that does what
`wanderbooks token revoke` does, including removing the token file's
copy. The command that reaches a company's books is now made in one
place (`bridge_serve_args`) for `connect` and for the Connect page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 09:28:50 -07:00
1 parent 4c474ee1d9
commit 016f1b2afc
4 files changed
+260 -20

No files matched your search

+43
View File
@@ -116,6 +116,49 @@ impl ledger_gui::owner::Owner for ViewerOwner {
self.server.exited()
}
fn serve_roster(&self) -> Result<ledger_gui::owner::Roster, String> {
use ledger_gui::owner::{Assistant, LastCall, Roster, TokenRow};
let roster = self.server.roster(std::time::Duration::from_secs(3))?;
let mut assistants = Vec::new();
for book in roster.sessions {
for s in book.sessions {
assistants.push(Assistant {
book: book.book.clone(),
token: s.token,
client_name: s.client_name,
client_version: s.client_version,
model: s.agent.and_then(|a| a.model),
connected_at: s.connected_at,
running: s.running,
last: s.last.map(|l| LastCall {
tool: l.tool,
outcome: l.outcome,
at: l.at,
}),
});
}
}
let tokens = roster
.tokens
.into_iter()
.map(|t| TokenRow {
book: t.book,
name: t.name,
scopes: t.scopes,
created: t.created,
})
.collect();
Ok(Roster { assistants, tokens })
}
fn serve_revoke(&self, book: &str, name: &str) -> Result<String, String> {
self.server.revoke_token(book, name)
}
fn bridge_command(&self, book: &str) -> Result<String, String> {
ledger_host::commands::bridge_command_line(&self.common, book)
}
fn close_books(&self) -> Result<String, String> {
ledger_host::commands::close_books(&self.common)
}