From a08cf9911c450df4e325c61dd6f802dd06ee023b Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 20:46:47 +0200 Subject: [PATCH] Show background jobs that finished while TUI was closed Previously _load_registry silently dropped dead PIDs, so jobs that completed in the background were invisible on restart. Now dead PIDs are loaded as 'success' status so the user sees they completed. The registry is cleaned up after loading. Co-Authored-By: Claude Opus 4.6 --- tui/jobs.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tui/jobs.py b/tui/jobs.py index 8e44bed..22e46ef 100644 --- a/tui/jobs.py +++ b/tui/jobs.py @@ -200,25 +200,30 @@ class JobManager: pid = entry.get("pid") if pid is None: continue - # Check if process is still alive - try: - os.kill(pid, 0) - except (ProcessLookupError, PermissionError): - continue job_id = entry["id"] if job_id in self._jobs: continue + # Check if process is still alive + alive = False + try: + os.kill(pid, 0) + alive = True + except (ProcessLookupError, PermissionError): + pass job = Job( id=job_id, kind=entry.get("kind", "backup"), label=entry.get("label", f"Job (PID {pid})"), - status="running", + status="running" if alive else "success", started_at=datetime.fromisoformat(entry["started_at"]), + finished_at=None if alive else datetime.now(), ) job._pid = pid job._pgid = entry.get("pgid") - job._reconnected = True + job._reconnected = alive self._jobs[job.id] = job + # Clean up registry: only keep still-running entries + self._save_registry() def check_reconnected(self) -> None: changed = False