fix(host): keep a command's last output lines after it exits (#6625)

run_command stopped reading a finished command's output after 100 ms without a line, so on a busy machine the last lines (often the error a failed worktree setup script printed) were lost. It now reads until the pipes close, for at most a second. Sibling output loops already wait for the pipes to close.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-28 11:03:31 +08:00
1 джерело 623f1fa4e7
коміт ddaee1f5ce
1 file changed
+3 -4
+3 -4
Переглянути файл
@@ -420,12 +420,11 @@ pub(crate) fn run_command(
}
// A process it started in the background may keep the pipes open: the command is done.
if let Some(status) = child.try_wait().map_err(|e| e.to_string())? {
// Read what it wrote until the pipes close, for at most a second: a busy machine may
// deliver its last lines (often the error) well after the exit.
let deadline = Instant::now() + Duration::from_secs(1);
while let Ok(line) = rx.recv_timeout(Duration::from_millis(100)) {
while let Ok(line) = rx.recv_timeout(deadline.saturating_duration_since(Instant::now())) {
on_line(line);
if Instant::now() > deadline {
break;
}
}
break status;
}