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 <noreply@anthropic.com>
This commit is contained in:
19
tui/jobs.py
19
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
|
||||
|
||||
Reference in New Issue
Block a user