Merge pull request 'ui: show the identity name in the approval dialog' (#14) from fix/approval-identity-name into main
CI / test (push) Successful in 48s
CI / test (push) Successful in 48s
Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
10 files changed
+47
-77
No files matched your search
@@ -29,6 +29,14 @@ the only place release notes are written.
|
||||
row `Sign kind 7 (Reaction)`, and an activity entry
|
||||
`Reaction (kind 7) — allowed silently`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The approval dialog's "Signing as" now shows the same identity name as the rest
|
||||
of the app. It read the key's vault label directly, so an identity whose profile
|
||||
carries a `display_name` appeared under that name in the switcher, the Apps page
|
||||
and the Connect dialog, but as `Identity key` in the approval prompt. Every
|
||||
surface now resolves the name through one rule.
|
||||
|
||||
## [0.9.2] - 2026-12-01
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
//! Deliberately not a `GtkApplication`: headless must work with no display, and
|
||||
//! nothing here needs GTK. It is a plain tokio program.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::AtomicU32;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -112,11 +111,6 @@ async fn serve(
|
||||
.unwrap_or(stored[0].public_key),
|
||||
};
|
||||
|
||||
let names: HashMap<String, String> = stored
|
||||
.into_iter()
|
||||
.map(|stored| (stored.public_key.to_hex(), stored.name))
|
||||
.collect();
|
||||
let names = Arc::new(Mutex::new(names));
|
||||
let default_identity = Arc::new(Mutex::new(Some(identity)));
|
||||
|
||||
// No window: deny everything the user has not already allowed, and never
|
||||
@@ -165,7 +159,6 @@ async fn serve(
|
||||
Arc::new(AtomicU32::new(settings.auto_approve_limit())),
|
||||
activity.clone(),
|
||||
changes.clone(),
|
||||
names,
|
||||
default_identity,
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -199,7 +199,6 @@ impl SignerRunner {
|
||||
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);
|
||||
@@ -214,7 +213,6 @@ impl SignerRunner {
|
||||
auto_approve_limit,
|
||||
activity,
|
||||
changes,
|
||||
names,
|
||||
current,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -33,10 +33,14 @@ pub struct ClientInfo {
|
||||
}
|
||||
|
||||
/// The identity key a request would act as.
|
||||
///
|
||||
/// Carries no name: the UI resolves the label it shows through
|
||||
/// `AppState::identity_label`, the one display rule (profile `display_name`
|
||||
/// first, else the user's key label), so a second, vault-only name cannot drift
|
||||
/// from the switcher.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SigningKey {
|
||||
pub public_key: PublicKey,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
/// One event tag, in the shape the dialog shows it.
|
||||
@@ -332,10 +336,7 @@ mod tests {
|
||||
image: None,
|
||||
},
|
||||
request,
|
||||
identity: SigningKey {
|
||||
public_key: identity.public_key(),
|
||||
name: None,
|
||||
},
|
||||
identity: SigningKey { public_key: identity.public_key() },
|
||||
rebind_from: None,
|
||||
}
|
||||
}
|
||||
|
||||
+6
-25
@@ -106,8 +106,6 @@ pub struct SignerConfig {
|
||||
pub device_keys: Keys,
|
||||
/// Identity keys, resolved per request.
|
||||
pub keys: IdentityKeys,
|
||||
/// Display names for the identity keys (hex → name), kept fresh by the UI.
|
||||
pub names: Arc<Mutex<HashMap<String, String>>>,
|
||||
/// The identity a **new** pairing is bound to. Shared with the UI; the
|
||||
/// responder only reads it in `connect`. It is never consulted for an
|
||||
/// existing app — that comes from the registry.
|
||||
@@ -145,7 +143,6 @@ impl SignerConfig {
|
||||
auto_approve_limit: Arc<AtomicU32>,
|
||||
activity: ActivityLog,
|
||||
changes: async_channel::Sender<()>,
|
||||
names: Arc<Mutex<HashMap<String, String>>>,
|
||||
default_identity: Arc<Mutex<Option<PublicKey>>>,
|
||||
) -> Result<Self> {
|
||||
let device_keys = store.device_key()?;
|
||||
@@ -154,7 +151,6 @@ impl SignerConfig {
|
||||
Ok(Self {
|
||||
device_keys,
|
||||
keys: IdentityKeys::Store(store),
|
||||
names,
|
||||
default_identity,
|
||||
relays,
|
||||
secret: Arc::new(Mutex::new(secret)),
|
||||
@@ -186,15 +182,10 @@ async fn pairing_identity(config: &SignerConfig) -> Result<PublicKey> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`SigningKey`] for display, with the name if the UI has one.
|
||||
fn signing_key(config: &SignerConfig, public_key: PublicKey) -> SigningKey {
|
||||
let name = config
|
||||
.names
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&public_key.to_hex())
|
||||
.cloned();
|
||||
SigningKey { public_key, name }
|
||||
/// The [`SigningKey`] a request would act as. Display-only: the name is
|
||||
/// resolved on the UI side, from the single display rule.
|
||||
fn signing_key(public_key: PublicKey) -> SigningKey {
|
||||
SigningKey { public_key }
|
||||
}
|
||||
|
||||
/// The identity a client is bound to. Read from the registry, never from the
|
||||
@@ -911,7 +902,7 @@ async fn handle_request(event: &Event, config: &SignerConfig) -> Result<Option<E
|
||||
// client-initiated `nostrconnect://` path).
|
||||
relays: Vec::new(),
|
||||
},
|
||||
identity: signing_key(config, identity),
|
||||
identity: signing_key(identity),
|
||||
rebind_from,
|
||||
};
|
||||
let answer = config.approver.ask(question).await;
|
||||
@@ -1160,7 +1151,7 @@ async fn gate(
|
||||
let question = Question {
|
||||
client: client.clone(),
|
||||
request,
|
||||
identity: signing_key(config, identity),
|
||||
identity: signing_key(identity),
|
||||
rebind_from: None,
|
||||
};
|
||||
let answer = config.approver.ask(question).await;
|
||||
@@ -1761,17 +1752,12 @@ mod tests {
|
||||
) -> SignerConfig {
|
||||
let identity = Keys::generate();
|
||||
let identity_public = identity.public_key();
|
||||
let names = Arc::new(Mutex::new(HashMap::from([(
|
||||
identity_public.to_hex(),
|
||||
"Test identity".to_string(),
|
||||
)])));
|
||||
let device_keys = Keys::generate();
|
||||
let relays = vec![relay.to_string()];
|
||||
let (secret, uri) = test_secret(&device_keys, &relays, "test-secret");
|
||||
SignerConfig {
|
||||
device_keys,
|
||||
keys: IdentityKeys::Fixed(identity),
|
||||
names,
|
||||
default_identity: Arc::new(Mutex::new(Some(identity_public))),
|
||||
relays,
|
||||
secret,
|
||||
@@ -2189,17 +2175,12 @@ mod tests {
|
||||
activity: ActivityLog,
|
||||
) -> SignerConfig {
|
||||
let (changes, _receiver) = async_channel::unbounded();
|
||||
let names = Arc::new(Mutex::new(HashMap::from([(
|
||||
identity.to_hex(),
|
||||
"Test identity".to_string(),
|
||||
)])));
|
||||
let device_keys = Keys::generate();
|
||||
let relays = vec![relay.to_string()];
|
||||
let (secret, uri) = test_secret(&device_keys, &relays, "test-secret");
|
||||
SignerConfig {
|
||||
device_keys,
|
||||
keys: IdentityKeys::Store(store),
|
||||
names,
|
||||
default_identity: Arc::new(Mutex::new(Some(identity))),
|
||||
relays,
|
||||
secret,
|
||||
|
||||
+4
-2
@@ -55,7 +55,8 @@ pub struct AppState {
|
||||
/// pairings only — an approved app keeps the identity stored in the
|
||||
/// registry.
|
||||
current: Arc<Mutex<Option<PublicKey>>>,
|
||||
/// Display names for the identity keys (hex → name), kept for dialogs.
|
||||
/// The vault label for each identity key (hex → name). Display goes through
|
||||
/// [`Self::identity_label`]; this is the raw label the user typed.
|
||||
names: Arc<Mutex<HashMap<String, String>>>,
|
||||
/// Cached kind-0 display names, read-only.
|
||||
profiles: Profiles,
|
||||
@@ -256,7 +257,8 @@ impl AppState {
|
||||
Arc::clone(&self.current)
|
||||
}
|
||||
|
||||
/// Key display names (hex → name), for approval dialogs.
|
||||
/// The vault label for each identity key (hex → name). Display belongs to
|
||||
/// [`Self::identity_label`].
|
||||
pub fn names(&self) -> Arc<Mutex<HashMap<String, String>>> {
|
||||
Arc::clone(&self.names)
|
||||
}
|
||||
|
||||
+10
-6
@@ -108,11 +108,13 @@ profiles and avatars, and NIP-05 verification.
|
||||
non-match — an unreachable domain leaves the confirmed one in place. Removing a
|
||||
key clears it as current, revokes the apps bound to it (the dialog names them),
|
||||
and deletes the item.
|
||||
- The identity is shown as **"Signing as {name}"** with the npub beneath it, not
|
||||
as `{name} ({npub})`: in the approval dialog it is a stacked field (optionally
|
||||
the npub alone when the key has no name), in the Connect dialog and the Apps
|
||||
page it is an `AdwActionRow` title plus subtitle. In-app pairing uses the
|
||||
current identity and warns when it would rebind an existing app.
|
||||
- The identity is shown as **"Signing as {name}"**, not as `{name} ({npub})`: in
|
||||
the Connect dialog and the Apps page the npub sits beneath as an
|
||||
`AdwActionRow` subtitle; in the approval dialog the name is a stacked field and
|
||||
the npub rides as its tooltip. Every surface resolves the name through
|
||||
`identity_label` (below), so none can drift onto a vault-only label. In-app
|
||||
pairing uses the current identity and warns when it would rebind an existing
|
||||
app.
|
||||
- Headless: `--headless`/`--pair` take **`--key <npub|hex>`** (default: the
|
||||
current identity). Serving resolves per app, so headless needs no single
|
||||
"active" key.
|
||||
@@ -241,7 +243,9 @@ profiles and avatars, and NIP-05 verification.
|
||||
- The fetch uses a fresh **ephemeral** client, never the device/identity key, so
|
||||
a relay cannot link an identity to this signer.
|
||||
- `AppState::identity_label` is the single display rule: profile `display_name`
|
||||
first, else the user's key label.
|
||||
first, else the user's key label. Every "Signing as" surface goes through it —
|
||||
the switcher, the Apps page, the Connect dialog and the approval dialog — so no
|
||||
surface can drift onto a vault-only name.
|
||||
- **One key style, two cuts.** Every `npub`/hex/`bunker://` value is shown in the
|
||||
monospace font at the size the label already has, through our `.key-value`
|
||||
class (`plain::key` for labels we build, `plain::key_row` for a row whose
|
||||
|
||||
+3
-3
@@ -206,9 +206,9 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
|
||||
|
||||
14. A shortened subtitle hides the full value, so carry it as a plain
|
||||
`tooltip_text` (never `tooltip_markup` — it is still attacker-supplied text
|
||||
for a client key). The approval dialog's "Signing as" shows only the key's
|
||||
name, with the full npub as its tooltip (a signing key always has a name).
|
||||
The identities window still offers "Copy public key".
|
||||
for a client key). The approval dialog's "Signing as" shows only the identity's
|
||||
display name (`AppState::identity_label`, the one rule), with the full npub as
|
||||
its tooltip. The identities window still offers "Copy public key".
|
||||
`AdwExpanderRow` is not an `AdwActionRow`, but that no longer matters: its
|
||||
byline is shortened like any other subtitle instead of reaching into the
|
||||
label to change its ellipsis mode.
|
||||
|
||||
+9
-16
@@ -660,20 +660,18 @@ fn more_details(question: &Question) -> gtk::ListBox {
|
||||
list
|
||||
}
|
||||
|
||||
/// The identity a request would act as: the key's name, with its npub as a
|
||||
/// tooltip. The name is what the user recognises; the npub is long and rarely
|
||||
/// read, so it stays out of the way (the identities window still offers
|
||||
/// "Copy public key").
|
||||
/// The identity a request would act as: the name the app knows it by, with its
|
||||
/// npub as a tooltip. The name comes from the single display rule
|
||||
/// ([`AppState::identity_label`] — the fetched profile `display_name`, else the
|
||||
/// user's key label), so this row always agrees with the switcher; the npub is
|
||||
/// long and rarely read, so it stays out of the way (the identities window still
|
||||
/// offers "Copy public key").
|
||||
fn identity_field(state: &Rc<AppState>, identity: &crate::signer::approval::SigningKey) -> gtk::Box {
|
||||
let npub = identity
|
||||
.public_key
|
||||
.to_bech32()
|
||||
.unwrap_or_else(|_| identity.public_key.to_hex());
|
||||
let name = identity
|
||||
.name
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|name| !name.is_empty());
|
||||
let name = state.identity_label(&identity.public_key);
|
||||
|
||||
let row = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
@@ -685,7 +683,7 @@ fn identity_field(state: &Rc<AppState>, identity: &crate::signer::approval::Sign
|
||||
// ever ran, so a missing texture is swapped in when it lands.
|
||||
let hex = identity.public_key.to_hex();
|
||||
let texture = state.icons().texture(&hex);
|
||||
let avatar = plain::avatar(32, name, texture.as_ref());
|
||||
let avatar = plain::avatar(32, Some(name.as_str()), texture.as_ref());
|
||||
if texture.is_none()
|
||||
&& let Some(picture) = state.profiles().picture(&identity.public_key)
|
||||
&& crate::store::icons::is_fetchable(&picture)
|
||||
@@ -695,12 +693,7 @@ fn identity_field(state: &Rc<AppState>, identity: &crate::signer::approval::Sign
|
||||
avatar.set_custom_image(Some(&texture));
|
||||
});
|
||||
}
|
||||
// A signing key always has a name; the shortened npub is only a fallback
|
||||
// for a key that somehow does not.
|
||||
let value = match name {
|
||||
Some(name) => plain::label(name),
|
||||
None => plain::key(&plain::shorten_npub(&npub)),
|
||||
};
|
||||
let value = plain::label(&name);
|
||||
value.set_hexpand(true);
|
||||
value.set_tooltip_text(Some(&npub));
|
||||
row.append(&avatar);
|
||||
|
||||
+1
-11
@@ -381,13 +381,6 @@ impl ConnectDialog {
|
||||
);
|
||||
return;
|
||||
};
|
||||
let name = self
|
||||
.state
|
||||
.names()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&identity.to_hex())
|
||||
.cloned();
|
||||
let rebind_from = self
|
||||
.state
|
||||
.registry()
|
||||
@@ -406,10 +399,7 @@ impl ConnectDialog {
|
||||
.map(|relay| relay.to_string())
|
||||
.collect(),
|
||||
},
|
||||
identity: SigningKey {
|
||||
public_key: identity,
|
||||
name,
|
||||
},
|
||||
identity: SigningKey { public_key: identity },
|
||||
rebind_from,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user