From bd2c3cf2fcf6950165866ea10910e0c5262aabd4 Mon Sep 17 00:00:00 2001 From: Fabro Date: Sun, 15 Mar 2026 17:27:58 +0000 Subject: [PATCH] fabro(01KKS6WW07GQBH57MN79B016ST): simplify (success) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fabro-Run: 01KKS6WW07GQBH57MN79B016ST Fabro-Completed: 6 Fabro-Checkpoint: 7fae5ac1a5812009b311d6dfcd90e05e4058bd50 ⚒️ Generated with [Fabro](https://fabro.sh) --- Cargo.lock | 1 - lib/crates/fabro-beastie/src/linux.rs | 76 ++++++++--------------- lib/crates/fabro-beastie/src/macos.rs | 2 +- lib/crates/fabro-cli/Cargo.toml | 4 +- lib/crates/fabro-cli/src/main.rs | 4 +- lib/crates/fabro-workflows/Cargo.toml | 4 +- lib/crates/fabro-workflows/src/cli/run.rs | 6 -- 7 files changed, 33 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67b5269f7..8163c10f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1560,7 +1560,6 @@ dependencies = [ "dirs", "dotenvy", "fabro-agent", - "fabro-beastie", "fabro-devcontainer", "fabro-exe", "fabro-git-storage", diff --git a/lib/crates/fabro-beastie/src/linux.rs b/lib/crates/fabro-beastie/src/linux.rs index 00381b0d8..2ea7ec063 100644 --- a/lib/crates/fabro-beastie/src/linux.rs +++ b/lib/crates/fabro-beastie/src/linux.rs @@ -12,12 +12,30 @@ pub(crate) struct LinuxGuard { impl LinuxGuard { pub(crate) fn acquire() -> Option { - // Try systemd-inhibit first - if let Some(guard) = Self::try_systemd_inhibit() { + if let Some(guard) = Self::spawn_inhibitor( + "systemd-inhibit", + &[ + "--what=idle", + "--who=fabro", + "--why=Workflow in progress", + "--mode=block", + "sleep", + "infinity", + ], + ) { return Some(guard); } - // Fallback to gnome-session-inhibit - if let Some(guard) = Self::try_gnome_inhibit() { + if let Some(guard) = Self::spawn_inhibitor( + "gnome-session-inhibit", + &[ + "--inhibit", + "idle", + "--reason", + "Workflow in progress", + "sleep", + "infinity", + ], + ) { return Some(guard); } tracing::warn!( @@ -27,17 +45,10 @@ impl LinuxGuard { None } - fn try_systemd_inhibit() -> Option { + fn spawn_inhibitor(cmd: &str, args: &[&str]) -> Option { let child = unsafe { - Command::new("systemd-inhibit") - .args([ - "--what=idle", - "--who=fabro", - "--why=Workflow in progress", - "--mode=block", - "sleep", - "infinity", - ]) + Command::new(cmd) + .args(args) .stdin(std::process::Stdio::null()) .stdout(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) @@ -51,44 +62,11 @@ impl LinuxGuard { match child { Ok(child) => { let pid = child.id(); - tracing::debug!(pid, "Sleep inhibitor: systemd-inhibit started"); + tracing::debug!(pid, cmd, "Sleep inhibitor: inhibitor started"); Some(Self { child }) } Err(e) => { - tracing::debug!(%e, "systemd-inhibit not available"); - None - } - } - } - - fn try_gnome_inhibit() -> Option { - let child = unsafe { - Command::new("gnome-session-inhibit") - .args([ - "--inhibit", - "idle", - "--reason", - "Workflow in progress", - "sleep", - "infinity", - ]) - .stdin(std::process::Stdio::null()) - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .pre_exec(|| { - libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM); - Ok(()) - }) - .spawn() - }; - match child { - Ok(child) => { - let pid = child.id(); - tracing::debug!(pid, "Sleep inhibitor: gnome-session-inhibit started"); - Some(Self { child }) - } - Err(e) => { - tracing::debug!(%e, "gnome-session-inhibit not available"); + tracing::debug!(%e, cmd, "Sleep inhibitor: command not available"); None } } diff --git a/lib/crates/fabro-beastie/src/macos.rs b/lib/crates/fabro-beastie/src/macos.rs index 102159c85..7dd90a216 100644 --- a/lib/crates/fabro-beastie/src/macos.rs +++ b/lib/crates/fabro-beastie/src/macos.rs @@ -10,7 +10,7 @@ pub(crate) struct MacOsGuard { impl MacOsGuard { pub(crate) fn acquire() -> Option { let assertion_type = CFString::from_static_string("PreventUserIdleSystemSleep"); - let reason = CFString::new("fabro workflow in progress"); + let reason = CFString::new("Workflow in progress"); let mut assertion_id: IOPMAssertionID = 0; let result = unsafe { diff --git a/lib/crates/fabro-cli/Cargo.toml b/lib/crates/fabro-cli/Cargo.toml index 2d7a6df73..a855fd69e 100644 --- a/lib/crates/fabro-cli/Cargo.toml +++ b/lib/crates/fabro-cli/Cargo.toml @@ -13,7 +13,7 @@ path = "src/main.rs" default = [] server = ["dep:fabro-api"] exedev = ["fabro-config/exedev", "fabro-workflows/exedev"] -sleep_inhibitor = ["dep:fabro-beastie", "fabro-workflows/sleep_inhibitor"] +sleep_inhibitor = ["dep:fabro-beastie"] [dependencies] fabro-config = { path = "../fabro-config" } @@ -69,4 +69,4 @@ predicates = "3" tempfile = "3" serde_json.workspace = true httpmock = "0.8" -trycmd = "0.15" \ No newline at end of file +trycmd = "0.15" diff --git a/lib/crates/fabro-cli/src/main.rs b/lib/crates/fabro-cli/src/main.rs index a4dcbd601..2fd3828d1 100644 --- a/lib/crates/fabro-cli/src/main.rs +++ b/lib/crates/fabro-cli/src/main.rs @@ -593,7 +593,8 @@ async fn main_inner() -> (String, Result<()>) { Box::leak(Box::new(fabro_util::terminal::Styles::detect_stderr())); let cli_config = cli_config::load_cli_config(None)?; args.verbose = args.verbose || cli_config.verbose; - let prevent_idle_sleep = cli_config.prevent_idle_sleep; + #[cfg(feature = "sleep_inhibitor")] + let _sleep_guard = fabro_beastie::guard(cli_config.prevent_idle_sleep); let github_app = build_github_app_credentials(cli_config.app_id()); let git_author = fabro_workflows::git::GitAuthor::from_options( @@ -607,7 +608,6 @@ async fn main_inner() -> (String, Result<()>) { styles, github_app, git_author, - prevent_idle_sleep, ) .await?; } diff --git a/lib/crates/fabro-workflows/Cargo.toml b/lib/crates/fabro-workflows/Cargo.toml index 8736eee3d..93f4aea64 100644 --- a/lib/crates/fabro-workflows/Cargo.toml +++ b/lib/crates/fabro-workflows/Cargo.toml @@ -15,7 +15,6 @@ doctest = false [features] default = [] exedev = ["dep:fabro-exe"] -sleep_inhibitor = ["dep:fabro-beastie"] [dependencies] clap.workspace = true @@ -23,7 +22,6 @@ anyhow.workspace = true dotenvy.workspace = true fabro-agent = { path = "../fabro-agent" } fabro-devcontainer = { path = "../fabro-devcontainer" } -fabro-beastie = { path = "../fabro-beastie", optional = true } fabro-exe = { path = "../fabro-exe", optional = true } fabro-ssh = { path = "../fabro-ssh" } fabro-mcp = { path = "../fabro-mcp" } @@ -68,4 +66,4 @@ tokio = { workspace = true, features = ["test-util", "macros"] } tempfile = "3" dotenvy.workspace = true assert_cmd = "2" -predicates = "3" \ No newline at end of file +predicates = "3" diff --git a/lib/crates/fabro-workflows/src/cli/run.rs b/lib/crates/fabro-workflows/src/cli/run.rs index 9426577b0..86ad2fabe 100644 --- a/lib/crates/fabro-workflows/src/cli/run.rs +++ b/lib/crates/fabro-workflows/src/cli/run.rs @@ -294,13 +294,7 @@ pub async fn run_command( styles: &'static Styles, github_app: Option, git_author: crate::git::GitAuthor, - prevent_idle_sleep: bool, ) -> anyhow::Result<()> { - #[cfg(feature = "sleep_inhibitor")] - let _sleep_guard = fabro_beastie::guard(prevent_idle_sleep); - #[cfg(not(feature = "sleep_inhibitor"))] - let _ = prevent_idle_sleep; - // Handle --run-branch resume: read everything from git metadata if let Some(branch) = args.run_branch.clone() { return run_from_branch(args, &branch, styles, git_author, run_defaults, github_app).await;