From 4e21aea89bc966e5c8365c172d9e4d5b5e633cc5 Mon Sep 17 00:00:00 2001 From: Jordan Thompson Date: Wed, 18 Feb 2026 15:13:47 -0800 Subject: [PATCH] Persist view selection --- web/comfy_viewer.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/web/comfy_viewer.js b/web/comfy_viewer.js index d1e2806..398f31e 100644 --- a/web/comfy_viewer.js +++ b/web/comfy_viewer.js @@ -640,7 +640,6 @@ function ensureElementsForNode(node) { const iframe = document.createElement("iframe"); iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-pointer-lock allow-downloads"); iframe.setAttribute("allow", "fullscreen"); - iframe.setAttribute("allowfullscreen", "true"); iframe.style.cssText = ` position: absolute; top: 0; @@ -881,6 +880,7 @@ function processIframeQueue() { elements.lastDirectUrlKey = null; const blob = new Blob([html], { type: "text/html" }); elements.lastBlobUrl = URL.createObjectURL(blob); + elements.iframe.removeAttribute("srcdoc"); elements.iframe.src = elements.lastBlobUrl; } else { if (elements.pendingSandbox && elements.iframe.getAttribute("sandbox") !== elements.pendingSandbox) { @@ -904,6 +904,19 @@ function updateIframeContent(node, elements, forceView = null) { manualViewType = elements.viewSelector.value; } + // Restore persisted view selection from view_state on reload + if (!content && !manualViewType) { + const vsWidget = node.widgets?.find(w => w.name === "view_state"); + if (vsWidget) { + try { + const vs = JSON.parse(vsWidget.value || "{}"); + if (vs._selectedView) { + manualViewType = vs._selectedView; + } + } catch {} + } + } + // When content is empty but the upstream node is a UI view provider (e.g. // OpenReel), load the view in standalone mode so the user can work in it // before the workflow has been executed. We use a special hash so this @@ -1067,6 +1080,16 @@ function updateIframeContent(node, elements, forceView = null) { * @param {string} viewName - Name of view to switch to */ function handleViewChange(node, elements, viewName) { + // Persist selected view into view_state so it survives refresh/reload + const vsWidget = node.widgets?.find(w => w.name === "view_state"); + if (vsWidget) { + try { + const vs = JSON.parse(vsWidget.value || "{}"); + vs._selectedView = viewName || null; + vsWidget.value = JSON.stringify(vs); + } catch {} + } + if (elements.multiviewContent) { elements.lastContentHash = ""; updateIframeContent(node, elements, viewName);