fix: keep sidebar selection when switching tabs
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m10s
CI / docker (push) Successful in 1m8s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 37s

Normalize the sidebar selectedPath so the app highlight persists across
tab switches (Dashboard, Runtime, Deployments). Also make sidebar clicks
tab-aware: clicking an app navigates to the current tab's path instead
of always going to /exchanges/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-09 07:13:04 +02:00
parent b86e95f08e
commit eb7cd9ba62

View File

@@ -443,7 +443,14 @@ function LayoutContent() {
if (sidebarRevealPath.startsWith('/admin') && !adminOpen) setAdminOpen(true);
}, [sidebarRevealPath]); // eslint-disable-line react-hooks/exhaustive-deps
const effectiveSelectedPath = sidebarRevealPath ?? location.pathname;
// Normalize path so sidebar highlights the app regardless of which tab is active.
// Sidebar nodes use /exchanges/{slug} paths, so map /dashboard/{slug}, /apps/{slug}, etc.
const effectiveSelectedPath = useMemo(() => {
const raw = sidebarRevealPath ?? location.pathname;
const match = raw.match(/^\/(exchanges|dashboard|apps|runtime)\/([^/]+)(\/.*)?$/);
if (match) return `/exchanges/${match[2]}${match[3] ?? ''}`;
return raw;
}, [sidebarRevealPath, location.pathname]);
// --- About Me dialog -----------------------------------------------
const [aboutMeOpen, setAboutMeOpen] = useState(false);
@@ -629,6 +636,17 @@ function LayoutContent() {
return;
}
const exchangeMatch = path.match(/^\/exchanges\/([^/]+)(?:\/(.+))?$/);
if (exchangeMatch) {
const [, sAppId, sRouteId] = exchangeMatch;
if (scope.tab === 'apps') {
navigate(`/apps/${sAppId}`, { state });
} else {
navigate(sRouteId ? `/${scope.tab}/${sAppId}/${sRouteId}` : `/${scope.tab}/${sAppId}`, { state });
}
return;
}
const agentMatch = path.match(/^\/agents\/([^/]+)(?:\/(.+))?$/);
if (agentMatch) {
const [, sAppId, sInstanceId] = agentMatch;