fix: show correct active tab

This commit is contained in:
Haileyesus
2026-04-08 16:35:29 +03:00
parent 8ed530d7cb
commit 8f668d2c8a
2 changed files with 26 additions and 4 deletions

View File

@@ -25,6 +25,17 @@ const decodeValue = (value?: string): string => {
}
};
const resolveTabFromPathname = (pathname: string): string => {
const normalizedPath = pathname.replace(/\/+$/, '');
const segments = normalizedPath.split('/').filter(Boolean);
if (segments.length >= 3 && (segments[0] === 'workspaces' || segments[0] === 'sessions')) {
return decodeValue(segments[2]);
}
return '';
};
const getTabTitle = (tab: AppTab, pluginDisplayName: string | undefined, t: (key: string) => string) => {
if (tab.startsWith('plugin:') && pluginDisplayName) {
return pluginDisplayName;
@@ -69,13 +80,13 @@ export function MainHeading() {
return decodeValue(params.get('name') ?? undefined);
}, [location.search]);
const activeTab = useMemo<AppTab>(() => {
const routeTab = decodeValue(tab);
const routeTab = decodeValue(tab) || resolveTabFromPathname(location.pathname);
if (routeTab === 'plugins' && pluginName) {
return `plugin:${pluginName}` as AppTab;
}
return (routeTab || 'chat') as AppTab;
}, [pluginName, tab]);
}, [location.pathname, pluginName, tab]);
const pluginDisplayName = useMemo(
() =>

View File

@@ -52,6 +52,17 @@ const decodeValue = (value?: string): string => {
}
};
const resolveTabFromPathname = (pathname: string): string => {
const normalizedPath = pathname.replace(/\/+$/, '');
const segments = normalizedPath.split('/').filter(Boolean);
if (segments.length >= 3 && (segments[0] === 'workspaces' || segments[0] === 'sessions')) {
return decodeValue(segments[2]);
}
return '';
};
export function MobileNav() {
const navigate = useNavigate();
const { t } = useTranslation(['common', 'settings']);
@@ -72,13 +83,13 @@ export function MobileNav() {
return decodeValue(params.get('name') ?? undefined);
}, [location.search]);
const activeTab = useMemo<AppTab>(() => {
const routeTab = decodeValue(tab);
const routeTab = decodeValue(tab) || resolveTabFromPathname(location.pathname);
if (routeTab === 'plugins' && pluginName) {
return `plugin:${pluginName}` as AppTab;
}
return (routeTab || 'chat') as AppTab;
}, [pluginName, tab]);
}, [location.pathname, pluginName, tab]);
const isPluginActive = activeTab.startsWith('plugin:');
useEffect(() => {