Wait for legacy notify hook completion

This commit is contained in:
Ahmed Ibrahim
2026-03-04 20:20:48 -08:00
parent 3a932261cf
commit 39c4f2b06d

View File

@@ -62,14 +62,19 @@ pub fn notify_hook(argv: Vec<String>) -> Hook {
command.arg(notify_payload);
}
// Backwards-compat: match legacy notify behavior (argv + JSON arg, fire-and-forget).
// Preserve the legacy argv + JSON payload shape, but wait for completion so
// after-agent hooks finish their side effects before the turn is marked done.
command
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null());
match command.spawn() {
Ok(_) => HookResult::Success,
match command.status().await {
Ok(status) if status.success() => HookResult::Success,
Ok(status) => HookResult::FailedContinue(
std::io::Error::other(format!("legacy notify exited with status {status}"))
.into(),
),
Err(err) => HookResult::FailedContinue(err.into()),
}
})