Keep the nostrconnect:// handler on the stable build

With both builds installed, both desktop files claimed
`x-scheme-handler/nostrconnect`, and the nightly deploy left the default
unset — so which app opened a link was decided by GIO's handler order, and
the nightly (whose vault has its own, often empty, identity) could end up
receiving links it could not pair.

The nightly desktop file no longer declares the scheme: system
integrations belong to the installed release. The nightly still accepts a
`nostrconnect://` argument (`HANDLES_OPEN`) and pairs through "Connect an
app…", it is just never the default handler.

GIO keeps honouring a `mimeapps.list` default even after the desktop file
stops claiming the scheme (verified), so `regent-deploy` also hands a stale
nightly association back by dropping the entry, leaving the stable build as
the only remaining handler.

Fix the second half too: a link-opened pairing presents no "Connect an app"
dialog, so `ConnectDialog::report_error` was parenting its alert to that
never-presented dialog (`self.window()` is `None`), and any failure — a bad
URI, or a build with no identity key — was silent. It now falls back to
`Windows::visible_parent()`, like every other pointer route.
This commit is contained in:
raucao committed 2026-11-28 14:24:34 +04:00
1 parent 5ff4d5d0f0
commit a8dd45b890
7 files changed
+80 -19

No files matched your search

+16 -2
View File
@@ -439,6 +439,13 @@ data/ desktop, metainfo, gschema (all `.in` templates), icons, re
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.
- **Opening a `nostrconnect://` link pairs straight away**, over the window the app
is (`Windows::pair_uri`), without opening the "Connect an app" dialog — so its
errors must not be parented to *that* dialog, which is never presented on this
path. `ConnectDialog::report_error` therefore falls back to
`Windows::visible_parent()`; otherwise a bad URI, or a build with no identity
key (as a fresh nightly has), would fail silently. Only the stable build is the
system's `nostrconnect://` handler (see the dev deploy section).
- **The other direction needs no Start button.** "Show Regent's code" is gated on
a running signer — the `bunker://` URI only exists while it listens — so
expanding that row starts the signer if it is stopped. That is why the dialog
@@ -807,8 +814,15 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
- **Stable vs nightly**: `REGENT_PROFILE=development regent-deploy` installs the
`.Devel` identity — `regent-devel` in `~/.local/bin`, its own desktop file, data
dirs and D-Bus name — so it runs *beside* a stable `/usr` install instead of
replacing it. It deliberately leaves the `nostrconnect://` scheme handler to the
stable build. The default profile is stable.
replacing it. The default profile is stable.
- **Only the stable build registers `x-scheme-handler/nostrconnect`.** The nightly
desktop file deliberately omits `MimeType` — system integrations belong to the
installed release — though the nightly still accepts a `nostrconnect://`
argument (`HANDLES_OPEN`). Two desktop files claiming one scheme makes which app
opens a link nondeterministic, so the dev deploy also *repairs* the association:
GIO keeps honouring a `mimeapps.list` default even after the desktop file stops
claiming the scheme, so `repair_scheme_handler` drops a stale nightly entry and
GIO falls back to the stable build.
- The two machines must agree on GTK/libadwaita versions; the wrapper compares
them and warns. If they drift, update both before debugging anything else.
- `--pkg` builds `build-aux/regent-git/PKGBUILD`, which packages the working
+2 -1
View File
@@ -127,7 +127,8 @@ GSettings schema, and prints the version it installed. `REGENT_DEPLOY_PKG=1
regent-deploy` builds and installs a real `regent-git` package instead (asks for
`sudo`). `REGENT_PROFILE=development regent-deploy` installs the nightly identity
instead — `regent-devel`, its own desktop file and data directories — so it runs
beside a stable install rather than replacing it.
beside a stable install rather than replacing it. Only the stable build handles
`nostrconnect://` links; the nightly never takes that association over.
Directly on the build host, without a workstation:
+34 -3
View File
@@ -175,6 +175,36 @@ set_scheme_handler() {
fi
}
# The nightly does not declare `x-scheme-handler/nostrconnect`, so it must not be
# the default handler either. GIO still honours a stale default in mimeapps.list
# even after the desktop file stops claiming the scheme, so a nightly that used to
# own the scheme would keep receiving links (and, with its own empty vault, would
# have nothing to pair with). Hand the scheme back by dropping the entry, which
# leaves GIO to pick the stable build as the only remaining handler.
repair_scheme_handler() {
command -v xdg-mime >/dev/null 2>&1 || return 0
local current
current=$(xdg-mime query default x-scheme-handler/nostrconnect 2>/dev/null || true)
[ "$current" = "$APP_ID.desktop" ] || return 0
local removed= list
for list in "$HOME/.config/mimeapps.list" "$HOME/.local/share/applications/mimeapps.list"; do
[ -f "$list" ] || continue
if grep -q '^x-scheme-handler/nostrconnect=' "$list"; then
sed -i '/^x-scheme-handler\/nostrconnect=/d' "$list"
removed=1
fi
done
if [ -n "$removed" ]; then
say "handed the nostrconnect:// handler back to the stable build"
else
say "note: the nightly is still the nostrconnect:// default; reset it with:" >&2
say " xdg-mime default org.kosmos.raucao.Regent.desktop x-scheme-handler/nostrconnect" >&2
fi
}
command -v ssh >/dev/null || die "ssh not found"
command -v pkg-config >/dev/null || die "pkg-config not found"
command -v tar >/dev/null || die "tar not found"
@@ -210,10 +240,11 @@ else
update-desktop-database "$HOME/.local/share/applications" >/dev/null 2>&1 || true
fix_desktop_file
check_desktop_file
# The stable build owns the `nostrconnect://` handler; a nightly install must
# not take it over.
# The stable build owns the `nostrconnect://` scheme; the nightly does not
# declare it. A nightly install that used to be the handler leaves a stale
# association behind, which is handed back here.
if [ "$PROFILE" = development ]; then
say "nightly build: leaving the nostrconnect:// handler alone"
repair_scheme_handler
else
set_scheme_handler
fi
+11
View File
@@ -17,6 +17,17 @@ if devel
app_name = 'Regent (Nightly)'
endif
app_conf.set('name', app_name)
# Only the stable build registers the `nostrconnect://` scheme handler: system
# integrations belong to the installed release, and two desktop files claiming
# the same scheme makes which one opens a link nondeterministic. The nightly
# still accepts a `nostrconnect://` argument (it is built with `HANDLES_OPEN`);
# it is just never the default handler. The dev deploy hands a stale nightly
# association back to the stable build (see `build-aux/regent-deploy.sh`).
mime = 'MimeType=x-scheme-handler/nostrconnect;'
if devel
mime = ''
endif
app_conf.set('mime', mime)
desktop_file = configure_file(
input: 'org.kosmos.raucao.Regent.desktop.in',
+1 -1
View File
@@ -10,4 +10,4 @@ Categories=Utility;Security;
Keywords=nostr;signer;keys;nip46;nip-46;
StartupNotify=true
X-GNOME-UsesNotifications=true
MimeType=x-scheme-handler/nostrconnect;
@mime@
+13 -11
View File
@@ -348,17 +348,13 @@ impl ConnectDialog {
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}"),
);
self.report_error(&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;
@@ -405,7 +401,6 @@ impl ConnectDialog {
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 => {
@@ -419,7 +414,7 @@ impl ConnectDialog {
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),
Err(error) => after.report_error(&error),
})),
);
}
@@ -438,7 +433,6 @@ impl ConnectDialog {
let changes = self.state.changes();
let signer = Arc::clone(signer);
let connect = Rc::clone(self);
let window = self.window();
runtime::spawn(
async move {
@@ -457,7 +451,7 @@ impl ConnectDialog {
connect.dialog.force_close();
connect.show_apps();
}
Err(error) => connect.report_error(window.as_ref(), &error),
Err(error) => connect.report_error(&error),
},
);
}
@@ -496,7 +490,15 @@ impl ConnectDialog {
}
}
fn report_error(&self, window: Option<&gtk::Window>, message: &str) {
fn report_error(&self, message: &str) {
// Parent to the window the app is when the Connect dialog itself is not
// on screen: the link-opened path never presents it, so `self.window()`
// is `None` there and an alert parented to nothing would be invisible.
let parent = self.window().or_else(|| {
self.windows
.upgrade()
.and_then(|windows| windows.visible_parent())
});
let dialog = adw::AlertDialog::builder()
.heading_use_markup(false)
.body_use_markup(false)
@@ -506,7 +508,7 @@ impl ConnectDialog {
plain::dialog(&dialog);
dialog.add_response("close", "Close");
dialog.set_default_response(Some("close"));
dialog.present(window);
dialog.present(parent.as_ref());
}
fn window(&self) -> Option<gtk::Window> {
+3 -1
View File
@@ -200,7 +200,9 @@ impl Windows {
/// Needed once the main window can be hidden in the background: parenting
/// an `AdwDialog` to a hidden window makes it silently invisible, so every
/// pointer route must fall back to a window that is actually on screen.
fn visible_parent(&self) -> Option<gtk::Window> {
/// `pub(crate)` because the "Connect an app" dialog's error path needs the
/// same fallback when it is not itself on screen (a link-opened pairing).
pub(crate) fn visible_parent(&self) -> Option<gtk::Window> {
self.app
.active_window()
.or_else(|| self.primary().map(|window| window.upcast::<gtk::Window>()))