Skip to content

Keep clicking a notification working after a shell restart - #6636

Merged
dhh merged 3 commits into
quattrofrom
persist-notification-actions
Aug 9, 2026
Merged

dhh merged 3 commits into
quattrofrom
persist-notification-actions

Conversation

@dhh

@dhh dhh commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Notifications with actions stopped working once they were restored after a shell restart — clicking the voxtype or keybindings invitation did nothing.

The action lived only in the sending process. omarchy-notification-send -a appended -A default=default, so notify-send blocked waiting for a D-Bus ActionInvoked signal and the caller ran the command when it arrived. None of that reached disk, so a restored row had no action to run — and it can't be recovered over D-Bus either, since the new server hands out ids from 1 again and cannot emit ActionInvoked for the dead generation's id. invokePopupDefault then fell through to focusing omarchy-action (a no-op), while the original notify-send stayed blocked forever.

So the action becomes data that persists alongside the popup. --exec <command> replaces -a: it travels as an omarchy-exec hint into the snapshot's exec role, through the popup files and history, and the shell runs it on click via Util.execDetached. Restored toasts now behave exactly like live ones, and the sender exits immediately instead of blocking until the click.

That let a lot of scaffolding go, all of which existed only to keep a blocked sender alive:

  • both first-run invitations lose their --show re-entry and two systemd-run transient units each
  • omarchy-migrate-notify loses its transient service, so the oneshot no longer stays activated waiting for an answer
  • the screenshot, recording, download, and taildrop toasts lose their wrapper subshells, and omarchy-tailscale-receive no longer backgrounds each announcement

Usage

omarchy-notification-send -u critical -g 󰋼 "Learn Keybindings" "Super + K for cheatsheet." \
  --exec omarchy-menu-keybindings

Interpolate paths with printf %q, since the shell runs the command through bash -lc:

omarchy-notification-send "Received $name" --exec "$(printf 'xdg-open %q' "$path")"

Breaking

-a / --action is removed. Every call site was in this repo, and the flag was Omarchy's own invention, but a user script passing -a will now fail on the missing value. Passing -A default=default straight through to notify-send still works for anyone who wants the libnotify round-trip.

Note

The shell now executes a command string carried in a D-Bus hint. That's no privilege escalation — the sender already runs as the user — but a sandboxed app with notification-portal access could get the host shell to run a command if the user clicks its toast. QML has no access to the D-Bus sender, so there's no way to restrict the hint to trusted senders.

— 🤖 Claude, posting on behalf of @dhh

Notification actions lived only in the sending process: `-a` appended
`-A default=default`, so notify-send blocked on a D-Bus ActionInvoked signal and
the caller ran the command when it arrived. Nothing about that reached disk, so a
restored popup had no action to run and its sender stayed blocked forever.

Replace `-a` with `--exec <command>`, carried as an `omarchy-exec` hint into the
snapshot's `exec` role. It travels through the popup files and history, and the
shell runs it on click, so restored toasts behave exactly like live ones and the
sender exits immediately.

That drops the scaffolding whose only job was keeping a blocked sender alive: the
first-run invitations lose their `--show` re-entry and two transient units each,
omarchy-migrate-notify loses its transient service, and the screenshot,
recording, download, and taildrop toasts lose their wrapper subshells.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 8, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Persists notification click commands so actions survive shell restarts and senders no longer block awaiting D-Bus responses.

Changes:

  • Adds --exec command hints and shell-side execution.
  • Migrates actionable notifications away from libnotify actions.
  • Updates notification persistence and tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 12 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
bin/omarchy-notification-send Adds --exec hint support.
shell/plugins/notifications/NotificationLogic.js Persists click commands.
shell/plugins/notifications/Service.qml Executes persisted commands.
bin/omarchy-migrate-notify Removes transient notification service.
bin/omarchy-tailscale-receive Attaches file-opening commands.
bin/omarchy-chromium-ytdlp-host Attaches video action and delayed cleanup.
bin/omarchy-capture-screenshot Attaches editor action.
bin/omarchy-capture-screenrecording Attaches playback action and cleanup.
install/user/first-run/wifi.sh Migrates setup notification actions.
install/user/first-run/welcome.sh Migrates keybindings invitation.
install/user/first-run/setup-fingerprint.hook Simplifies fingerprint invitation.
install/user/first-run/install-voxtype.hook Simplifies Voxtype invitation.
test/shell.d/notification-send-test.sh Tests --exec parsing.
test/shell.d/notifications-test.sh Tests command persistence.
test/shell.d/migrate-notify-test.sh Tests direct notification handoff.
test/shell.d/tailscale-receive-test.sh Tests quoted open commands.
test/shell.d/fingerprint-invitation-test.sh Tests persisted setup action.
test/shell.d/voxtype-invitation-test.sh Tests persisted installer action.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if (command) {
// Detached so the launched command outlives the shell process, which the
// installer toasts depend on: they restart the shell as their first act.
Util.execDetached(command)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagged in the PR body as a known property of the design, so this is a fair callout — but the proposed mitigation is harder than it looks, and I'd rather be explicit about why it isn't in this PR.

An opaque handle only helps if the registry backing it is somewhere a sandboxed app can't write:

  • $XDG_RUNTIME_DIR is the one place flatpak genuinely can't reach (it gets a private runtime dir, so it can't touch the shell's IPC socket either). But it doesn't survive a reboot, and these invitations are -u critical → duration 0 → they persist indefinitely on purpose. A runtime-dir handle would leave the click dead after a reboot, which is the exact bug this PR fixes.
  • ~/.local/state survives reboots but weakens the authentication, since flatpaks commonly hold --filesystem=home and could write the registry directly.
  • Whitelisting omarchy-* commands isn't a boundary at all: omarchy-launch-floating-terminal-with-presentation <cmd> runs arbitrary commands, so it's still a full escape.

On the exposure itself: the attack needs a malicious app and a user click, and only pays off inside a sandbox — a native package already runs with full user privileges, so it gains nothing from the hint. Flatpak isn't in Omarchy's default package set either; it appears only as an opt-in path (GeForce NOW, LocalSend detection).

The honest version of your suggestion is a handle registered over the shell's own IPC socket and persisted to a shell-owned file in the state dir. That does raise the bar for sandboxes without home access, at the cost of a registry lifecycle (GC on dismiss/expire, and leaked entries whenever DND suppresses a toast). Worth doing as a follow-up if Omarchy wants to treat sandboxed senders as untrusted, but it's a separate change from restoring click-through, and it shouldn't ride along on a bug fix.

— 🤖 Claude, posting on behalf of @dhh

Moving these sends out of their backgrounded subshells put a fallible command
on the foreground path, where the `&` used to swallow its exit status. A
notification outage — including the shell restart this branch targets — now
propagates:

- taildrop's receiver dies under `set -e` mid-delivery
- omarchy-capture-screenshot reports failure for a screenshot it already saved
- a completed download exits before scheduling its thumbnail cleanup, leaking
  the mktemp file

Announcing is best-effort in all three: the work is already done by the time
the toast goes out.

Also drop the first-run sleep that spaced out the welcome and Wi-Fi toasts.
It compensated for the background notify-send processes this branch removes;
each send now returns only once the server has taken the toast, so sending in
order is enough to stack them newest-on-top.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 8, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 19 changed files in this pull request and generated no new comments.

The shell loads a notification thumbnail into memory when the toast appears and
never re-reads the file, so the preview only has to outlive that load. Deriving
the cleanup delay from the expiry was false precision, and it turned -t into a
variable for no reason: -t is already the helper's expiry setting.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 9, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 19 changed files in this pull request and generated no new comments.

@dhh
dhh merged commit 5a58f79 into quattro Aug 9, 2026
4 checks passed
@dhh
dhh deleted the persist-notification-actions branch August 9, 2026 10:33
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
* Keep clicking a notification working after a shell restart

Notification actions lived only in the sending process: `-a` appended
`-A default=default`, so notify-send blocked on a D-Bus ActionInvoked signal and
the caller ran the command when it arrived. Nothing about that reached disk, so a
restored popup had no action to run and its sender stayed blocked forever.

Replace `-a` with `--exec <command>`, carried as an `omarchy-exec` hint into the
snapshot's `exec` role. It travels through the popup files and history, and the
shell runs it on click, so restored toasts behave exactly like live ones and the
sender exits immediately.

That drops the scaffolding whose only job was keeping a blocked sender alive: the
first-run invitations lose their `--show` re-entry and two transient units each,
omarchy-migrate-notify loses its transient service, and the screenshot,
recording, download, and taildrop toasts lose their wrapper subshells.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Keep a failed toast from failing the work it announces

Moving these sends out of their backgrounded subshells put a fallible command
on the foreground path, where the `&` used to swallow its exit status. A
notification outage — including the shell restart this branch targets — now
propagates:

- taildrop's receiver dies under `set -e` mid-delivery
- omarchy-capture-screenshot reports failure for a screenshot it already saved
- a completed download exits before scheduling its thumbnail cleanup, leaking
  the mktemp file

Announcing is best-effort in all three: the work is already done by the time
the toast goes out.

Also drop the first-run sleep that spaced out the welcome and Wi-Fi toasts.
It compensated for the background notify-send processes this branch removes;
each send now returns only once the server has taken the toast, so sending in
order is enough to stack them newest-on-top.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Stop tying the preview cleanup to the toast's expiry

The shell loads a notification thumbnail into memory when the toast appears and
never re-reads the file, so the preview only has to outlive that load. Deriving
the cleanup delay from the expiry was false precision, and it turned -t into a
variable for no reason: -t is already the helper's expiry setting.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants