From 790b7e6f5ea4805249ed76d2a96d18cb2f048f2a Mon Sep 17 00:00:00 2001 From: ekcSchiano Date: Mon, 2 Nov 2026 16:22:34 +0000 Subject: [PATCH] See the route: open the valley on that dragon's most probable route In-page links now keep their sub-path (#valley/blue) when switching tabs, and a link to a dragon opens it fresh on its most probable route (earlier detours cleared). Clicking the Valley tab itself keeps the current selection. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ --- apps/atlas/explorer.js | 8 +++++++- apps/atlas/ui.js | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/atlas/explorer.js b/apps/atlas/explorer.js index 2199385..49600f0 100644 --- a/apps/atlas/explorer.js +++ b/apps/atlas/explorer.js @@ -467,8 +467,14 @@ if (parts[0] !== "valley") return; const c = parts[1] ? COLOURS.find((x) => x.toLowerCase() === parts[1].toLowerCase()) : null; const enc = parts[2] && c && S.ENCOUNTERS[c].includes(parts[2]) ? parts[2] : null; + // plain "#valley" (e.g. the tab itself) keeps whatever the reader was looking at + if (!c) { writeHash(); return; } if (!st.policy) { st.pendingHash = { c, enc }; return; } - if (c !== st.colour || (enc && enc !== st.focus)) { st.colour = c; st.focus = enc; st.expanded = null; render(); } + // a link to a dragon opens its most probable route, fresh: no earlier detours, nothing expanded + st.colour = c; st.focus = enc; st.expanded = null; st.info = null; + delete st.over[enc || ""]; + S.ENCOUNTERS[c].forEach((e) => delete st.over[e]); + render(); } /* ---------- render ---------- */ diff --git a/apps/atlas/ui.js b/apps/atlas/ui.js index effef3d..3cd5af5 100644 --- a/apps/atlas/ui.js +++ b/apps/atlas/ui.js @@ -60,7 +60,14 @@ const a = e.target.closest('a[href^="#"]'); if (!a) return; const id = a.getAttribute("href").slice(1); - if (tabOf(id)) { e.preventDefault(); showTab(tabOf(id)); return; } + if (tabOf(id)) { + // keep sub-paths such as #valley/blue so the destination can open on that selection + e.preventDefault(); + try { history.replaceState(null, "", "#" + id); } catch (err) { /* ignore */ } + showTab(tabOf(id), false, true); + window.scrollTo({ top: 0, behavior: "smooth" }); + return; + } const target = document.getElementById(id); const panel = target && target.closest(".tabpanel"); if (panel && panel.hidden) { e.preventDefault(); showTab(panel.id.replace("panel-", "")); target.scrollIntoView({ behavior: "smooth" }); }