From ea6aa93c228680de2c398bbacc5f9d414e2bd4e6 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 15 Mar 2026 13:37:48 -0400 Subject: [PATCH] Fix race condition between `fabro run --detach` and `fabro logs -f` Write id.txt and touch empty progress.jsonl in detach_run() before spawning the child process so that `fabro logs -f ULID` can resolve the run and tail the file immediately. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-cli/src/main.rs | 2 ++ lib/crates/fabro-workflows/src/cli/runs.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/crates/fabro-cli/src/main.rs b/lib/crates/fabro-cli/src/main.rs index 2411ead71..4b639e793 100644 --- a/lib/crates/fabro-cli/src/main.rs +++ b/lib/crates/fabro-cli/src/main.rs @@ -218,6 +218,8 @@ fn detach_run(args: fabro_workflows::cli::RunArgs) -> Result<()> { )) }); std::fs::create_dir_all(&run_dir)?; + std::fs::write(run_dir.join("id.txt"), &run_id)?; + std::fs::File::create(run_dir.join("progress.jsonl"))?; let log_file = std::fs::File::create(run_dir.join("detach.log"))?; diff --git a/lib/crates/fabro-workflows/src/cli/runs.rs b/lib/crates/fabro-workflows/src/cli/runs.rs index 472684edd..dfd2e1301 100644 --- a/lib/crates/fabro-workflows/src/cli/runs.rs +++ b/lib/crates/fabro-workflows/src/cli/runs.rs @@ -161,8 +161,12 @@ pub fn scan_runs(base: &Path) -> Result> { .map(|t| -> DateTime { t.into() }); let mtime = mtime_dt.map(|dt| dt.to_rfc3339()).unwrap_or_default(); + let run_id = std::fs::read_to_string(path.join("id.txt")) + .map(|s| s.trim().to_string()) + .unwrap_or_else(|_| dir_name.clone()); + runs.push(RunInfo { - run_id: dir_name.clone(), + run_id, dir_name, workflow_name: "[no manifest]".to_string(), workflow_slug: None,