Skip to content

Commit e1865cb

Browse files
wesbillmanBrain
andauthored
fix(desktop): stop marking users away while active on the machine (#1942)
Signed-off-by: Wes <[email protected]> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
1 parent 4ddb61f commit e1865cb

10 files changed

Lines changed: 266 additions & 40 deletions

File tree

‎desktop/src-tauri/Cargo.lock‎

Lines changed: 130 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎desktop/src-tauri/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ objc2-app-kit = { version = "0.3.2", default-features = false, features = ["NSHa
4646
keyring = { version = "3.6.3", default-features = false, features = ["apple-native", "vendored"], optional = true }
4747
security-framework = { version = "3.7.0", features = ["OSX_10_15"] }
4848
window-vibrancy = "0.6"
49+
user-idle = { version = "0.6", default-features = false }
4950

5051
[target.'cfg(windows)'.dependencies]
5152
windows-sys = { version = "0.61", features = ["Win32_Security", "Win32_Storage_FileSystem", "Win32_System_JobObjects", "Win32_System_Registry", "Win32_System_Threading", "Win32_Foundation"] }
5253
keyring = { version = "3.6.3", default-features = false, features = ["windows-native", "vendored"], optional = true }
54+
user-idle = { version = "0.6", default-features = false }
5355

5456
[dependencies]
5557
atomic-write-file = "0.3"

‎desktop/src-tauri/src/commands/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub(crate) mod mesh_llm;
2727
mod messages;
2828
mod notifications;
2929
mod observer_archive;
30+
mod os_idle;
3031
pub mod pairing;
3132
mod personas;
3233
mod prevent_sleep;
@@ -72,6 +73,7 @@ pub use mesh_llm::*;
7273
pub use messages::*;
7374
pub use notifications::*;
7475
pub use observer_archive::*;
76+
pub use os_idle::*;
7577
pub use pairing::*;
7678
pub use personas::*;
7779
pub use prevent_sleep::*;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// Seconds since the last OS-wide user input (keyboard/mouse anywhere on the
2+
/// machine), or `None` on platforms without a supported idle API (Linux
3+
/// Wayland). Callers fall back to in-app activity tracking when `None`.
4+
#[tauri::command]
5+
pub fn get_os_idle_seconds() -> Option<u64> {
6+
#[cfg(any(target_os = "macos", windows))]
7+
{
8+
user_idle::UserIdle::get_time()
9+
.ok()
10+
.map(|idle| idle.as_seconds())
11+
}
12+
#[cfg(not(any(target_os = "macos", windows)))]
13+
{
14+
None
15+
}
16+
}

‎desktop/src-tauri/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ pub fn run() {
760760
open_project_terminal,
761761
search_users,
762762
get_presence,
763+
get_os_idle_seconds,
763764
get_default_relay_url,
764765
get_legacy_workspace_storage,
765766
is_shared_identity,

0 commit comments

Comments
 (0)