From a918cbec3becb77f94f16a03b0da2812898b4a03 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Tue, 6 Oct 2026 20:54:33 +0000 Subject: [PATCH] Refresh run details and actions when tasks finish --- python-tools/static/app.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python-tools/static/app.js b/python-tools/static/app.js index c5ed806..f51ece6 100644 --- a/python-tools/static/app.js +++ b/python-tools/static/app.js @@ -2,6 +2,9 @@ const output = document.querySelector("#run-output"); if (output) { let refreshTimer; + let detailsFinalized = !["queued", "running"].includes( + document.querySelector("#run-status")?.textContent.trim(), + ); const refresh = async () => { const response = await fetch(output.dataset.outputUrl, { cache: "no-store" }); if (response.ok) { @@ -17,6 +20,22 @@ if (output) { const state = await stateResponse.json(); status.textContent = state.status; if (state.status !== "queued" && state.status !== "running") { + if (!detailsFinalized) { + const pageResponse = await fetch(window.location.href, { cache: "no-store" }); + if (!pageResponse.ok) { + return; + } + const page = new DOMParser().parseFromString(await pageResponse.text(), "text/html"); + const nextDetails = page.querySelector("#run-status")?.closest("dl"); + if (!nextDetails) { + return; + } + const actions = 'form[action$="/cancel"], form[action$="/execute"]'; + document.querySelectorAll(actions).forEach((form) => form.remove()); + status.closest("dl").replaceWith(nextDetails); + nextDetails.after(...page.querySelectorAll(actions)); + detailsFinalized = true; + } window.clearInterval(refreshTimer); } }