From 28faefef94ff20484a30ffb22c559fbd5fdbeebd Mon Sep 17 00:00:00 2001 From: CyberSecurityUP Date: Sun, 18 Oct 2026 16:50:06 -0300 Subject: [PATCH] fix(web): auto-exit live view when job no longer exists on server restart --- web/public/app.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/public/app.js b/web/public/app.js index 79f8931..68b025a 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -779,7 +779,20 @@ function attachLiveJob(id, target, name, pinnedAgents) { clearInterval(state.currentJob.pocPoll); refreshRuns(); }); - es.onerror = () => { /* EventSource auto-retries; the server replays its buffer on reconnect */ }; + es.onerror = () => { + if (es.readyState === EventSource.CLOSED) return; + api(`/api/exploit/${id}`).catch(() => { + es.close(); + clearInterval(state.currentJob?.pocPoll); + localStorage.removeItem(ACTIVE_JOB_KEY); + if (state.currentJob?.runId) { + show($('#liveView'), false); show($('#detailView'), true); + loadDetail(state.currentJob.runId); + } else { show($('#liveView'), false); show($('#dashView'), true); } + state.currentJob = null; + refreshRuns(); + }); + }; // PoC scripts land in runs//pocs/ during the run — poll for them once // the CLI's own run id is known (see applySnapshot), so the finding modal