mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-29 07:25:33 +08: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) => {
|
const getTabTitle = (tab: AppTab, pluginDisplayName: string | undefined, t: (key: string) => string) => {
|
||||||
if (tab.startsWith('plugin:') && pluginDisplayName) {
|
if (tab.startsWith('plugin:') && pluginDisplayName) {
|
||||||
return pluginDisplayName;
|
return pluginDisplayName;
|
||||||
@@ -69,13 +80,13 @@ export function MainHeading() {
|
|||||||
return decodeValue(params.get('name') ?? undefined);
|
return decodeValue(params.get('name') ?? undefined);
|
||||||
}, [location.search]);
|
}, [location.search]);
|
||||||
const activeTab = useMemo<AppTab>(() => {
|
const activeTab = useMemo<AppTab>(() => {
|
||||||
const routeTab = decodeValue(tab);
|
const routeTab = decodeValue(tab) || resolveTabFromPathname(location.pathname);
|
||||||
if (routeTab === 'plugins' && pluginName) {
|
if (routeTab === 'plugins' && pluginName) {
|
||||||
return `plugin:${pluginName}` as AppTab;
|
return `plugin:${pluginName}` as AppTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (routeTab || 'chat') as AppTab;
|
return (routeTab || 'chat') as AppTab;
|
||||||
}, [pluginName, tab]);
|
}, [location.pathname, pluginName, tab]);
|
||||||
|
|
||||||
const pluginDisplayName = useMemo(
|
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() {
|
export function MobileNav() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation(['common', 'settings']);
|
const { t } = useTranslation(['common', 'settings']);
|
||||||
@@ -72,13 +83,13 @@ export function MobileNav() {
|
|||||||
return decodeValue(params.get('name') ?? undefined);
|
return decodeValue(params.get('name') ?? undefined);
|
||||||
}, [location.search]);
|
}, [location.search]);
|
||||||
const activeTab = useMemo<AppTab>(() => {
|
const activeTab = useMemo<AppTab>(() => {
|
||||||
const routeTab = decodeValue(tab);
|
const routeTab = decodeValue(tab) || resolveTabFromPathname(location.pathname);
|
||||||
if (routeTab === 'plugins' && pluginName) {
|
if (routeTab === 'plugins' && pluginName) {
|
||||||
return `plugin:${pluginName}` as AppTab;
|
return `plugin:${pluginName}` as AppTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (routeTab || 'chat') as AppTab;
|
return (routeTab || 'chat') as AppTab;
|
||||||
}, [pluginName, tab]);
|
}, [location.pathname, pluginName, tab]);
|
||||||
const isPluginActive = activeTab.startsWith('plugin:');
|
const isPluginActive = activeTab.startsWith('plugin:');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user