From ad590fb3dbfd355ded336ae5f293ee231955beeb Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Sun, 26 Apr 2026 17:50:01 +0300 Subject: [PATCH] Reduce legacy route flicker Keep React-owned pages out of the legacy page activator during initial bootstrap, and switch the visible React host before paint when the shell mounts. That removes the refresh flash on /issues while preserving the legacy-page behavior and browser-history stability. Verified with the router tests and the issues smoke suite. --- webui/src/platform/shell/route-controllers.tsx | 13 +++++++++---- webui/static/search.js | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/webui/src/platform/shell/route-controllers.tsx b/webui/src/platform/shell/route-controllers.tsx index 4eb1a8dc..e6a77dd6 100644 --- a/webui/src/platform/shell/route-controllers.tsx +++ b/webui/src/platform/shell/route-controllers.tsx @@ -1,5 +1,5 @@ import { useRouter } from '@tanstack/react-router'; -import { useEffect, useState } from 'react'; +import { useEffect, useLayoutEffect, useState } from 'react'; import { getProfileHomePath, getShellBridge, type ShellPageId } from './bridge'; @@ -42,6 +42,14 @@ export function useReactPageShell(pageId: ShellPageId) { const bridge = useShellBridge(); const router = useRouter(); + useLayoutEffect(() => { + if (!bridge) return; + if (!bridge.isPageAllowed(pageId)) return; + + bridge.setActivePageChrome(pageId); + bridge.showReactHost(pageId); + }, [bridge, pageId]); + useEffect(() => { if (!bridge) return; @@ -49,9 +57,6 @@ export function useReactPageShell(pageId: ShellPageId) { void router.navigate({ href: getProfileHomePath(bridge), replace: true }); return; } - - bridge.setActivePageChrome(pageId); - bridge.showReactHost(pageId); }, [bridge, pageId, router]); return bridge; diff --git a/webui/static/search.js b/webui/static/search.js index 1c7f39e4..1a7c21f4 100644 --- a/webui/static/search.js +++ b/webui/static/search.js @@ -1180,6 +1180,15 @@ async function loadInitialData() { // Always apply the target page to the legacy shell chrome. // When the router is present, skipRouteChange keeps the URL stable // while still syncing the active page/nav state for direct loads. + const router = getWebRouter(); + const route = router?.routeManifest?.find((entry) => entry.pageId === targetPage); + + if (route?.kind === 'react') { + showReactHost(targetPage); + setActivePageChrome(targetPage); + return; + } + navigateToPage(targetPage, { skipRouteChange: true, forceReload: true }); } catch (error) { console.error('Error loading initial data:', error);