mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-16 01:12:46 +00:00
fix: show correct active tab
This commit is contained in:
@@ -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(
|
||||
() =>
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user