Show the signing identity as a name over its npub

Everywhere the identity was rendered as "Signing as" + "{name} ({npub})",
the name now sits on the Signing as line and the npub drops beneath it,
without parentheses. The name is what the user recognises, so it leads.

The approval dialog stacks the two plain labels in the value column; the
Connect dialog and the Apps page use an AdwActionRow's title and subtitle.
No colour or size changes: the npub keeps the text style it already had.
This commit is contained in:
raucao committed 2026-11-25 17:37:22 +04:00
1 parent 015c312098
commit fdc29a3b9f
4 files changed
+57 -26

No files matched your search

+5 -2
View File
@@ -287,8 +287,11 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
- Identities window: list, **Add/Import**, per-key **Rename / Copy / Export /
Remove**, and **Use for new pairings**. Removing a key clears it as current,
revokes the apps bound to it (the dialog names them), and deletes the item.
- Approval dialogs show **"Signing as: {name} ({npub})"**; in-app pairing uses
the current identity and warns when it would rebind an existing app.
- 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.
- Headless: `--headless`/`--pair` take **`--key <npub|hex>`** (default: the
current identity). Serving resolves per app, so headless needs no single
"active" key.
+30 -10
View File
@@ -428,7 +428,7 @@ fn details(question: &Question) -> gtk::Box {
.spacing(10)
.build();
content.append(&field("Signing as", &describe_key(&question.identity)));
content.append(&identity_field(&question.identity));
content.append(&field(
"Application",
client.name.as_deref().unwrap_or("(unnamed)"),
@@ -492,20 +492,41 @@ fn details(question: &Question) -> gtk::Box {
content
}
/// The identity a request would act as: its label and npub.
fn describe_key(key: &crate::signer::approval::SigningKey) -> String {
let npub = key
/// The identity a request would act as: the name on the "Signing as" line, and
/// the npub beneath it. The name is what the user recognises, so it leads; when
/// there is none only the npub is shown.
fn identity_field(identity: &crate::signer::approval::SigningKey) -> gtk::Box {
let npub = identity
.public_key
.to_bech32()
.unwrap_or_else(|_| key.public_key.to_hex());
match &key.name {
Some(name) if !name.trim().is_empty() => format!("{name} ({npub})"),
_ => npub,
.unwrap_or_else(|_| identity.public_key.to_hex());
let value = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.spacing(2)
.build();
let name = identity
.name
.as_deref()
.map(str::trim)
.filter(|name| !name.is_empty());
match name {
Some(name) => {
value.append(&plain(name));
value.append(&plain(&npub));
}
None => value.append(&plain(&npub)),
}
field_widget("Signing as", &value)
}
/// A label/value row. Both halves are plain and selectable.
fn field(title: &str, value: &str) -> gtk::Box {
field_widget(title, &plain(value))
}
/// [`field`] with an arbitrary value widget, e.g. one that stacks the name and
/// the npub.
fn field_widget(title: &str, value: &impl IsA<gtk::Widget>) -> gtk::Box {
let row = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.spacing(12)
@@ -517,10 +538,9 @@ fn field(title: &str, value: &str) -> gtk::Box {
.width_chars(12)
.css_classes(["dim-label"])
.build();
let value = plain(value);
value.set_hexpand(true);
row.append(&title);
row.append(&value);
row.append(value);
row
}
+10 -7
View File
@@ -238,14 +238,17 @@ impl Ui {
// Which identity this app signs as. This is the binding the responder
// resolves per request.
let bound = PublicKey::parse(&app.identity).ok();
let signing_as = match bound {
Some(identity) => {
let key_npub = identity.to_bech32().unwrap_or_else(|_| identity.to_hex());
format!("{} ({key_npub})", self.state.identity_label(&identity))
}
None => "unknown (paired before identities existed)".to_string(),
let (signing_as, signing_npub) = match bound {
Some(identity) => (
format!("Signing as {}", self.state.identity_label(&identity)),
identity.to_bech32().unwrap_or_else(|_| identity.to_hex()),
),
None => (
"Signing as unknown".to_string(),
"paired before identities existed".to_string(),
),
};
row.add_row(&plain::row("Signing as", &signing_as));
row.add_row(&plain::row(&signing_as, &signing_npub));
if app.policy.kinds.is_empty() && app.policy.methods.is_empty() {
row.add_row(&plain::row(
+12 -7
View File
@@ -241,17 +241,22 @@ impl ConnectDialog {
fn refresh(&self) {
let has_keys = self.state.has_keys();
let description = match self.state.current_identity() {
// The name leads on the row's title and the npub sits beneath it; there
// is no identity yet, so there is no name to show.
match self.state.current_identity() {
Some(identity) => {
let npub = identity.to_bech32().unwrap_or_else(|_| identity.to_hex());
format!(
"{} ({npub})",
self.signing_as.set_title(&format!(
"Signing as {}",
self.state.identity_label(&identity)
)
));
self.signing_as.set_subtitle(&npub);
}
None => "Add an identity key first.".to_string(),
};
self.signing_as.set_subtitle(&description);
None => {
self.signing_as.set_title("Signing as");
self.signing_as.set_subtitle("Add an identity key first.");
}
}
match self.runner.status() {
Status::Stopped => {