From 8d6ab4eb743bfec17fcbc4293a872f7ee24e4338 Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Sat, 2 May 2026 17:15:04 +0300 Subject: [PATCH] Restore shell sync on browser history - Re-sync the active shell page on popstate - Keep React routes like /issues on the React host after back/forward navigation - Preserve the existing legacy page activation path for non-React routes --- webui/static/shell-bridge.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/webui/static/shell-bridge.js b/webui/static/shell-bridge.js index db4368de..00e63e8a 100644 --- a/webui/static/shell-bridge.js +++ b/webui/static/shell-bridge.js @@ -64,6 +64,28 @@ function activateLegacyPath(pathname) { activatePage(targetPage, { forceReload: true }); } +function syncActivePageFromLocation() { + const router = getWebRouter(); + const targetPage = router?.resolvePageId?.(window.location.pathname) || _getPageFromPath(window.location.pathname); + if (!targetPage) return; + + if (!isPageAllowed(targetPage)) { + const home = getProfileHomePage(); + if (home !== targetPage) { + navigateToPage(home, { replace: true }); + } + return; + } + + const route = router?.routeManifest?.find((entry) => entry.pageId === targetPage); + if (route?.kind === 'react') { + showReactHost(targetPage); + } else { + showLegacyPage(targetPage); + } + setActivePageChrome(targetPage); +} + const SHELL_BRIDGE_READY_EVENT = 'ss:webui-shell-bridge-ready'; function openDownloadMissingAlbumWorkflow(input) { @@ -130,4 +152,5 @@ window.SoulSyncWebShellBridge = { }, }; +window.addEventListener('popstate', syncActivePageFromLocation); window.dispatchEvent(new CustomEvent(SHELL_BRIDGE_READY_EVENT));