Document the notification backend and desktop file traps in AGENTS.md
This commit is contained in:
1 file changed
+58
-19
@@ -139,6 +139,22 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
- The unlock retry loop shares one deadline across passphrase attempts — a wrong
|
||||
passphrase must not buy the request more time — and reports it in the dialog
|
||||
body rather than stacking a second error dialog.
|
||||
- **Which interface is used depends on the machine, and the gtk one is strict.**
|
||||
GLib picks its backend by priority: `org.gtk.Notifications` (100) whenever that
|
||||
name is owned — every real GNOME session — else `org.freedesktop.Notifications`
|
||||
(0). **The gtk path refuses the notification unless GNOME Shell can resolve
|
||||
`<app id>.desktop` in its app index**, and its D-Bus call passes no error
|
||||
callback, so a refusal is *completely silent*: no banner, no stderr, no trace.
|
||||
`warn_if_the_desktop_is_missing()` in `application.rs` is the only place that
|
||||
failure can be made visible. Note that the freedesktop backend *does* log a
|
||||
warning — so "no warning in stderr" does **not** mean "no notification was
|
||||
attempted".
|
||||
- **GIO drops a desktop file whose `Exec` does not resolve.** It validates `Exec`
|
||||
while parsing and discards the whole file, so the app never enters the index and
|
||||
every notification is refused. That is why `regent-deploy` rewrites the
|
||||
installed copy's `Exec` to the absolute `~/.local/bin/regent`: a session's PATH
|
||||
(a systemd user session gets `/usr/local/bin:/usr/bin`) has no `~/.local/bin`,
|
||||
while the packaged `Exec=regent` is correct for a `/usr` install.
|
||||
- `connect_activate` is **idempotent**: it presents the existing window instead of
|
||||
building another. Activation arrives for a notification click and for launching
|
||||
`regent` again, and a second window would share the state and show the same
|
||||
@@ -428,20 +444,26 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
|
||||
text (`plain` does this). Symptom: a row renders empty and GTK logs "Failed to
|
||||
set text … from markup".
|
||||
|
||||
8. `GApplication::send_notification` speaks the **freedesktop**
|
||||
`org.freedesktop.Notifications` interface directly (not `org.gtk.Notifications`,
|
||||
which is the portal path): `Notify` arrives with `app_name`, `summary`, `body`,
|
||||
`actions = ["default", ""]` when a default action is set, and hints
|
||||
`desktop-entry` (the app id) and `urgency` (0/1/2 for Low/Normal/High). The
|
||||
action **name** is not transmitted; on a body click GNOME Shell emits
|
||||
`ActionInvoked(id, "default")` and GLib activates the app's default action
|
||||
in-process. `withdraw_notification` becomes `CloseNotification(id)`. All of it
|
||||
is fire-and-forget: with no notification daemon on the bus it logs one
|
||||
`GLib-GIO-WARNING` and carries on.
|
||||
8. `GApplication::send_notification` has **two** backends, chosen by priority:
|
||||
`org.gtk.Notifications` (100 — used whenever the name is owned, i.e. on any
|
||||
real GNOME session) and `org.freedesktop.Notifications` (0 — the fallback).
|
||||
The gtk payload is `AddNotification(app_id, id, a{sv})` carrying `title`,
|
||||
`body`, `icon`, `priority` (`low`/`normal`/`high`/`urgent`) and
|
||||
`default-action`; the freedesktop one is the classic `Notify(...)` with
|
||||
`actions = ["default", ""]` and `desktop-entry`/`urgency` hints. **Only the
|
||||
gtk path requires GNOME Shell to resolve `<app id>.desktop`, and it discards
|
||||
every error** (the freedesktop backend logs a warning instead) — so on a real
|
||||
desktop a bad desktop file means notifications silently never appear.
|
||||
`withdraw_notification` becomes `RemoveNotification` / `CloseNotification`.
|
||||
9. `gtk4-broadwayd` has **no window manager**, so `GtkWindow::is_active()` is
|
||||
`true` for a window nothing ever focused. Any "is the user looking at this"
|
||||
branch is therefore untestable under Broadway without a forced override — and
|
||||
`GdkToplevel::state()` is empty there too.
|
||||
10. **GIO validates `Exec` while parsing a desktop file and drops the file when
|
||||
the program cannot be found** (`g_find_program_for_path` returns NULL →
|
||||
`goto error`). The app then never appears in `Gio.AppInfo::all()`, GNOME Shell
|
||||
cannot resolve it, and every notification from it is refused — silently. A
|
||||
desktop file for anything installed outside `PATH` needs an absolute `Exec`.
|
||||
|
||||
## Blueprint / Meson traps
|
||||
|
||||
@@ -473,6 +495,13 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
|
||||
them and warns. If they drift, update both before debugging anything else.
|
||||
- `--pkg` builds `build-aux/regent-git/PKGBUILD`, which packages the working
|
||||
tree and is a preview of the real release packaging.
|
||||
- The install tree is `/usr`-rooted, so its desktop file says `Exec=regent`.
|
||||
`regent-deploy` rewrites the copy it installs to the absolute
|
||||
`~/.local/bin/regent`, because GIO **drops a desktop file whose `Exec` does not
|
||||
resolve on the session's PATH** — and GNOME Shell then refuses every
|
||||
notification from the app, silently (see the notification section). It checks
|
||||
the result and warns if the shell still cannot resolve the app. The packaged
|
||||
file is left alone: `/usr/bin` is on PATH.
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -519,15 +548,25 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
|
||||
waiting prompt raises a notification. Needs `nak`, `gtk4-broadwayd`, `python3`
|
||||
with `dbus-python` (for `build-aux/notify-stub.py`), and a D-Bus session for
|
||||
the GUI part.
|
||||
- The notification check stands a stub `org.freedesktop.Notifications`
|
||||
(`build-aux/notify-stub.py`) in for the desktop: it logs every `Notify` to
|
||||
`$NOTIFY_LOG` and simulates a click by emitting `ActionInvoked`, which is what
|
||||
GNOME Shell does on a body click. Two gotchas live there: `dbus.service.BusName`
|
||||
must be kept referenced (dbus-python releases the name when it is collected),
|
||||
and `str()` on a `dbus.Byte` is the raw character, so the stub renders numbers
|
||||
as numbers. The request itself is hand-built — an approved client is seeded in
|
||||
`apps.json` and `nak encrypt` + `nak event` publish the `kind:24133` request,
|
||||
because the app's pairing secret is deliberately unobservable.
|
||||
- The notification checks stand a stub (`build-aux/notify-stub.py`) in for the
|
||||
desktop. It owns **both** notification names, so GLib takes the `gtk` path a
|
||||
real GNOME session uses — owning only the freedesktop name would exercise the
|
||||
fallback and miss exactly the behaviour that broke on a real desktop. It logs
|
||||
every call to `$NOTIFY_LOG` and simulates a click the way each backend expects:
|
||||
`ActivateAction("focus")` on the app for the gtk path (what GNOME Shell does),
|
||||
an `ActionInvoked` signal for freedesktop. Gotchas there: `dbus.service.BusName`
|
||||
and the service objects must be kept referenced (dbus-python releases a name
|
||||
and unregisters an object when it is collected), **one object cannot be
|
||||
exported at two paths** (`add_to_connection` raises, so each interface needs
|
||||
its own class), and `str()` on a `dbus.Byte` is the raw character. The request
|
||||
itself is hand-built — an approved client is seeded in `apps.json` and
|
||||
`nak encrypt` + `nak event` publish the `kind:24133` request, because the app's
|
||||
pairing secret is deliberately unobservable.
|
||||
- Two more checks cover the desktop file GNOME has to find: the shipped file is
|
||||
installed the way `regent-deploy` installs it and `Gio.AppInfo` must index it,
|
||||
and a copy with an unresolvable `Exec` must be dropped — the failure that made
|
||||
notifications vanish on a real desktop. The app is also asserted **not** to
|
||||
print its "GNOME cannot resolve …" warning.
|
||||
- Loopback with no public relays and no display:
|
||||
- `nak serve --port 10547` = writable in-memory relay.
|
||||
- `nak --sec 'bunker://…' …` = independent NIP-46 *client*.
|
||||
|
||||
Reference in new issue
Block a user