From c5aa66045b21f8f55496582581db55e846452c82 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Thu, 9 Apr 2026 04:36:12 -0700 Subject: [PATCH 1/4] Remove alert/warning about officialness Signed-off-by: Daniel Hansen --- Web/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Web/index.html b/Web/index.html index d06054f8b..6e98f6d7d 100644 --- a/Web/index.html +++ b/Web/index.html @@ -10,8 +10,6 @@ -
Not an official GR tool.
-
@@ -120,7 +118,7 @@

GRCAN Viewer

- + From 01fed163de33302b3dfd71b394271e0e31c0e7e3 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Thu, 9 Apr 2026 04:40:29 -0700 Subject: [PATCH 2/4] Setup url to parse queries with ref and also show url status via fragment identifiers, this way we can easily share viewers on specific references and any shared link clearly shows custom/edited/etc by default Signed-off-by: Daniel Hansen --- Web/viewer.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/Web/viewer.js b/Web/viewer.js index a093ecdc3..e1e8f3179 100644 --- a/Web/viewer.js +++ b/Web/viewer.js @@ -20,6 +20,25 @@ window.addEventListener("DOMContentLoaded", function () { const searchInput = document.getElementById("viewer-search"); let nodeIdMap = new Map(); let currentRef = ""; + const requestedQueryKey = (() => { + try { + const params = new URLSearchParams(window.location.search); + if (params.has("ref")) return "ref"; + if (params.has("branch")) return "branch"; + return "ref"; + } catch (_err) { + return "ref"; + } + })(); + const requestedRefFromUrl = (() => { + try { + const params = new URLSearchParams(window.location.search); + const ref = params.get("ref") || params.get("branch"); + return ref ? ref.trim() : ""; + } catch (_err) { + return ""; + } + })(); let _allNodes = []; // persisted node→bus→messages index for search let _searchDropdown = null; @@ -63,6 +82,28 @@ window.addEventListener("DOMContentLoaded", function () { container.appendChild(d); } + function updateLocationState(ref) { + const url = new URL(window.location.href); + const isCustomFile = !!window.GrcanApi.isLocalMode(); + const hasEdits = + !isCustomFile && !!editor && !!editor.hasUnsavedEdits && editor.hasUnsavedEdits(); + + if (isCustomFile) { + url.search = ""; + url.hash = "custom"; + } else { + if (ref) { + url.searchParams.set(requestedQueryKey, ref); + } else { + url.searchParams.delete("ref"); + url.searchParams.delete("branch"); + } + url.hash = hasEdits ? "edited" : ""; + } + + window.history.replaceState(null, "", url); + } + function messageChangeState(msgName, deviceName, busCanonical) { const busPort = busCanonical ? window.GrcanApi.busToPort(busCanonical) @@ -1113,6 +1154,7 @@ window.addEventListener("DOMContentLoaded", function () { await renderBusNode(null, text); } restoreSelection(snapshot || navSnapshot()); + updateLocationState(currentRef); } if (editor) { @@ -1179,6 +1221,7 @@ window.addEventListener("DOMContentLoaded", function () { } await renderHierarchy(ref); currentRef = ref; + updateLocationState(currentRef); if (typeof window.regenerateAndDrawBg === "function") { window.regenerateAndDrawBg(); } @@ -1210,12 +1253,21 @@ window.addEventListener("DOMContentLoaded", function () { refSelect.appendChild(opt); }); - if (branches.includes("main")) { - refSelect.value = "main"; - await renderHierarchy("main"); - currentRef = "main"; + const availableRefs = new Set([...branches, ...tags]); + const initialRef = availableRefs.has(requestedRefFromUrl) + ? requestedRefFromUrl + : branches.includes("main") + ? "main" + : ""; + + if (initialRef) { + refSelect.value = initialRef; + await renderHierarchy(initialRef); + currentRef = initialRef; + updateLocationState(currentRef); } else { setPlaceholder(firstList, "Select a ref"); + updateLocationState(""); } } @@ -1235,6 +1287,7 @@ window.addEventListener("DOMContentLoaded", function () { localFileInput.value = ""; window.GrcanApi.setLocalCandoText(null); refSelect.disabled = false; + updateLocationState(currentRef); if (currentRef) renderHierarchy(currentRef); } }); @@ -1246,6 +1299,7 @@ window.addEventListener("DOMContentLoaded", function () { localFileInput.style.display = "none"; window.GrcanApi.setLocalCandoText(null); refSelect.disabled = false; + updateLocationState(currentRef); return; } const reader = new FileReader(); @@ -1253,6 +1307,7 @@ window.addEventListener("DOMContentLoaded", function () { window.GrcanApi.setLocalCandoText(e.target.result); refSelect.disabled = true; renderHierarchy(currentRef || "local"); + updateLocationState(currentRef); }; reader.readAsText(file); }); @@ -1260,6 +1315,9 @@ window.addEventListener("DOMContentLoaded", function () { localFileInput.addEventListener("cancel", function () { localToggle.checked = false; localFileInput.style.display = "none"; + window.GrcanApi.setLocalCandoText(null); + refSelect.disabled = false; + updateLocationState(currentRef); }); } From 7b430089e7cdb8081b1b5f39afdc14bb98b27bde Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:49:08 +0000 Subject: [PATCH 3/4] Automatic Web Format: Standardized formatting automatically --- Web/viewer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Web/viewer.js b/Web/viewer.js index e1e8f3179..1d4ea23dc 100644 --- a/Web/viewer.js +++ b/Web/viewer.js @@ -86,7 +86,10 @@ window.addEventListener("DOMContentLoaded", function () { const url = new URL(window.location.href); const isCustomFile = !!window.GrcanApi.isLocalMode(); const hasEdits = - !isCustomFile && !!editor && !!editor.hasUnsavedEdits && editor.hasUnsavedEdits(); + !isCustomFile && + !!editor && + !!editor.hasUnsavedEdits && + editor.hasUnsavedEdits(); if (isCustomFile) { url.search = ""; From 1fd308578a0c98aef3f0b555271d1863a0af287a Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Thu, 9 Apr 2026 04:50:50 -0700 Subject: [PATCH 4/4] Fix `viewer.js` version incrementation Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- Web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web/index.html b/Web/index.html index 6e98f6d7d..c0ea35434 100644 --- a/Web/index.html +++ b/Web/index.html @@ -118,7 +118,7 @@

GRCAN Viewer

- +