Replace the signer page with a Connect an app dialog
The main window is now Apps and Activity only. Pairing lives in one re-presented dialog: the client's nostrconnect:// URI, the Start/Stop control, and Regent's own bunker:// code behind a reveal so the QR and the pairing secret are not permanently on screen. The signer's lifecycle and the single approval drain moved into a process-wide SignerRunner. Deleting the old view would otherwise have dropped the only approval channel and turned every prompt into a timeout. The runner also guards against a stop during Starting and against starting with no identity key. Delete the device-key, key-vault and standalone status rows, and keep the Apps page's connect row visible above the list. Update the layout docs and the acceptance action loop.
This commit is contained in:
12 files changed
+892
-632
No files matched your search
@@ -29,6 +29,7 @@ src/headless.rs headless mode + CLI pairing (no window)
|
||||
src/window.rs the windows: main, identities, and the registry (M10)
|
||||
src/config.rs GSettings wrapper (+ REGENT_RELAYS override)
|
||||
src/runtime.rs tokio runtime + the bridge back to the GTK main loop
|
||||
src/runner.rs the signer's lifecycle + the approval drain (process-wide)
|
||||
src/state.rs shared state: key vault, app registry, activity log, change channel
|
||||
src/signer/mod.rs the NIP-46 responder
|
||||
src/signer/approval.rs asking the user (timeout ⇒ deny), incl. unlocking
|
||||
@@ -40,11 +41,11 @@ src/store/profiles.rs cached kind-0 display names (read-only)
|
||||
src/ui/approval.rs approval dialogs
|
||||
src/ui/apps_view.rs the apps page (permission table + revoke)
|
||||
src/ui/activity_view.rs the activity page
|
||||
src/ui/connect.rs the "Connect an app" dialog (pairing + QR reveal)
|
||||
src/ui/kind.rs human names for the common event kinds
|
||||
src/ui/plain.rs plain-text rows/dialogs (markup off)
|
||||
src/ui/preferences.rs the preferences dialog (vault + rate limit)
|
||||
src/ui/keys_view.rs the identities window's content (list + management)
|
||||
src/ui/signer_view.rs the signer page (pairing string, QR, state)
|
||||
src/ui/switcher.rs the header identity switcher
|
||||
src/ui/qr.rs QR → GdkTexture
|
||||
data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, style.css)
|
||||
@@ -178,7 +179,7 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
they closed.
|
||||
- **The launch decision** (`Windows::build` + `present_primary`): no keys ⇒
|
||||
present the identities window only; keys ⇒ the main window, whose first page is
|
||||
Signer. `follow_keys` (a `state.listen` callback) follows the *transition*: the
|
||||
Apps. `follow_keys` (a `state.listen` callback) follows the *transition*: the
|
||||
first key presents the main window and leaves the identities window open, and
|
||||
removing the last key hides the main window and presents the identities window
|
||||
again — first-run mode. Acting on the transition rather than on every `notify()`
|
||||
@@ -296,7 +297,7 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
approvals (the title names it) and its "Forget all" is scoped; Activity filters
|
||||
to the identity and "Clear this identity's activity" keeps the rest. Pre-M7
|
||||
audit rows (no identity) show under every scope.
|
||||
- Signer page: a "New connections" row names the identity a pairing will use.
|
||||
- The "Connect an app" dialog names the identity a new pairing will use.
|
||||
- **Profiles** (`store/profiles.rs`): kind-0 is fetched best-effort from the
|
||||
configured relays and cached in `profiles.json` (0600). Only `display_name` is
|
||||
shown — never nip05 as verified, since kind-0 is attacker-publishable. Avatars
|
||||
@@ -344,13 +345,13 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
present. It is read once, wrapped in `Zeroizing`, and never logged. Without it
|
||||
a locked vault simply denies the sensitive methods. `--pair` needs no identity
|
||||
secret and works while locked.
|
||||
- **In-app pairing** (Signer page → "Pair with a client…"): paste the
|
||||
- **In-app pairing** (Apps page → "Connect an app…" or the primary menu): paste the
|
||||
`nostrconnect://` string, then the *same* approval dialog used for responder
|
||||
questions (`ui::approval::present_question`). On allow, the client's relays are
|
||||
added to the running signer and `signer::pair_client` registers + answers. If
|
||||
the signer is stopped, it is started with the client's relays first. The signer
|
||||
has a `Stopped | Starting | Running` state so a second start cannot put two
|
||||
responders on one device key.
|
||||
the signer is stopped, it is started with the client's relays first. The
|
||||
`SignerRunner` has a `Stopped | Starting | Running` state so a second start
|
||||
cannot put two responders on one device key.
|
||||
- `Signer::add_client_relays` mirrors `start`: add with
|
||||
`verify_subscriptions`, **wait until connected**, then subscribe an explicit
|
||||
`(RelayUrl, Vec<Filter>)` target. Subscribing before the connection lands is
|
||||
|
||||
@@ -227,12 +227,12 @@ grep -q 'regent: bringing the window to the front' "$TMP_HOME/app.log"
|
||||
check $? "clicking the notification brings the window to the front"
|
||||
|
||||
printf '\n== the app actions ==\n'
|
||||
# Preferences builds its dialog on the first activation and re-presents it on the
|
||||
# second; both reach their window through the registry, not app.windows(). A
|
||||
# `RefCell` borrow held across the build (or the wrong window) shows up here as a
|
||||
# dead process rather than as a silent misbehaviour.
|
||||
# Connect and Preferences build their dialogs on the first activation and
|
||||
# re-present them on the second; both reach their window through the registry,
|
||||
# not app.windows(). A `RefCell` borrow held across the build (or the wrong
|
||||
# window) shows up here as a dead process rather than as a silent misbehaviour.
|
||||
OBJ_PATH="/$(printf '%s' "$DATA_DIR" | tr '.' '/')"
|
||||
for action in preferences preferences identities; do
|
||||
for action in connect connect preferences preferences identities; do
|
||||
gdbus call --session --dest "$DATA_DIR" --object-path "$OBJ_PATH" \
|
||||
--method org.freedesktop.Application.ActivateAction "$action" '[]' '{}' \
|
||||
>/dev/null 2>&1
|
||||
@@ -240,7 +240,7 @@ for action in preferences preferences identities; do
|
||||
done
|
||||
|
||||
kill -0 "$APP" 2>/dev/null
|
||||
check $? "activating Preferences twice and Identities leaves the app running"
|
||||
check $? "activating Connect and Preferences twice and Identities leaves the app running"
|
||||
|
||||
! grep -q 'panicked' "$TMP_HOME/app.log"
|
||||
check $? "and nothing panicked"
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ cargo_build = custom_target(binary_name,
|
||||
'src/application.rs',
|
||||
'src/config.rs',
|
||||
'src/headless.rs',
|
||||
'src/runner.rs',
|
||||
'src/runtime.rs',
|
||||
'src/signer/approval.rs',
|
||||
'src/signer/mod.rs',
|
||||
@@ -39,13 +40,13 @@ cargo_build = custom_target(binary_name,
|
||||
'src/ui/activity_view.rs',
|
||||
'src/ui/apps_view.rs',
|
||||
'src/ui/approval.rs',
|
||||
'src/ui/connect.rs',
|
||||
'src/ui/kind.rs',
|
||||
'src/ui/keys_view.rs',
|
||||
'src/ui/mod.rs',
|
||||
'src/ui/plain.rs',
|
||||
'src/ui/preferences.rs',
|
||||
'src/ui/qr.rs',
|
||||
'src/ui/signer_view.rs',
|
||||
'src/ui/switcher.rs',
|
||||
'src/window.rs',
|
||||
),
|
||||
|
||||
@@ -83,6 +83,15 @@ pub fn run() -> glib::ExitCode {
|
||||
}
|
||||
app.add_action(&identities);
|
||||
|
||||
// The "Connect an app…" dialog. Named so it is D-Bus-activatable and the
|
||||
// acceptance test can drive the build-once/present path.
|
||||
let connect = gio::SimpleAction::new("connect", None);
|
||||
{
|
||||
let windows = Rc::clone(&windows);
|
||||
connect.connect_activate(move |_, _| windows.present_connect());
|
||||
}
|
||||
app.add_action(&connect);
|
||||
|
||||
// The vault's security and the request rate limit.
|
||||
let preferences = gio::SimpleAction::new("preferences", None);
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
mod application;
|
||||
mod config;
|
||||
mod headless;
|
||||
mod runner;
|
||||
mod runtime;
|
||||
mod signer;
|
||||
mod state;
|
||||
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
//! The signer's lifecycle: the one responder this process runs, and the one
|
||||
//! approval drain that answers its questions.
|
||||
//!
|
||||
//! This is deliberately **not** a view. The signer is a process-wide actor: it
|
||||
//! must outlive whichever page or dialog happens to be on screen, and the
|
||||
//! approval drain is the only path a request has to the user. Creating it in a
|
||||
//! view meant deleting the view would silently turn every prompt into a timeout,
|
||||
//! so the runner owns it and the windows own the runner.
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use nostr::nips::nip19::ToBech32;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::runtime;
|
||||
use crate::signer::approval::Approver;
|
||||
use crate::signer::{Signer, SignerConfig};
|
||||
use crate::state::AppState;
|
||||
|
||||
/// The responder's lifecycle. `Starting` matters: a second start (the dialog's
|
||||
/// toggle, or a pairing while the first start is still in flight) would put two
|
||||
/// responders on the same device key.
|
||||
#[derive(Clone)]
|
||||
pub enum Status {
|
||||
Stopped,
|
||||
Starting,
|
||||
Running(Arc<Signer>),
|
||||
}
|
||||
|
||||
type Listener = Rc<dyn Fn()>;
|
||||
|
||||
pub struct SignerRunner {
|
||||
state: Rc<AppState>,
|
||||
/// The widget the approval drain parents its dialogs to. It is the main
|
||||
/// window, so a request can never arrive without somewhere to ask.
|
||||
widget: gtk::Widget,
|
||||
approver: Approver,
|
||||
status: RefCell<Status>,
|
||||
/// Bumped by every start and stop. An in-flight start whose generation is
|
||||
/// stale must tear its responder down instead of publishing it.
|
||||
generation: Cell<u64>,
|
||||
/// True while a start is in flight. New starts are refused until it
|
||||
/// resolves and, if it was superseded, its responder has actually stopped.
|
||||
/// This is what keeps a stop during `Starting` from letting a second
|
||||
/// responder overlap the first on the same device key.
|
||||
starting: Cell<bool>,
|
||||
/// Set when a stop arrives while a start is in flight. The start's
|
||||
/// completion tears the responder down instead of publishing it.
|
||||
stop_requested: Cell<bool>,
|
||||
listeners: RefCell<Vec<Listener>>,
|
||||
}
|
||||
|
||||
impl SignerRunner {
|
||||
/// Create the process's runner and install the approval drain. Call this
|
||||
/// once, from the main window, after the window has its application.
|
||||
pub fn new(state: Rc<AppState>, widget: gtk::Widget) -> Rc<Self> {
|
||||
let (approver, prompts) = Approver::new();
|
||||
crate::ui::approval::install(prompts, widget.clone(), Rc::clone(&state));
|
||||
|
||||
let runner = Rc::new(Self {
|
||||
state,
|
||||
widget,
|
||||
approver,
|
||||
status: RefCell::new(Status::Stopped),
|
||||
generation: Cell::new(0),
|
||||
starting: Cell::new(false),
|
||||
stop_requested: Cell::new(false),
|
||||
listeners: RefCell::new(Vec::new()),
|
||||
});
|
||||
|
||||
// Follow the key list's *transitions*, not every `notify()`: a profile
|
||||
// fetch or a lock must not restart a signer the user stopped. The first
|
||||
// key starts the responder; removing the last one stops it, which is what
|
||||
// keeps "the main window is visible exactly when the responder can ask"
|
||||
// honest.
|
||||
{
|
||||
let runner = Rc::clone(&runner);
|
||||
let state = Rc::clone(&runner.state);
|
||||
let had_keys = Cell::new(false);
|
||||
state.listen(move || {
|
||||
let has_keys = runner.state.has_keys();
|
||||
if has_keys == had_keys.get() {
|
||||
return;
|
||||
}
|
||||
had_keys.set(has_keys);
|
||||
if has_keys {
|
||||
runner.auto_start();
|
||||
} else {
|
||||
runner.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
runner
|
||||
}
|
||||
|
||||
pub fn status(&self) -> Status {
|
||||
self.status.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn bunker_uri(&self) -> Option<String> {
|
||||
match &*self.status.borrow() {
|
||||
Status::Running(signer) => Some(signer.bunker_uri().to_string()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Register a callback for lifecycle changes. It runs immediately, so the
|
||||
/// caller does not need a separate initial refresh.
|
||||
pub fn listen(self: &Rc<Self>, listener: impl Fn() + 'static) {
|
||||
let listener: Listener = Rc::new(listener);
|
||||
self.listeners.borrow_mut().push(Rc::clone(&listener));
|
||||
listener();
|
||||
}
|
||||
|
||||
pub(crate) fn notify(&self) {
|
||||
for listener in self.listeners.borrow().clone() {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the responder. `extra` are relays a client asked for; `after` runs
|
||||
/// once the start resolves (pairing uses it to answer the client on the new
|
||||
/// connection, or to report why it failed).
|
||||
pub fn start(
|
||||
self: &Rc<Self>,
|
||||
extra: Vec<String>,
|
||||
after: Option<Box<dyn FnOnce(Result<Arc<Signer>, String>)>>,
|
||||
) {
|
||||
// No key, no responder: starting one would leave the approval drain
|
||||
// parented to a hidden window. The key listener and the toggle both
|
||||
// come through here.
|
||||
if !self.state.has_keys() {
|
||||
if let Some(after) = after {
|
||||
after(Err("Add an identity key first.".to_string()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if self.starting.get() || !matches!(&*self.status.borrow(), Status::Stopped) {
|
||||
if let Some(after) = after {
|
||||
after(Err("The signer is already running or starting.".to_string()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Claim this start. A later stop or start bumps the generation, which
|
||||
// tells this one's completion handler to tear its responder down.
|
||||
self.starting.set(true);
|
||||
self.stop_requested.set(false);
|
||||
let generation = self.generation.get() + 1;
|
||||
self.generation.set(generation);
|
||||
*self.status.borrow_mut() = Status::Starting;
|
||||
self.notify();
|
||||
|
||||
let settings = Config::new();
|
||||
let relays = settings.relays();
|
||||
let auto_approve_limit = settings.auto_approve_limit();
|
||||
|
||||
// Only `Send` handles go into the async task; the runner and its widget
|
||||
// stay on the main thread.
|
||||
let store = self.state.store();
|
||||
let registry = self.state.registry();
|
||||
let activity = self.state.activity();
|
||||
let changes = self.state.changes();
|
||||
let names = self.state.names();
|
||||
let current = self.state.current_identity_handle();
|
||||
let approver = self.approver.clone();
|
||||
let runner = Rc::clone(self);
|
||||
|
||||
runtime::spawn(
|
||||
async move {
|
||||
let mut config = SignerConfig::from_store(
|
||||
store,
|
||||
relays,
|
||||
approver,
|
||||
registry,
|
||||
auto_approve_limit,
|
||||
activity,
|
||||
changes,
|
||||
names,
|
||||
current,
|
||||
)
|
||||
.await?;
|
||||
config.extra_relays = extra;
|
||||
Signer::start(config).await
|
||||
},
|
||||
move |result| {
|
||||
let stale = runner.generation.get() != generation || runner.stop_requested.get();
|
||||
match result {
|
||||
Ok(started) => {
|
||||
let signer = Arc::new(started);
|
||||
if stale {
|
||||
// A stop or a newer start arrived while this start
|
||||
// was in flight. Tear the responder down, and keep
|
||||
// refusing new starts until it has actually stopped.
|
||||
if let Some(after) = after {
|
||||
after(Err("The signer was stopped while starting.".to_string()));
|
||||
}
|
||||
runner.finish_stale_start(signer);
|
||||
return;
|
||||
}
|
||||
runner.starting.set(false);
|
||||
eprintln!(
|
||||
"regent: signer listening on {} relay(s) as {}",
|
||||
signer.relay_count(),
|
||||
signer.device_public_key().to_bech32().unwrap_or_default()
|
||||
);
|
||||
*runner.status.borrow_mut() = Status::Running(Arc::clone(&signer));
|
||||
runner.notify();
|
||||
if let Some(after) = after {
|
||||
after(Ok(signer));
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
runner.starting.set(false);
|
||||
*runner.status.borrow_mut() = Status::Stopped;
|
||||
runner.notify();
|
||||
if let Some(after) = after {
|
||||
after(Err(error));
|
||||
} else {
|
||||
eprintln!("regent: could not start the signer: {error}");
|
||||
crate::ui::plain::error_dialog(&runner.widget, &error);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Tear down a responder whose start was superseded. New starts stay
|
||||
/// refused until the teardown completes, so two responders never overlap.
|
||||
fn finish_stale_start(self: &Rc<Self>, signer: Arc<Signer>) {
|
||||
let runner = Rc::clone(self);
|
||||
runtime::spawn(
|
||||
async move {
|
||||
signer.stop().await;
|
||||
Ok::<(), String>(())
|
||||
},
|
||||
move |_| {
|
||||
runner.starting.set(false);
|
||||
*runner.status.borrow_mut() = Status::Stopped;
|
||||
runner.notify();
|
||||
// A key may have been added while the stale responder was
|
||||
// shutting down. Now that it is gone, follow the key state.
|
||||
if runner.state.has_keys() {
|
||||
runner.auto_start();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn stop(self: &Rc<Self>) {
|
||||
if self.starting.get() {
|
||||
// A start is in flight. Ask its completion to tear the responder
|
||||
// down; keep refusing new starts until that teardown finishes.
|
||||
self.stop_requested.set(true);
|
||||
self.generation.set(self.generation.get() + 1);
|
||||
self.notify();
|
||||
return;
|
||||
}
|
||||
let previous = std::mem::replace(&mut *self.status.borrow_mut(), Status::Stopped);
|
||||
if let Status::Running(signer) = previous {
|
||||
runtime::spawn_detached(async move { signer.stop().await });
|
||||
}
|
||||
self.notify();
|
||||
}
|
||||
|
||||
/// Start without a callback, but only when there is a key to sign with.
|
||||
fn auto_start(self: &Rc<Self>) {
|
||||
if !self.state.has_keys() {
|
||||
return;
|
||||
}
|
||||
self.start(Vec::new(), None);
|
||||
}
|
||||
}
|
||||
+71
-12
@@ -15,6 +15,7 @@ use adw::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
use crate::runner::{SignerRunner, Status};
|
||||
use crate::state::AppState;
|
||||
use crate::store::apps::{App, Permission, Policy};
|
||||
use crate::ui::{kind, plain};
|
||||
@@ -34,15 +35,19 @@ pub struct AppsView {
|
||||
|
||||
struct Ui {
|
||||
stack: gtk::Stack,
|
||||
/// The always-visible "Connect an app…" row; its subtitle is the signer's
|
||||
/// status, so run-state needs no separate banner.
|
||||
connect: adw::ActionRow,
|
||||
/// Cleared and rebuilt when the registry changes; never populated while
|
||||
/// holding the registry lock.
|
||||
content: gtk::Box,
|
||||
/// holding the registry lock. The connect row above it stays put.
|
||||
body: gtk::Box,
|
||||
shown: RefCell<Option<Shown>>,
|
||||
state: Rc<AppState>,
|
||||
runner: Rc<SignerRunner>,
|
||||
}
|
||||
|
||||
impl AppsView {
|
||||
pub fn new(state: Rc<AppState>) -> Self {
|
||||
pub fn new(state: Rc<AppState>, runner: Rc<SignerRunner>) -> Self {
|
||||
let stack = gtk::Stack::builder().vexpand(true).build();
|
||||
|
||||
let empty = adw::StatusPage::builder()
|
||||
@@ -50,6 +55,13 @@ impl AppsView {
|
||||
.title("No applications yet")
|
||||
.description("Applications appear here once you approve them while pairing.")
|
||||
.build();
|
||||
let connect_button = gtk::Button::builder()
|
||||
.label("Connect an app…")
|
||||
.halign(gtk::Align::Center)
|
||||
.css_classes(["pill", "suggested-action"])
|
||||
.build();
|
||||
connect_button.set_action_name(Some("app.connect"));
|
||||
empty.set_child(Some(&connect_button));
|
||||
stack.add_named(&empty, Some("empty"));
|
||||
|
||||
let content = gtk::Box::builder()
|
||||
@@ -60,6 +72,30 @@ impl AppsView {
|
||||
.margin_start(12)
|
||||
.margin_end(12)
|
||||
.build();
|
||||
|
||||
// The connect row sits above the stack, so it stays put in the empty
|
||||
// state too and a long app list cannot scroll the one action that adds
|
||||
// another app out of reach.
|
||||
let connect = plain::row("Connect an app…", "Stopped");
|
||||
let connect_action = gtk::Button::builder()
|
||||
.label("Connect")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["flat"])
|
||||
.build();
|
||||
connect_action.set_action_name(Some("app.connect"));
|
||||
connect.add_suffix(&connect_action);
|
||||
let connect_group = adw::PreferencesGroup::new();
|
||||
connect_group.add(&connect);
|
||||
connect_group.set_margin_top(18);
|
||||
connect_group.set_margin_start(12);
|
||||
connect_group.set_margin_end(12);
|
||||
|
||||
let body = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.spacing(18)
|
||||
.build();
|
||||
content.append(&body);
|
||||
|
||||
let clamp = adw::Clamp::builder()
|
||||
.child(&content)
|
||||
.maximum_size(720)
|
||||
@@ -70,27 +106,50 @@ impl AppsView {
|
||||
.build();
|
||||
stack.add_named(&scrolled, Some("apps"));
|
||||
|
||||
let outer = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build();
|
||||
outer.append(&connect_group);
|
||||
outer.append(&stack);
|
||||
|
||||
let ui = Rc::new(Ui {
|
||||
stack,
|
||||
content,
|
||||
connect,
|
||||
body,
|
||||
shown: RefCell::new(None),
|
||||
state,
|
||||
runner,
|
||||
});
|
||||
|
||||
{
|
||||
let listener_state = Rc::clone(&ui.state);
|
||||
let view = Rc::clone(&ui);
|
||||
listener_state.listen_changes(move || view.refresh());
|
||||
let state = Rc::clone(&ui.state);
|
||||
let listener = Rc::clone(&ui);
|
||||
state.listen_changes(move || listener.refresh());
|
||||
}
|
||||
{
|
||||
let runner = Rc::clone(&ui.runner);
|
||||
let listener = Rc::clone(&ui);
|
||||
runner.listen(move || listener.update_connect_row());
|
||||
}
|
||||
ui.update_connect_row();
|
||||
ui.refresh();
|
||||
|
||||
Self {
|
||||
widget: ui.stack.clone().upcast(),
|
||||
widget: outer.upcast(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ui {
|
||||
fn update_connect_row(&self) {
|
||||
let subtitle = match self.runner.status() {
|
||||
Status::Stopped => "Stopped".to_string(),
|
||||
Status::Starting => "Starting…".to_string(),
|
||||
Status::Running(signer) => format!("Listening on {} relay(s)", signer.relay_count()),
|
||||
};
|
||||
self.connect.set_subtitle(&subtitle);
|
||||
}
|
||||
|
||||
fn refresh(self: &Rc<Self>) {
|
||||
// The page is scoped to the selected identity.
|
||||
let current = self.state.current_identity();
|
||||
@@ -128,8 +187,8 @@ impl Ui {
|
||||
}
|
||||
*self.shown.borrow_mut() = Some(signature);
|
||||
|
||||
while let Some(child) = self.content.first_child() {
|
||||
self.content.remove(&child);
|
||||
while let Some(child) = self.body.first_child() {
|
||||
self.body.remove(&child);
|
||||
}
|
||||
|
||||
if apps.is_empty() {
|
||||
@@ -152,8 +211,8 @@ impl Ui {
|
||||
for app in &apps {
|
||||
group.add(&self.app_row(app));
|
||||
}
|
||||
self.content.append(&group);
|
||||
self.content.append(&self.forget_all_group());
|
||||
self.body.append(&group);
|
||||
self.body.append(&self.forget_all_group());
|
||||
}
|
||||
|
||||
fn app_row(self: &Rc<Self>, app: &App) -> adw::ExpanderRow {
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
//! The "Connect an app…" dialog: pairing in both directions, and the signer's
|
||||
//! run state where it is actionable.
|
||||
//!
|
||||
//! This replaces the old Signer page. The page's permanent connection string and
|
||||
//! QR code were mostly dead weight — and the `bunker://` URI embeds the pairing
|
||||
//! secret, so keeping it behind a deliberate reveal is the safer default. The
|
||||
//! dialog is built once and re-presented, like Preferences.
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use adw::prelude::*;
|
||||
use gtk::gdk;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
use nostr::nips::nip19::ToBech32;
|
||||
use nostr::prelude::PublicKey;
|
||||
|
||||
use crate::runner::{SignerRunner, Status};
|
||||
use crate::runtime;
|
||||
use crate::signer::approval::{Decision, Question, Request, SigningKey};
|
||||
use crate::signer::{ClientPairing, Signer, pair_client, parse_client_uri};
|
||||
use crate::state::AppState;
|
||||
use crate::ui::{approval, plain, qr};
|
||||
|
||||
pub struct ConnectDialog {
|
||||
dialog: adw::Dialog,
|
||||
state: Rc<AppState>,
|
||||
runner: Rc<SignerRunner>,
|
||||
signer_row: adw::ActionRow,
|
||||
toggle: gtk::Button,
|
||||
entry: adw::EntryRow,
|
||||
pair: gtk::Button,
|
||||
/// The identity a new pairing will use. A plain row, because the display
|
||||
/// name is kind-0 data and an `AdwPreferencesGroup` description renders
|
||||
/// markup.
|
||||
signing_as: adw::ActionRow,
|
||||
reveal: adw::ExpanderRow,
|
||||
uri: adw::ActionRow,
|
||||
picture: gtk::Picture,
|
||||
}
|
||||
|
||||
impl ConnectDialog {
|
||||
pub fn new(state: Rc<AppState>, runner: Rc<SignerRunner>) -> Rc<Self> {
|
||||
// --- Start/stop: the only screen where run-state is actionable. ---
|
||||
let signer_row = plain::row("Signer", "Stopped");
|
||||
let toggle = gtk::Button::builder()
|
||||
.label("Start")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["pill", "suggested-action"])
|
||||
.build();
|
||||
signer_row.add_suffix(&toggle);
|
||||
let signer_group = adw::PreferencesGroup::new();
|
||||
signer_group.add(&signer_row);
|
||||
|
||||
// --- The client-initiated direction. ---
|
||||
let identity_group = adw::PreferencesGroup::builder()
|
||||
.title("The app shows a code")
|
||||
.description("New apps sign as the identity selected in the header.")
|
||||
.build();
|
||||
let signing_as = plain::row("Signing as", "");
|
||||
identity_group.add(&signing_as);
|
||||
let entry = adw::EntryRow::builder().title("Pairing code").build();
|
||||
let pair = gtk::Button::builder()
|
||||
.label("Pair")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["suggested-action"])
|
||||
.build();
|
||||
entry.add_suffix(&pair);
|
||||
identity_group.add(&entry);
|
||||
|
||||
// --- The signer-initiated direction: hidden until asked for. ---
|
||||
let uri = plain::row("Connection string", "—");
|
||||
let copy = gtk::Button::builder()
|
||||
.icon_name("edit-copy-symbolic")
|
||||
.tooltip_text("Copy connection string")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["flat"])
|
||||
.build();
|
||||
uri.add_suffix(©);
|
||||
|
||||
let picture = gtk::Picture::builder()
|
||||
.content_fit(gtk::ContentFit::Contain)
|
||||
.can_shrink(true)
|
||||
.height_request(256)
|
||||
.margin_top(12)
|
||||
.margin_bottom(12)
|
||||
.build();
|
||||
|
||||
let reveal = plain::expander(
|
||||
"Show Regent's code",
|
||||
"The connection string embeds the pairing secret.",
|
||||
);
|
||||
reveal.add_row(&uri);
|
||||
reveal.add_row(&picture);
|
||||
let reveal_group = adw::PreferencesGroup::new();
|
||||
reveal_group.add(&reveal);
|
||||
|
||||
let content = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.spacing(18)
|
||||
.margin_top(18)
|
||||
.margin_bottom(18)
|
||||
.margin_start(12)
|
||||
.margin_end(12)
|
||||
.build();
|
||||
content.append(&signer_group);
|
||||
content.append(&identity_group);
|
||||
content.append(&reveal_group);
|
||||
let scrolled = gtk::ScrolledWindow::builder()
|
||||
.child(&content)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
|
||||
let header = adw::HeaderBar::new();
|
||||
header.set_title_widget(Some(&adw::WindowTitle::new("Connect an app", "")));
|
||||
let toolbar = adw::ToolbarView::new();
|
||||
toolbar.add_top_bar(&header);
|
||||
toolbar.set_content(Some(&scrolled));
|
||||
|
||||
let dialog = adw::Dialog::builder()
|
||||
.title("Connect an app")
|
||||
.content_width(560)
|
||||
.content_height(620)
|
||||
.child(&toolbar)
|
||||
.build();
|
||||
|
||||
let connect = Rc::new(Self {
|
||||
dialog,
|
||||
state,
|
||||
runner,
|
||||
signer_row,
|
||||
toggle,
|
||||
entry,
|
||||
pair,
|
||||
signing_as,
|
||||
reveal,
|
||||
uri,
|
||||
picture,
|
||||
});
|
||||
|
||||
// The page changes with the selected identity and with the signer's
|
||||
// lifecycle. Identity selection and key changes go over different
|
||||
// channels (`notify_changes` vs `notify`), so follow both. The runner
|
||||
// has its own listener. All are process-lifetime, like the dialog.
|
||||
{
|
||||
let state = Rc::clone(&connect.state);
|
||||
let listener = Rc::clone(&connect);
|
||||
state.listen(move || listener.refresh());
|
||||
}
|
||||
{
|
||||
let state = Rc::clone(&connect.state);
|
||||
let listener = Rc::clone(&connect);
|
||||
state.listen_changes(move || listener.refresh());
|
||||
}
|
||||
{
|
||||
let runner = Rc::clone(&connect.runner);
|
||||
let listener = Rc::clone(&connect);
|
||||
runner.listen(move || listener.refresh());
|
||||
}
|
||||
|
||||
{
|
||||
let toggle = connect.toggle.clone();
|
||||
let listener = Rc::clone(&connect);
|
||||
toggle.connect_clicked(move |_| match listener.runner.status() {
|
||||
Status::Stopped => listener.runner.start(Vec::new(), None),
|
||||
Status::Running(_) => listener.runner.stop(),
|
||||
Status::Starting => {}
|
||||
});
|
||||
}
|
||||
{
|
||||
let pair = connect.pair.clone();
|
||||
let listener = Rc::clone(&connect);
|
||||
pair.connect_clicked(move |_| listener.pair());
|
||||
}
|
||||
{
|
||||
let entry = connect.entry.clone();
|
||||
let listener = Rc::clone(&connect);
|
||||
entry.connect_entry_activated(move |_| listener.pair());
|
||||
}
|
||||
{
|
||||
let listener = Rc::clone(&connect);
|
||||
copy.connect_clicked(move |_| {
|
||||
if let Some(uri) = listener.runner.bunker_uri() {
|
||||
if let Some(window) = listener.window() {
|
||||
window.clipboard().set_text(&uri);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
{
|
||||
let reveal = connect.reveal.clone();
|
||||
let listener = Rc::clone(&connect);
|
||||
reveal.connect_expanded_notify(move |_| {
|
||||
if listener.reveal.is_expanded() {
|
||||
if let Some(uri) = listener.runner.bunker_uri() {
|
||||
listener.show_qr(&uri);
|
||||
}
|
||||
} else {
|
||||
listener.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
connect.refresh();
|
||||
connect
|
||||
}
|
||||
|
||||
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
|
||||
// Every presentation starts with the code hidden: the bunker URI embeds
|
||||
// the pairing secret, so revealing it stays a deliberate act.
|
||||
self.reveal.set_expanded(false);
|
||||
self.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
self.refresh();
|
||||
self.dialog.present(parent);
|
||||
}
|
||||
|
||||
fn refresh(&self) {
|
||||
let has_keys = self.state.has_keys();
|
||||
let description = match self.state.current_identity() {
|
||||
Some(identity) => {
|
||||
let npub = identity.to_bech32().unwrap_or_else(|_| identity.to_hex());
|
||||
format!(
|
||||
"{} ({npub})",
|
||||
self.state.identity_label(&identity)
|
||||
)
|
||||
}
|
||||
None => "Add an identity key first.".to_string(),
|
||||
};
|
||||
self.signing_as.set_subtitle(&description);
|
||||
|
||||
match self.runner.status() {
|
||||
Status::Stopped => {
|
||||
self.signer_row.set_subtitle(if has_keys {
|
||||
"Stopped"
|
||||
} else {
|
||||
"Add an identity key first"
|
||||
});
|
||||
self.toggle.set_label("Start");
|
||||
self.toggle.set_sensitive(has_keys);
|
||||
self.toggle.add_css_class("suggested-action");
|
||||
self.reveal.set_sensitive(false);
|
||||
self.reveal.set_subtitle("Start the signer first");
|
||||
self.reveal.set_expanded(false);
|
||||
self.uri.set_subtitle("—");
|
||||
self.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
}
|
||||
Status::Starting => {
|
||||
self.signer_row.set_subtitle("Starting…");
|
||||
self.toggle.set_label("Starting…");
|
||||
self.toggle.set_sensitive(false);
|
||||
self.toggle.remove_css_class("suggested-action");
|
||||
self.reveal.set_sensitive(false);
|
||||
self.reveal.set_subtitle("Start the signer first");
|
||||
self.reveal.set_expanded(false);
|
||||
self.uri.set_subtitle("—");
|
||||
self.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
}
|
||||
Status::Running(signer) => {
|
||||
self.signer_row
|
||||
.set_subtitle(&format!("Listening on {} relay(s)", signer.relay_count()));
|
||||
self.toggle.set_label("Stop");
|
||||
self.toggle.set_sensitive(has_keys);
|
||||
self.toggle.remove_css_class("suggested-action");
|
||||
self.reveal.set_sensitive(true);
|
||||
self.reveal
|
||||
.set_subtitle("The connection string embeds the pairing secret.");
|
||||
self.uri.set_subtitle(signer.bunker_uri());
|
||||
if self.reveal.is_expanded() {
|
||||
self.show_qr(signer.bunker_uri());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn show_qr(&self, uri: &str) {
|
||||
match qr::texture(uri, 256) {
|
||||
Ok(texture) => self.picture.set_paintable(Some(&texture)),
|
||||
Err(error) => {
|
||||
eprintln!("regent: could not draw the pairing QR code: {error}");
|
||||
self.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pair(self: &Rc<Self>) {
|
||||
let text = self.entry.text();
|
||||
if text.trim().is_empty() {
|
||||
return;
|
||||
}
|
||||
self.begin_pairing(text.trim());
|
||||
}
|
||||
|
||||
fn begin_pairing(self: &Rc<Self>, uri: &str) {
|
||||
let pairing = match parse_client_uri(uri) {
|
||||
Ok(pairing) => pairing,
|
||||
Err(error) => {
|
||||
self.report_error(
|
||||
self.window().as_ref(),
|
||||
&format!("That is not a usable nostrconnect:// string: {error}"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let Some(identity) = self.state.current_identity() else {
|
||||
self.report_error(
|
||||
self.window().as_ref(),
|
||||
"Add an identity key in the Identities window, then pair an application.",
|
||||
);
|
||||
return;
|
||||
};
|
||||
let name = self
|
||||
.state
|
||||
.names()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&identity.to_hex())
|
||||
.cloned();
|
||||
let rebind_from = self
|
||||
.state
|
||||
.registry()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.identity_for(&pairing.client)
|
||||
.filter(|existing| *existing != identity);
|
||||
|
||||
let question = Question {
|
||||
client: pairing.client_info(),
|
||||
request: Request::Pair {
|
||||
requested: pairing.requested.clone(),
|
||||
},
|
||||
identity: SigningKey {
|
||||
public_key: identity,
|
||||
name,
|
||||
},
|
||||
rebind_from,
|
||||
};
|
||||
|
||||
let connect = Rc::clone(self);
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
// The same approval dialog as a responder question: the app is
|
||||
// registered *before* the response goes out, and the user is the
|
||||
// one who decides.
|
||||
let decision = approval::present_question(&connect.dialog, &question, None).await;
|
||||
if decision == Decision::Deny {
|
||||
return;
|
||||
}
|
||||
|
||||
match connect.runner.status() {
|
||||
Status::Running(signer) => connect.pair_now(&signer, pairing, identity),
|
||||
Status::Starting => connect.report_error(
|
||||
connect.window().as_ref(),
|
||||
"The signer is still starting. Try again in a moment.",
|
||||
),
|
||||
Status::Stopped => {
|
||||
let extra = pairing
|
||||
.relays
|
||||
.iter()
|
||||
.map(|relay| relay.to_string())
|
||||
.collect();
|
||||
let after = Rc::clone(&connect);
|
||||
connect.runner.start(
|
||||
extra,
|
||||
Some(Box::new(move |result| match result {
|
||||
Ok(signer) => after.pair_now(&signer, pairing, identity),
|
||||
Err(error) => after.report_error(after.window().as_ref(), &error),
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn pair_now(
|
||||
self: &Rc<Self>,
|
||||
signer: &Arc<Signer>,
|
||||
pairing: ClientPairing,
|
||||
identity: PublicKey,
|
||||
) {
|
||||
let app_name = pairing
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| "The application".to_string());
|
||||
let registry = self.state.registry();
|
||||
let activity = self.state.activity();
|
||||
let changes = self.state.changes();
|
||||
let signer = Arc::clone(signer);
|
||||
let connect = Rc::clone(self);
|
||||
let window = self.window();
|
||||
|
||||
runtime::spawn(
|
||||
async move {
|
||||
signer.add_client_relays(&pairing.relays).await?;
|
||||
pair_client(&signer, ®istry, &activity, &changes, &pairing, identity).await?;
|
||||
Ok::<(), crate::signer::Error>(())
|
||||
},
|
||||
move |result| match result {
|
||||
Ok(()) => {
|
||||
// The client's relays are now part of the running signer;
|
||||
// refresh the relay count shown by the dialog and Apps page.
|
||||
connect.runner.notify();
|
||||
connect.entry.set_text("");
|
||||
connect.dialog.force_close();
|
||||
connect.present_paired(window.as_ref(), &app_name, identity);
|
||||
}
|
||||
Err(error) => connect.report_error(window.as_ref(), &error),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn present_paired(
|
||||
&self,
|
||||
window: Option<>k::Window>,
|
||||
app: &str,
|
||||
identity: PublicKey,
|
||||
) {
|
||||
let name = self
|
||||
.state
|
||||
.names()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&identity.to_hex())
|
||||
.cloned();
|
||||
let npub = identity.to_bech32().unwrap_or_else(|_| identity.to_hex());
|
||||
let who = match name {
|
||||
Some(name) if !name.trim().is_empty() => format!("{name} ({npub})"),
|
||||
_ => npub,
|
||||
};
|
||||
let dialog = adw::AlertDialog::builder()
|
||||
.heading_use_markup(false)
|
||||
.body_use_markup(false)
|
||||
.heading("Client paired")
|
||||
.body(format!("{app} now signs as {who}."))
|
||||
.build();
|
||||
plain::dialog(&dialog);
|
||||
dialog.add_response("close", "Close");
|
||||
dialog.set_default_response(Some("close"));
|
||||
dialog.present(window);
|
||||
}
|
||||
|
||||
fn report_error(&self, window: Option<>k::Window>, message: &str) {
|
||||
let dialog = adw::AlertDialog::builder()
|
||||
.heading_use_markup(false)
|
||||
.body_use_markup(false)
|
||||
.heading("Something went wrong")
|
||||
.body(message)
|
||||
.build();
|
||||
plain::dialog(&dialog);
|
||||
dialog.add_response("close", "Close");
|
||||
dialog.set_default_response(Some("close"));
|
||||
dialog.present(window);
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<gtk::Window> {
|
||||
self.dialog.root().and_downcast::<gtk::Window>()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,10 +3,10 @@
|
||||
pub mod activity_view;
|
||||
pub mod approval;
|
||||
pub mod apps_view;
|
||||
pub mod connect;
|
||||
pub mod kind;
|
||||
pub mod keys_view;
|
||||
pub mod plain;
|
||||
pub mod preferences;
|
||||
pub mod qr;
|
||||
pub mod signer_view;
|
||||
pub mod switcher;
|
||||
@@ -11,8 +11,26 @@
|
||||
//! defaults to plain text, so it needs no wrapper.
|
||||
|
||||
use adw::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
/// A plain "Something went wrong" dialog, parented to the widget's window.
|
||||
///
|
||||
/// The message is our own text, but it can carry a client-supplied name or a
|
||||
/// relay's error, so it goes through the same no-markup path as everything else.
|
||||
pub fn error_dialog(widget: &impl IsA<gtk::Widget>, message: &str) {
|
||||
let alert = adw::AlertDialog::builder()
|
||||
.heading_use_markup(false)
|
||||
.body_use_markup(false)
|
||||
.heading("Something went wrong")
|
||||
.body(message)
|
||||
.build();
|
||||
dialog(&alert);
|
||||
alert.add_response("close", "Close");
|
||||
alert.set_default_response(Some("close"));
|
||||
alert.present(widget.root().and_downcast::<gtk::Window>().as_ref());
|
||||
}
|
||||
|
||||
/// An `ActionRow` whose title and subtitle are plain text.
|
||||
///
|
||||
/// Markup is turned off **before** the strings are set. A builder that sets
|
||||
|
||||
@@ -1,592 +0,0 @@
|
||||
//! The signer page: connection string, QR code, and whether Regent is listening.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::signer::approval::{Approver, Decision, Question, Request, SigningKey};
|
||||
|
||||
use nostr::nips::nip19::ToBech32;
|
||||
use nostr::prelude::PublicKey;
|
||||
|
||||
use adw::prelude::*;
|
||||
use gtk::gdk;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::runtime;
|
||||
use crate::signer::{ClientPairing, Signer, SignerConfig, pair_client, parse_client_uri};
|
||||
use crate::state::AppState;
|
||||
use crate::ui::approval;
|
||||
use crate::ui::plain;
|
||||
use crate::ui::qr;
|
||||
|
||||
/// Handles the callbacks need; cloned per closure.
|
||||
#[derive(Clone)]
|
||||
struct Handles {
|
||||
stack: gtk::Stack,
|
||||
status: adw::ActionRow,
|
||||
uri: adw::ActionRow,
|
||||
device: adw::ActionRow,
|
||||
picture: gtk::Picture,
|
||||
toggle: gtk::Button,
|
||||
pair: gtk::Button,
|
||||
signing_as: adw::ActionRow,
|
||||
vault: adw::ActionRow,
|
||||
}
|
||||
|
||||
/// The toplevel, resolved lazily: a view is not in a window when it is built.
|
||||
fn toplevel(handles: &Handles) -> Option<gtk::Window> {
|
||||
handles.stack.root().and_downcast::<gtk::Window>()
|
||||
}
|
||||
|
||||
/// The signer's lifecycle. `Starting` matters: a second start (the toggle, or a
|
||||
/// paste while the first start is still in flight) would put two responders on
|
||||
/// the same device key.
|
||||
enum State {
|
||||
Stopped,
|
||||
Starting,
|
||||
Running(Arc<Signer>),
|
||||
}
|
||||
|
||||
type Running = Rc<RefCell<State>>;
|
||||
|
||||
pub struct SignerView {
|
||||
pub widget: gtk::Widget,
|
||||
}
|
||||
|
||||
impl SignerView {
|
||||
pub fn new(state: Rc<AppState>) -> Self {
|
||||
let stack = gtk::Stack::builder().vexpand(true).build();
|
||||
|
||||
let empty = adw::StatusPage::builder()
|
||||
.icon_name("network-offline-symbolic")
|
||||
.title("Nothing to listen for yet")
|
||||
.description(
|
||||
"Add an identity key in the Identities window, then come back here to \
|
||||
connect an application.",
|
||||
)
|
||||
.build();
|
||||
stack.add_named(&empty, Some("empty"));
|
||||
|
||||
let status = plain::row("Status", "Stopped");
|
||||
let uri = plain::row("Connection string", "—");
|
||||
let copy = gtk::Button::builder()
|
||||
.icon_name("edit-copy-symbolic")
|
||||
.tooltip_text("Copy connection string")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["flat"])
|
||||
.build();
|
||||
uri.add_suffix(©);
|
||||
let device = plain::row("Device key", "—");
|
||||
let signing_as = plain::row("New connections", "—");
|
||||
let vault = plain::row("Key vault", "—");
|
||||
|
||||
let group = adw::PreferencesGroup::builder()
|
||||
.title("Pairing")
|
||||
.description("Hand this to a Nostr application, or let it scan the code.")
|
||||
.build();
|
||||
group.add(&status);
|
||||
group.add(&uri);
|
||||
group.add(&device);
|
||||
group.add(&signing_as);
|
||||
group.add(&vault);
|
||||
|
||||
// The client-initiated direction: the application shows a
|
||||
// `nostrconnect://` string and waits for the signer to answer it.
|
||||
let pair_row = plain::row(
|
||||
"Pair with a client",
|
||||
"Paste a nostrconnect:// string from an application that is waiting to connect",
|
||||
);
|
||||
let pair = gtk::Button::builder()
|
||||
.label("Pair…")
|
||||
.valign(gtk::Align::Center)
|
||||
.css_classes(["flat"])
|
||||
.build();
|
||||
pair_row.add_suffix(&pair);
|
||||
group.add(&pair_row);
|
||||
|
||||
let picture = gtk::Picture::builder()
|
||||
.content_fit(gtk::ContentFit::Contain)
|
||||
.can_shrink(true)
|
||||
.height_request(220)
|
||||
.margin_top(12)
|
||||
.margin_bottom(12)
|
||||
.build();
|
||||
|
||||
let toggle = gtk::Button::builder()
|
||||
.label("Start")
|
||||
.halign(gtk::Align::Center)
|
||||
.css_classes(["pill", "suggested-action"])
|
||||
.build();
|
||||
|
||||
let page = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.spacing(18)
|
||||
.margin_top(18)
|
||||
.margin_bottom(18)
|
||||
.margin_start(12)
|
||||
.margin_end(12)
|
||||
.build();
|
||||
page.append(&group);
|
||||
page.append(&picture);
|
||||
page.append(&toggle);
|
||||
|
||||
let scrolled = gtk::ScrolledWindow::builder()
|
||||
.child(&page)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
stack.add_named(&scrolled, Some("ready"));
|
||||
|
||||
let handles = Handles {
|
||||
stack,
|
||||
status,
|
||||
uri,
|
||||
device,
|
||||
picture,
|
||||
toggle,
|
||||
pair,
|
||||
signing_as,
|
||||
vault,
|
||||
};
|
||||
|
||||
let widget: gtk::Widget = handles.stack.clone().upcast();
|
||||
|
||||
update_state(&handles, &state);
|
||||
{
|
||||
let (listener_handles, listener_state) = (handles.clone(), Rc::clone(&state));
|
||||
state.listen(move || update_state(&listener_handles, &listener_state));
|
||||
}
|
||||
{
|
||||
let (listener_handles, listener_state) = (handles.clone(), Rc::clone(&state));
|
||||
state.listen_changes(move || update_state(&listener_handles, &listener_state));
|
||||
}
|
||||
|
||||
// Approval questions and unlock prompts are answered on the main loop;
|
||||
// the responder waits on the other end of this channel.
|
||||
let (approver, prompts) = Approver::new();
|
||||
crate::ui::approval::install(prompts, widget.clone(), Rc::clone(&state));
|
||||
|
||||
let running: Running = Rc::new(RefCell::new(State::Stopped));
|
||||
|
||||
{
|
||||
let (handles, running) = (handles.clone(), Rc::clone(&running));
|
||||
copy.connect_clicked(move |_| {
|
||||
let signer = match &*running.borrow() {
|
||||
State::Running(signer) => Arc::clone(signer),
|
||||
_ => return,
|
||||
};
|
||||
if let Some(window) = toplevel(&handles) {
|
||||
window.clipboard().set_text(signer.bunker_uri());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let (handles, state, running) = (handles.clone(), Rc::clone(&state), Rc::clone(&running));
|
||||
let approver = approver.clone();
|
||||
handles.toggle.clone().connect_clicked(move |_| {
|
||||
if matches!(&*running.borrow(), State::Starting) {
|
||||
return;
|
||||
}
|
||||
if matches!(&*running.borrow(), State::Running(_)) {
|
||||
stop(handles.clone(), Rc::clone(&running));
|
||||
} else {
|
||||
start(
|
||||
handles.clone(),
|
||||
Rc::clone(&state),
|
||||
Rc::clone(&running),
|
||||
approver.clone(),
|
||||
Vec::new(),
|
||||
None,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let (handles, state, running) = (handles.clone(), Rc::clone(&state), Rc::clone(&running));
|
||||
let approver = approver.clone();
|
||||
handles.pair.clone().connect_clicked(move |_| {
|
||||
present_paste_dialog(
|
||||
handles.clone(),
|
||||
Rc::clone(&state),
|
||||
Rc::clone(&running),
|
||||
approver.clone(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// React to the vault becoming available, and to keys being changed.
|
||||
{
|
||||
let handles = handles.clone();
|
||||
let signer_running = Rc::clone(&running);
|
||||
let listener_state = Rc::clone(&state);
|
||||
let listener_approver = approver.clone();
|
||||
state.listen(move || {
|
||||
let store = listener_state.store();
|
||||
if !matches!(&*signer_running.borrow(), State::Stopped) {
|
||||
return;
|
||||
}
|
||||
let (handles, state, running) = (
|
||||
handles.clone(),
|
||||
Rc::clone(&listener_state),
|
||||
Rc::clone(&signer_running),
|
||||
);
|
||||
let approver = listener_approver.clone();
|
||||
runtime::spawn(
|
||||
async move { Ok::<_, String>(store.list_user_keys()) },
|
||||
move |result| match result {
|
||||
Ok(keys) if keys.is_empty() => show_empty(&handles),
|
||||
Ok(_) => start(handles, state, running, approver, Vec::new(), None),
|
||||
Err(error) => report_error(&handles, &error),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
}
|
||||
|
||||
/// Show which identity a new pairing would use, and whether the vault is open.
|
||||
fn update_state(handles: &Handles, state: &Rc<AppState>) {
|
||||
let subtitle = match state.current_identity() {
|
||||
Some(key) => {
|
||||
let name = state.identity_label(&key);
|
||||
let npub = key.to_bech32().unwrap_or_else(|_| key.to_hex());
|
||||
format!("{name} ({npub})")
|
||||
}
|
||||
None => "no identity key yet".to_string(),
|
||||
};
|
||||
handles.signing_as.set_subtitle(&subtitle);
|
||||
handles.vault.set_subtitle(if state.is_locked() {
|
||||
"Locked — the passphrase is needed to sign"
|
||||
} else {
|
||||
"Unlocked"
|
||||
});
|
||||
}
|
||||
|
||||
fn show_empty(handles: &Handles) {
|
||||
handles.stack.set_visible_child_name("empty");
|
||||
handles.status.set_subtitle("Stopped");
|
||||
handles.uri.set_subtitle("—");
|
||||
handles.device.set_subtitle("—");
|
||||
handles.toggle.set_label("Start");
|
||||
}
|
||||
|
||||
fn start(
|
||||
handles: Handles,
|
||||
state: Rc<AppState>,
|
||||
running: Running,
|
||||
approver: Approver,
|
||||
extra_relays: Vec<String>,
|
||||
after: Option<(ClientPairing, PublicKey)>,
|
||||
) {
|
||||
if !matches!(&*running.borrow(), State::Stopped) {
|
||||
return;
|
||||
}
|
||||
let store = state.store();
|
||||
*running.borrow_mut() = State::Starting;
|
||||
|
||||
let settings = Config::new();
|
||||
let relays = settings.relays();
|
||||
let auto_approve_limit = settings.auto_approve_limit();
|
||||
|
||||
// Only `Send` handles go into the async task; the registry and log are the
|
||||
// shared ones the pages read.
|
||||
let registry = state.registry();
|
||||
let activity = state.activity();
|
||||
let changes = state.changes();
|
||||
let names = state.names();
|
||||
let current = state.current_identity_handle();
|
||||
|
||||
runtime::spawn(
|
||||
async move {
|
||||
let mut config = SignerConfig::from_store(
|
||||
store,
|
||||
relays,
|
||||
approver,
|
||||
registry,
|
||||
auto_approve_limit,
|
||||
activity,
|
||||
changes,
|
||||
names,
|
||||
current,
|
||||
)
|
||||
.await?;
|
||||
config.extra_relays = extra_relays;
|
||||
Signer::start(config).await
|
||||
},
|
||||
move |result| match result {
|
||||
Ok(started) => {
|
||||
let started = Arc::new(started);
|
||||
*running.borrow_mut() = State::Running(Arc::clone(&started));
|
||||
show_running(&handles, &started);
|
||||
if let Some((pairing, identity)) = after {
|
||||
pair_now(handles.clone(), state, &started, pairing, identity);
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
*running.borrow_mut() = State::Stopped;
|
||||
handles.status.set_subtitle("Could not start");
|
||||
handles.stack.set_visible_child_name("ready");
|
||||
report_error(&handles, &error);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn stop(handles: Handles, running: Running) {
|
||||
let signer = match std::mem::replace(&mut *running.borrow_mut(), State::Stopped) {
|
||||
State::Running(signer) => signer,
|
||||
_ => return,
|
||||
};
|
||||
runtime::spawn_detached(async move { signer.stop().await });
|
||||
handles.picture.set_paintable(None::<&gdk::Paintable>);
|
||||
handles.status.set_subtitle("Stopped");
|
||||
handles.uri.set_subtitle("—");
|
||||
handles.device.set_subtitle("—");
|
||||
handles.toggle.set_label("Start");
|
||||
}
|
||||
|
||||
fn show_running(handles: &Handles, signer: &Signer) {
|
||||
// Deliberately logs the public key and relay count, never the secret.
|
||||
eprintln!(
|
||||
"regent: signer listening on {} relay(s) as {}",
|
||||
signer.relay_count(),
|
||||
signer.device_public_key().to_bech32().unwrap_or_default()
|
||||
);
|
||||
|
||||
handles.stack.set_visible_child_name("ready");
|
||||
handles
|
||||
.status
|
||||
.set_subtitle(&format!("Running on {} relay(s)", signer.relay_count()));
|
||||
handles.uri.set_subtitle(signer.bunker_uri());
|
||||
handles
|
||||
.device
|
||||
.set_subtitle(&signer.device_public_key().to_bech32().unwrap_or_default());
|
||||
handles.toggle.set_label("Stop");
|
||||
|
||||
match qr::texture(signer.bunker_uri(), 220) {
|
||||
Ok(texture) => handles.picture.set_paintable(Some(&texture)),
|
||||
Err(error) => handles.status.set_subtitle(&format!("QR failed: {error}")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ask for the client's `nostrconnect://` string.
|
||||
fn present_paste_dialog(
|
||||
handles: Handles,
|
||||
state: Rc<AppState>,
|
||||
running: Running,
|
||||
approver: Approver,
|
||||
) {
|
||||
// A plain `gtk::Entry`: an `AdwEntryRow` renders its text as Pango markup.
|
||||
let entry = gtk::Entry::builder()
|
||||
.placeholder_text("nostrconnect://…")
|
||||
.hexpand(true)
|
||||
.build();
|
||||
let dialog = adw::AlertDialog::builder()
|
||||
.heading("Pair with a client")
|
||||
.body(
|
||||
"Paste the nostrconnect:// string the application is showing. It must be \
|
||||
waiting for Regent to connect.",
|
||||
)
|
||||
.extra_child(&entry)
|
||||
.build();
|
||||
plain::dialog(&dialog);
|
||||
dialog.add_response("cancel", "Cancel");
|
||||
dialog.add_response("pair", "Pair");
|
||||
dialog.set_default_response(Some("pair"));
|
||||
dialog.set_response_appearance("pair", adw::ResponseAppearance::Suggested);
|
||||
dialog.set_close_response("cancel");
|
||||
|
||||
{
|
||||
let entry = entry.clone();
|
||||
let handles = handles.clone();
|
||||
dialog.connect_response(None, move |_, response| {
|
||||
if response != "pair" {
|
||||
return;
|
||||
}
|
||||
let uri = entry.text().to_string();
|
||||
if !uri.trim().is_empty() {
|
||||
begin_pairing(
|
||||
&handles,
|
||||
Rc::clone(&state),
|
||||
Rc::clone(&running),
|
||||
approver.clone(),
|
||||
uri,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
dialog.present(toplevel(&handles).as_ref());
|
||||
}
|
||||
|
||||
/// Parse the URI, ask for consent, then pair — starting the signer if it is
|
||||
/// stopped, so the button works from any state.
|
||||
fn begin_pairing(
|
||||
handles: &Handles,
|
||||
state: Rc<AppState>,
|
||||
running: Running,
|
||||
approver: Approver,
|
||||
uri: String,
|
||||
) {
|
||||
let pairing = match parse_client_uri(uri.trim()) {
|
||||
Ok(pairing) => pairing,
|
||||
Err(error) => {
|
||||
report_error(
|
||||
handles,
|
||||
&format!("That is not a usable nostrconnect:// string: {error}"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// New pairings are bound to the currently selected identity.
|
||||
let Some(identity) = state.current_identity() else {
|
||||
report_error(
|
||||
handles,
|
||||
"Add an identity key in the Identities window first, then pair a client.",
|
||||
);
|
||||
return;
|
||||
};
|
||||
let name = state
|
||||
.names()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&identity.to_hex())
|
||||
.cloned();
|
||||
eprintln!(
|
||||
"regent: pairing as {}",
|
||||
identity.to_bech32().unwrap_or_else(|_| identity.to_hex())
|
||||
);
|
||||
let rebind_from = state
|
||||
.registry()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.identity_for(&pairing.client)
|
||||
.filter(|previous| *previous != identity);
|
||||
let question = Question {
|
||||
client: pairing.client_info(),
|
||||
request: Request::Pair {
|
||||
requested: pairing.requested.clone(),
|
||||
},
|
||||
identity: SigningKey {
|
||||
public_key: identity,
|
||||
name,
|
||||
},
|
||||
rebind_from,
|
||||
};
|
||||
|
||||
let handles = handles.clone();
|
||||
let widget: gtk::Widget = handles.stack.clone().upcast();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
// The same dialog and the same rules as a responder-side question.
|
||||
let decision = approval::present_question(&widget, &question, None).await;
|
||||
if decision == Decision::Deny {
|
||||
return;
|
||||
}
|
||||
|
||||
if matches!(&*running.borrow(), State::Starting) {
|
||||
report_error(
|
||||
&handles,
|
||||
"The signer is still starting; try again in a moment.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
let signer = match &*running.borrow() {
|
||||
State::Running(signer) => Some(Arc::clone(signer)),
|
||||
_ => None,
|
||||
};
|
||||
match signer {
|
||||
Some(signer) => pair_now(handles, state, &signer, pairing, identity),
|
||||
None => {
|
||||
let extra = pairing
|
||||
.relays
|
||||
.iter()
|
||||
.map(|relay| relay.to_string())
|
||||
.collect();
|
||||
start(
|
||||
handles,
|
||||
state,
|
||||
running,
|
||||
approver,
|
||||
extra,
|
||||
Some((pairing, identity)),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Add the client's relays to the running signer and send it the connect
|
||||
/// response. The app is registered before the response goes out (the client
|
||||
/// validates the secret and immediately sends `connect`).
|
||||
fn pair_now(
|
||||
handles: Handles,
|
||||
state: Rc<AppState>,
|
||||
signer: &Arc<Signer>,
|
||||
pairing: ClientPairing,
|
||||
identity: PublicKey,
|
||||
) {
|
||||
let app_name = pairing
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| "The application".to_string());
|
||||
let registry = state.registry();
|
||||
let activity = state.activity();
|
||||
let changes = state.changes();
|
||||
let signer = Arc::clone(signer);
|
||||
let refresh = Arc::clone(&signer);
|
||||
let ui_state = Rc::clone(&state);
|
||||
runtime::spawn(
|
||||
async move {
|
||||
signer.add_client_relays(&pairing.relays).await?;
|
||||
pair_client(&signer, ®istry, &activity, &changes, &pairing, identity).await?;
|
||||
Ok::<(), crate::signer::Error>(())
|
||||
},
|
||||
move |result| match result {
|
||||
Ok(()) => {
|
||||
show_running(&handles, &refresh);
|
||||
present_paired(&handles, &app_name, &ui_state, identity);
|
||||
}
|
||||
Err(error) => report_error(&handles, &error),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Confirm which identity a freshly paired client was bound to.
|
||||
fn present_paired(handles: &Handles, app: &str, state: &Rc<AppState>, identity: PublicKey) {
|
||||
let name = state
|
||||
.names()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&identity.to_hex())
|
||||
.cloned();
|
||||
let npub = identity.to_bech32().unwrap_or_else(|_| identity.to_hex());
|
||||
let who = match name {
|
||||
Some(name) if !name.trim().is_empty() => format!("{name} ({npub})"),
|
||||
_ => npub,
|
||||
};
|
||||
let dialog = adw::AlertDialog::builder()
|
||||
.heading("Client paired")
|
||||
.body(format!("{app} now signs as {who}."))
|
||||
.build();
|
||||
plain::dialog(&dialog);
|
||||
dialog.add_response("close", "Close");
|
||||
dialog.set_default_response(Some("close"));
|
||||
dialog.present(toplevel(handles).as_ref());
|
||||
}
|
||||
|
||||
fn report_error(handles: &Handles, message: &str) {
|
||||
let dialog = adw::AlertDialog::builder()
|
||||
.title("Something went wrong")
|
||||
.body(message)
|
||||
.build();
|
||||
plain::dialog(&dialog);
|
||||
dialog.add_response("close", "Close");
|
||||
dialog.set_default_response(Some("close"));
|
||||
dialog.present(toplevel(handles).as_ref());
|
||||
}
|
||||
+42
-13
@@ -1,5 +1,5 @@
|
||||
//! The windows: the main one (Signer / Apps / Activity), the identities one, and
|
||||
//! the registry that decides which of them the app "is".
|
||||
//! The windows: the main one (Apps / Activity), the identities one, and the
|
||||
//! registry that decides which of them the app "is".
|
||||
//!
|
||||
//! Two windows rather than one plus a dialog, because a dialog presents *inside*
|
||||
//! a parent window and so cannot be the whole visible app — and on first run,
|
||||
@@ -12,12 +12,13 @@ use gtk::gio;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
use crate::runner::SignerRunner;
|
||||
use crate::state::AppState;
|
||||
use crate::ui::activity_view::ActivityView;
|
||||
use crate::ui::apps_view::AppsView;
|
||||
use crate::ui::connect::ConnectDialog;
|
||||
use crate::ui::keys_view::KeysView;
|
||||
use crate::ui::preferences::Preferences;
|
||||
use crate::ui::signer_view::SignerView;
|
||||
use crate::ui::switcher::IdentitySwitcher;
|
||||
use crate::RESOURCE_PATH;
|
||||
|
||||
@@ -35,6 +36,8 @@ pub struct Windows {
|
||||
main: RefCell<Option<adw::ApplicationWindow>>,
|
||||
identities: RefCell<Option<adw::ApplicationWindow>>,
|
||||
preferences: RefCell<Option<Rc<Preferences>>>,
|
||||
runner: RefCell<Option<Rc<SignerRunner>>>,
|
||||
connect: RefCell<Option<Rc<ConnectDialog>>>,
|
||||
}
|
||||
|
||||
impl Windows {
|
||||
@@ -45,6 +48,8 @@ impl Windows {
|
||||
main: RefCell::new(None),
|
||||
identities: RefCell::new(None),
|
||||
preferences: RefCell::new(None),
|
||||
runner: RefCell::new(None),
|
||||
connect: RefCell::new(None),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,6 +121,28 @@ impl Windows {
|
||||
preferences.present(self.primary().as_ref());
|
||||
}
|
||||
|
||||
/// Present the "Connect an app…" dialog inside the window the app "is".
|
||||
/// Built once and re-presented, like Preferences: its listeners stay
|
||||
/// registered and the dialog re-presents after being closed.
|
||||
pub fn present_connect(&self) {
|
||||
// Bind the clone to a local first: a `match` scrutinee is a temporary
|
||||
// scope that lasts to the end of the match, so an inline `borrow()`
|
||||
// would still hold the `Ref` when the `None` arm takes `borrow_mut()`.
|
||||
let existing = self.connect.borrow().clone();
|
||||
let connect = match existing {
|
||||
Some(connect) => connect,
|
||||
None => {
|
||||
let Some(runner) = self.runner.borrow().clone() else {
|
||||
return;
|
||||
};
|
||||
let connect = ConnectDialog::new(Rc::clone(&self.state), runner);
|
||||
*self.connect.borrow_mut() = Some(Rc::clone(&connect));
|
||||
connect
|
||||
}
|
||||
};
|
||||
connect.present(self.primary().as_ref());
|
||||
}
|
||||
|
||||
/// Follow the key list: the main window is what the app is once a key
|
||||
/// exists, and the identities window is what it is when the last key is
|
||||
/// removed — the state the app starts in.
|
||||
@@ -165,18 +192,20 @@ fn main_window(
|
||||
.object("header_bar")
|
||||
.expect("ui/window.blp must contain an object with id \"header_bar\"");
|
||||
|
||||
let signer_view = SignerView::new(Rc::clone(state));
|
||||
let apps_view = AppsView::new(Rc::clone(state));
|
||||
// The window must have its application before the runner installs the
|
||||
// approval drain: a notification without an application goes nowhere.
|
||||
window.set_application(Some(app));
|
||||
|
||||
// The runner owns the process's only approval drain and the signer's
|
||||
// lifecycle. Create it before the views so the Apps page can show its state.
|
||||
let runner = SignerRunner::new(Rc::clone(state), window.clone().upcast());
|
||||
*windows.runner.borrow_mut() = Some(Rc::clone(&runner));
|
||||
|
||||
let apps_view = AppsView::new(Rc::clone(state), Rc::clone(&runner));
|
||||
let activity_view = ActivityView::new(Rc::clone(state));
|
||||
|
||||
let stack = adw::ViewStack::new();
|
||||
// Signer first: it is what the app is, and the switcher follows the stack.
|
||||
stack.add_titled_with_icon(
|
||||
&signer_view.widget,
|
||||
Some("signer"),
|
||||
"Signer",
|
||||
"network-transmit-receive-symbolic",
|
||||
);
|
||||
// Apps first: it is what the app is for, and the switcher follows the stack.
|
||||
stack.add_titled_with_icon(
|
||||
&apps_view.widget,
|
||||
Some("apps"),
|
||||
@@ -214,6 +243,7 @@ fn main_window(
|
||||
|
||||
// The primary menu. Locking stays on the button above, so it needs no entry.
|
||||
let menu = gio::Menu::new();
|
||||
menu.append(Some("Connect an app…"), Some("app.connect"));
|
||||
menu.append(Some("Manage identities…"), Some("app.identities"));
|
||||
menu.append(Some("Preferences…"), Some("app.preferences"));
|
||||
menu.append(Some("Quit"), Some("app.quit"));
|
||||
@@ -245,7 +275,6 @@ fn main_window(
|
||||
}
|
||||
|
||||
toolbar_view.set_content(Some(&stack));
|
||||
window.set_application(Some(app));
|
||||
|
||||
// Closing the main window ends the session. The responder can only put a
|
||||
// request to the user through this window, so leaving the process alive —
|
||||
|
||||
Reference in new issue
Block a user