You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(notifications): detect Linux desktop lock and Wayland idle - #46985
Phones set to receive alerts only when the desktop is away can now receive them when Orca's Linux desktop is locked or has had no input for three minutes on supported Wayland compositors.
What Changed
Read the graphical logind session's LockedHint and report lock transitions promptly. Resolve the session by PID and use XDG_SESSION_ID for desktop launches outside the graphical session scope. A wrapper in a private process group reaps the logind monitor when its parent pipe closes.
Use the existing bundled Wayland helper to subscribe to input-only idle and resume events at 180,000 ms on single-seat compositors advertising ext_idle_notifier_v1 v2. Electron supplies initial and fallback presence.
Use the same Linux activity state for local alerts and desktop presence reports to compatible relays.
Why
On the reported niri setup, logind shows a locked session while Electron reports active and zero idle time. The away-only filter then suppresses alerts. Logind supplies lock state and the Wayland v2 input-idle protocol measures keyboard and pointer inactivity independently of display idle inhibitors.
The change is to background alert eligibility. The issue includes the before-state Electron readings. The private niri probe produced these after-state relay decisions with Electron held at active/0. Before-state report
Desktop input state
Away-only relay result
Active
Suppress
Idle
Allow
Input resumes
Suppress
Idle again
Allow
Testing
Independent review passed all 25 checks in pnpm check:changed --base=a817c50bd824 for the final logind wrapper change. On the preceding revision, the combined patch passed the 28-check gate and all five focused desktop-away tests. The implementation also ran the five focused tests on the final revision.
Independently ran the implementation's private D-Bus fixture with the production watcher and real gdbus under Bash and Ubuntu dash. Both runs verified the wrapper and monitor occupy a process group separate from the owner and checked session selection, lock transitions, parent-only SIGKILL, normal stop, cancellation during spawn, and cleanup after monitor exit.
In the preceding independent review, built the unchanged native helper with release warning and hardening flags. Seven Wayland protocol tests and the X11 clipboard fallback test on a private Xvfb display passed. The protocol tests cover the v2 input-only request, the 180,000 ms threshold, resume, parent EOF, and v1 or absent-protocol fallback.
Reran the implementation's isolated niri/Xvfb probe through Orca's relay delivery predicate in the preceding independent review. The probe verifies the production 180,000 ms argument and uses a shortened 1,200 ms timer in the private compositor. The implementation previously verified an x64 helper against the Ubuntu 20.04 glibc floor.
Full Linux packaging and arm64 execution remain unverified locally. The production build requires Docker and the local daemon is unavailable. Actual push gateway/APNs delivery to a paired iPhone still needs a separate end-to-end test.
I manually tested these changes locally
Automated tests added or updated
Added tests exercise lock transitions and the input-idle and relay-delivery invariants introduced by this change
Performance
Linux starts an event-driven logind monitor with a shell wrapper and, on supported Wayland desktops, one idle helper. The lock watcher makes bounded startup and property re-read calls. The existing relay sampling interval remains five seconds, with immediate reports on activity transitions.
Risk
Level: Medium. Linux session discovery or compositor compatibility can affect when away-only alerts are eligible. Unavailable sources fall back to Electron. The existing relay capability gate determines which remote runtimes receive presence reports. A revert restores the prior detection behavior without a data migration.
AI Disclosure
OpenAI Codex (GPT-6) assisted with implementation, independent review, and verification.
Review
An independent reviewer reproduced the monitor lifecycle issue on the earlier revision and verified the fix on this PR's head.
Agent skill upstream boundary
Not applicable
Notes
X11 clipboard regression coverage ran on a private display. The non-Linux state test exercises the macOS fallback. Windows was reviewed in code. Relay verification exercised the existing presence RPC and the away-only delivery predicate.
Checklist
This PR is focused on Linux desktop presence for away-only mobile alerts
Explained the user-facing change and rationale
Documented risk and rollback
Included behavioral evidence
Reviewed correctness, security, performance, and cross-platform/remote behavior
Local changed-files gate passed. Full builds and platform checks are for CI.
The native Wayland helper adds idle notifications and tests for idle, resume, and parent-pipe closure. Linux session-lock and Wayland-idle watchers now feed desktop-away state. Away-state changes trigger desktop presence updates. Startup supplies the helper path for Linux Wayland sessions, and the clipboard publisher uses the shared helper-path function.
Severity of issue fixed: Medium
Merge Risk: Moderate · up to f9051
On Linux AppImage installs, inherited loader paths can stop the new logind lock detection from working. The lock state is then not reported and away-only mobile alerts keep behaving as before. Passing the AppImage-cleaned environment to both logind subprocesses should be done before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main capabilities added: Linux desktop lock detection and Wayland idle detection. These match the changed files, which add logind LockedHint monitoring and a Wayland ext_idle_n…
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #41341), Visual Proof (N/A with reason and a before-state link), Testing, Performance, Risk wi…
Linked Issues check
Directly linked issue #41341 requires Linux presence detection that reports away when the session is locked, using logind LockedHint, because Electron reports active/0 on niri. The change set impl…
Out of Scope Changes check
The changes support the Linux desktop-away objective of #41341. wayland-clipboard.c adds wl_display_dispatch, a reusable get_registry helper, and a version parameter for bind. These changes ar…
Full details: Title check
Explanation
The title names the two main capabilities added: Linux desktop lock detection and Wayland idle detection. These match the changed files, which add logind LockedHint monitoring and a Wayland ext_idle_notifier_v1 idle watcher. The title follows the conventional commit style and is specific enough for a teammate scanning history.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #41341), Visual Proof (N/A with reason and a before-state link), Testing, Performance, Risk with level and rollback, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. The Testing section is long and reports many verification runs that a reviewer cannot easily follow. The Performance section is written as a description rather than the required one-line sentence. The Risk section describes rollback as a plain revert. The Visual Proof section relies on a relay-decision table that is not a UI screenshot. These points are minor. The description is mostly complete.
Full details: Linked Issues check
Explanation
Directly linked issue #41341 requires Linux presence detection that reports away when the session is locked, using logind LockedHint, because Electron reports active/0 on niri. The change set implements this requirement. src/main/notifications/linux-session-lock.ts (added) resolves the graphical session by PID, falls back to XDG_SESSION_ID, and monitors LockedHint through gdbus monitor. src/main/notifications/desktop-away-state.ts reports away when the session is locked. subscribeDesktopAwayChanges and subscribeAwayChanges in desktop-presence-reporter.ts push lock transitions to the presence reporter immediately. The tests in desktop-away-state.test.ts cover lock and unlock transitions, unavailable session data, a missing LockedHint, and the non-Linux fallback. The issue's optional idle-hint suggestion is covered by the Wayland ext_idle_notifier_v1 input-idle watcher (linux-wayland-idle.ts, --watch-idle in wayland-clipboard.c), with 180,000 ms threshold tests in protocol_test.py. The issue's UI-wording and debugging suggestions are non-core and not required. Assessment relies on the supplied PR summary and the linked issue text. Source-level behavior was not independently re-read in this review.
Full details: Out of Scope Changes check
Explanation
The changes support the Linux desktop-away objective of #41341. wayland-clipboard.c adds wl_display_dispatch, a reusable get_registry helper, and a version parameter for bind. These changes are needed for the --watch-idle mode. electron-wayland-helper-path.ts centralizes helper path resolution. clipboard-text-publisher.ts uses that shared path, which is a refactor that keeps the existing legacy AppImage staging logic. native/wayland-clipboard/README.md documents the idle watcher and its test coverage. protocol_test.py tests the idle watcher. main-process-observers.ts passes the helper path only for Linux Wayland sessions. The clipboard publisher and README edits affect the shared helper packaging. The summary does not show a clipboard behavior change beyond path resolution. No unrelated change was identified.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Pass the AppImage-cleaned environment to both logind subprocesses.
The logind monitor and the callLogind queries run host tools with the full app environment. Inside an AppImage, that environment can include APPDIR and LD_LIBRARY_PATH entries under the mount. Host gdbus and /bin/sh may then load bundled libraries. In that case the lock state is not reported, and Orca falls back to Electron's active state. The away-only alert problem in #41341 remains.
The Wayland idle watcher and other host-tool launches already use envWithoutAppImageRuntime. Use the same helper for both logind subprocesses.
Thanks @Mel-SRK, the root cause (Electron's powerMonitor idle/lock reports active on niri/Wayland, so away-only pushes are always suppressed) is right. The fix is too large for us to land as a bug fix, though. It changes the native Wayland helper in C and adds a long-lived gdbus/logind subprocess wrapper, so it needs a design decision from the notifications owner. Holding it for now.
Thanks for the review. @Jinwoo-H, would you be open to splitting this into two changes?
For this PR, fix screen-lock detection by subscribing to logind’s LockedHint directly in Electron main and reusing the current desktop presence reporting. Is a small JS D-Bus dependency acceptable? The prototype needed no shell or gdbus monitor process and updated an in-process relay in 1.4–3.1 ms. A five-second polling prototype still missed alerts fired immediately after locking. A headless relay can still decide eligibility before the updated presence arrives. Would you be comfortable handling that ordering guarantee separately?
Once we agree on the lock path, I’ll narrow this PR and update it against current main.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Phones set to receive alerts only when the desktop is away can now receive them when Orca's Linux desktop is locked or has had no input for three minutes on supported Wayland compositors.
What Changed
LockedHintand report lock transitions promptly. Resolve the session by PID and useXDG_SESSION_IDfor desktop launches outside the graphical session scope. A wrapper in a private process group reaps the logind monitor when its parent pipe closes.ext_idle_notifier_v1v2. Electron supplies initial and fallback presence.Why
On the reported niri setup, logind shows a locked session while Electron reports
activeand zero idle time. The away-only filter then suppresses alerts. Logind supplies lock state and the Wayland v2 input-idle protocol measures keyboard and pointer inactivity independently of display idle inhibitors.Linked Issue
Fixes #41341
Visual Proof
N/A
The change is to background alert eligibility. The issue includes the before-state Electron readings. The private niri probe produced these after-state relay decisions with Electron held at
active/0. Before-state reportTesting
Independent review passed all 25 checks in
pnpm check:changed --base=a817c50bd824for the final logind wrapper change. On the preceding revision, the combined patch passed the 28-check gate and all five focused desktop-away tests. The implementation also ran the five focused tests on the final revision.Independently ran the implementation's private D-Bus fixture with the production watcher and real
gdbusunder Bash and Ubuntu dash. Both runs verified the wrapper and monitor occupy a process group separate from the owner and checked session selection, lock transitions, parent-only SIGKILL, normal stop, cancellation during spawn, and cleanup after monitor exit.In the preceding independent review, built the unchanged native helper with release warning and hardening flags. Seven Wayland protocol tests and the X11 clipboard fallback test on a private Xvfb display passed. The protocol tests cover the v2 input-only request, the 180,000 ms threshold, resume, parent EOF, and v1 or absent-protocol fallback.
Reran the implementation's isolated niri/Xvfb probe through Orca's relay delivery predicate in the preceding independent review. The probe verifies the production 180,000 ms argument and uses a shortened 1,200 ms timer in the private compositor. The implementation previously verified an x64 helper against the Ubuntu 20.04 glibc floor.
Full Linux packaging and arm64 execution remain unverified locally. The production build requires Docker and the local daemon is unavailable. Actual push gateway/APNs delivery to a paired iPhone still needs a separate end-to-end test.
I manually tested these changes locally
Automated tests added or updated
Added tests exercise lock transitions and the input-idle and relay-delivery invariants introduced by this change
Performance
Linux starts an event-driven logind monitor with a shell wrapper and, on supported Wayland desktops, one idle helper. The lock watcher makes bounded startup and property re-read calls. The existing relay sampling interval remains five seconds, with immediate reports on activity transitions.
Risk
Level: Medium. Linux session discovery or compositor compatibility can affect when away-only alerts are eligible. Unavailable sources fall back to Electron. The existing relay capability gate determines which remote runtimes receive presence reports. A revert restores the prior detection behavior without a data migration.
AI Disclosure
OpenAI Codex (GPT-6) assisted with implementation, independent review, and verification.
Review
An independent reviewer reproduced the monitor lifecycle issue on the earlier revision and verified the fix on this PR's head.
Agent skill upstream boundary
Notes
X11 clipboard regression coverage ran on a private display. The non-Linux state test exercises the macOS fallback. Windows was reviewed in code. Relay verification exercised the existing presence RPC and the away-only delivery predicate.
Checklist