Skip to content

Linux: notifications post while the window is focused, and a click doesn't raise it #1295

Done

Description

@zce

What happens

On Fedora 45, GNOME Shell 51.1, mutter 51.1, Wayland:

  1. With the app window focused, a permission or question request still posts a system notification. features/notifications/src/lib.rs says a toast posts only while the window isn't focused.
  2. Clicking a notification while another window or workspace is active doesn't bring OpenCode forward. The click is received and the session opens, but the window stays behind.

Why

Both are Linux gaps in the helpers the notification path uses:

  • NotificationsHost::is_window_focused() defaults to rune_notify::app_focused(). On Linux that function returns false unconditionally (crates/rune-notify/src/lib.rs), so Notifier::post never takes the focused branch. poll_taskbar reads the same function, so its waiting toast notifies while focused too.
  • rune_notify::bring_to_front() is a no-op on Linux. The notification server's ActivationToken is captured in Click::activation_token(), but nothing consumes it. On Wayland a window can't take focus without that token; WindowHandle::focus() only calls request_user_attention. Rune has AppHandle::activate(token) but no per-window WindowHandle::activate(token), and a click belongs to the window that posted the toast.

Proposed fix

  • Use the window's own focus state (App::window.focused, set by the on_focus handler) for is_window_focused() and the taskbar's focused.
  • Add a NotificationsHost::activate_window(token) hook and route a click's activation_token() to the posting window's WindowHandle. The Rune side is zce/rune:linux-notify-activate @ 82ec595 (one activation commit on top of the frame commit 7824acd): WindowHandle::activate(token) sends WindowRequest::Open(Some(token)), which reaches xdg_activation_v1.activate on Wayland and X11 startup activation; no token falls back to focus().
  • Button clicks stay answer-only; only a click on the toast itself raises the window.

The Rune API request is anomalyco/rune#2445. The app patch is not a PR yet because it needs that API; I can send it once the Rune side is in.

Verification

Tested on the real GNOME above with a Fedora RPM built from the branch: while focused, no toast (including the taskbar waiting toast); after switching apps/workspaces the toast appears; clicking its body raises the window on the right session; clicking Allow/Deny answers without raising.

Activity

  1. Hona commented on Nov 27, 2026

    @Hona
    Member

    Fixed in #1394 (merged to dev at 6d7be895214723dd34cdf9e5aa8092f50349f79f).

    • Focused suppression on Linux: Tracked per-window focus from on_focus (clearing it on hide/close) and wired NotificationsHost::is_window_focused() and App::poll_taskbar() to use it on Linux while keeping rune_notify::app_focused() on macOS and Windows.
    • Raise on click on Linux: Added NotificationsHost::activate_window(token) and routed clicked notifications' Click::activation_token() to the posting window's WindowHandle::activate(token) (falling back to WindowHandle::focus() when no token is supplied), while keeping inline permission/question button clicks answer-only.

    Verification: Verified locally with pwsh scripts/guardrails.ps1 (10/10 passed), cargo check -p opencode-feature-notifications, and cargo clippy --no-deps -p opencode-feature-notifications -- -D warnings. This was not verified on live Linux Wayland/X11 desktop hardware (GNOME/mutter) or a full local apps/desktop build — please reopen if anything still misbehaves on your setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions