From 777e79804184712f8c3e0ff679c4b1550f3eb3ef Mon Sep 17 00:00:00 2001 From: akadeepesh Date: Sun, 20 Sep 2026 11:56:37 +0530 Subject: [PATCH] fix(webui): auto-close the config UI tab after saving The success overlay already told the user they could close the tab, but nothing ever tried to. Calls window.close() shortly after the save + shutdown round-trip completes. Browsers permit scripted close on tabs whose entire session history is a single page, which the config UI always is, so this closes cleanly and drops the user back to their terminal; if a browser still blocks it, the existing on-screen message remains as the manual fallback. --- contextzip/webui/assets.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contextzip/webui/assets.py b/contextzip/webui/assets.py index ba94566..d9cd34c 100644 --- a/contextzip/webui/assets.py +++ b/contextzip/webui/assets.py @@ -1148,6 +1148,17 @@ INDEX_HTML = r""" document.getElementById("overlay").classList.add("show"); setTimeout(function () { api("/api/shutdown", { method: "GET" }).catch(function () {}); + // Try to close the tab automatically and hop back to the terminal. + // Browsers only allow script-initiated close on windows/tabs that + // were opened by a script, or ones whose entire session history is + // just this one page — which this config-UI tab always is, since + // it's a single page with no navigation. If the browser still + // blocks it (some do, regardless), window.close() is a silent + // no-op and the overlay's "you can close this tab" text — already + // on screen — is the fallback the user follows manually. + setTimeout(function () { + try { window.close(); } catch (e) { /* ignored — fallback is the overlay text */ } + }, 300); }, 900); }).catch(function () { btn.disabled = false;