fabro(01KKS6WW07GQBH57MN79B016ST): simplify (success)

Fabro-Run: 01KKS6WW07GQBH57MN79B016ST
Fabro-Completed: 6
Fabro-Checkpoint: 7fae5ac1a5

⚒️ Generated with [Fabro](https://fabro.sh)
This commit is contained in:
Fabro 2026-03-15 17:27:58 +00:00
parent f23e90a9d6
commit bd2c3cf2fc
7 changed files with 33 additions and 64 deletions

1
Cargo.lock generated
View file

@ -1560,7 +1560,6 @@ dependencies = [
"dirs",
"dotenvy",
"fabro-agent",
"fabro-beastie",
"fabro-devcontainer",
"fabro-exe",
"fabro-git-storage",

View file

@ -12,12 +12,30 @@ pub(crate) struct LinuxGuard {
impl LinuxGuard {
pub(crate) fn acquire() -> Option<Self> {
// 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<Self> {
fn spawn_inhibitor(cmd: &str, args: &[&str]) -> Option<Self> {
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<Self> {
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
}
}

View file

@ -10,7 +10,7 @@ pub(crate) struct MacOsGuard {
impl MacOsGuard {
pub(crate) fn acquire() -> Option<Self> {
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 {

View file

@ -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"
trycmd = "0.15"

View file

@ -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?;
}

View file

@ -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"
predicates = "3"

View file

@ -294,13 +294,7 @@ pub async fn run_command(
styles: &'static Styles,
github_app: Option<fabro_github::GitHubAppCredentials>,
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;