Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(agent-sidebar): move topics view-all into the Topics section header (#23454)

AmAzing-835b9f3b5603
diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsx
index 385cb5c8998..d4f7cf11024 100644
--- a/src/features/AgentSidebar/Header/Nav.test.tsx
+++ b/src/features/AgentSidebar/Header/Nav.test.tsx
@@ -348,7 +348,7 @@ describe('Agent sidebar header nav', () => {
});
});
- it('places topics above goals and tasks, with profile settings in the header', () => {
+ it('places goals above tasks, with profile settings in the header', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
render(<Nav />);
@@ -358,12 +358,19 @@ describe('Agent sidebar header nav', () => {
expect(screen.getByRole('banner')).toContainElement(
screen.getByRole('button', { name: 'tab.profile' }),
);
- expect(labels.indexOf('management.sidebarEntry')).toBeLessThan(
- labels.indexOf('goalList.title'),
- );
expect(labels.indexOf('goalList.title')).toBeLessThan(labels.indexOf('tab.tasks'));
});
+ // The full topic page is reached from the Topics section header arrow, not a
+ // nav entry that duplicated the section right below it.
+ it('has no Topics nav entry', () => {
+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u/topics');
+
+ render(<Nav />);
+
+ expect(screen.queryByRole('button', { name: 'management.sidebarEntry' })).toBeNull();
+ });
+
// r1018 issue 7: in a workspace, `useResourceAccess` reports the edit check as
// permissive while `getGeneralAccess` is in flight (`canEditResource: true`,
// `isAccessResolved: false`). The profile entry must not vanish for that
diff --git a/src/features/AgentSidebar/Header/Nav.tsx b/src/features/AgentSidebar/Header/Nav.tsx
index 77dad6d93b4..dba892f9a8f 100644
--- a/src/features/AgentSidebar/Header/Nav.tsx
+++ b/src/features/AgentSidebar/Header/Nav.tsx
@@ -2,14 +2,7 @@
import { Flexbox } from '@lobehub/ui';
import { BotPromptIcon } from '@lobehub/ui/icons';
-import {
- DnaIcon,
- ListTodoIcon,
- MessageSquarePlusIcon,
- MessagesSquareIcon,
- SearchIcon,
- TargetIcon,
-} from 'lucide-react';
+import { DnaIcon, ListTodoIcon, MessageSquarePlusIcon, SearchIcon, TargetIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
@@ -50,9 +43,6 @@ const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
const isProfileActive = isAgentProfileRoute(pathname) && !isSelfLearningActive;
const isGoalsActive = pathname.endsWith('/goals');
const isTasksActive = pathname.endsWith('/tasks') || pathname.includes('/task/');
- // Topic IDs are prefixed `topics_`, so /agent/:aid/topics_abc would also match
- // pathname.includes('/topics') — anchor to end to avoid that false positive.
- const isTopicsActive = pathname.endsWith('/topics');
const router = useQueryRoute();
const { allowed: canCreateTopic } = usePermission('create_content');
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
@@ -92,15 +82,6 @@ const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
toggleCommandMenu(true);
}}
/>
- <NavItem
- active={isTopicsActive}
- icon={MessagesSquareIcon}
- title={tTopic('management.sidebarEntry')}
- onClick={() => {
- switchTopic(null, { skipRefreshMessage: true });
- router.push(urlJoin('/agent', agentId!, 'topics'));
- }}
- />
{showProfile && isMobileSurface() && (
<NavItem
active={isProfileActive}
diff --git a/src/features/AgentSidebar/Topic/ViewAllAction.tsx b/src/features/AgentSidebar/Topic/ViewAllAction.tsx
new file mode 100644
index 00000000000..7d14dcb99fc
--- /dev/null
+++ b/src/features/AgentSidebar/Topic/ViewAllAction.tsx
@@ -0,0 +1,34 @@
+import { ActionIcon } from '@lobehub/ui';
+import { ArrowRight } from 'lucide-react';
+import { memo, type MouseEvent } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useOpenActiveAgentTopics } from './hooks/useTopicNavigation';
+
+/**
+ * Header entry to the agent's full topic page (`/agent/:aid/topics`), the same
+ * arrow the home sidebar's Agents section uses for its view-all page.
+ */
+const ViewAllAction = memo(() => {
+ const { t } = useTranslation('chat');
+ const openTopics = useOpenActiveAgentTopics();
+
+ if (!openTopics) return null;
+
+ return (
+ <ActionIcon
+ icon={ArrowRight}
+ size={'small'}
+ title={t('topic.viewAll')}
+ onClick={(e: MouseEvent) => {
+ // Stop the click from toggling the accordion header.
+ e.stopPropagation();
+ openTopics();
+ }}
+ />
+ );
+});
+
+ViewAllAction.displayName = 'TopicViewAllAction';
+
+export default ViewAllAction;
diff --git a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
index b1046d4cad2..4cf3b113095 100644
--- a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
+++ b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
@@ -5,7 +5,11 @@ import { act, renderHook } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { TopicListScopeContext } from '../TopicListScope';
-import { useNavigateToAgentTopics, useTopicNavigation } from './useTopicNavigation';
+import {
+ useNavigateToAgentTopics,
+ useOpenActiveAgentTopics,
+ useTopicNavigation,
+} from './useTopicNavigation';
const switchTopicMock = vi.hoisted(() => vi.fn());
const toggleMobileTopicMock = vi.hoisted(() => vi.fn());
@@ -230,4 +234,23 @@ describe('useTopicNavigation', () => {
expect(pushMock).toHaveBeenCalledWith('/agent/agent-1/topics');
});
+
+ it('leaves the current topic and opens the active agent topics page', () => {
+ const { result } = renderHook(() => useOpenActiveAgentTopics());
+
+ act(() => {
+ result.current?.();
+ });
+
+ expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });
+ expect(pushMock).toHaveBeenCalledWith('/agent/agent-1/topics');
+ });
+
+ it('offers no topics-page entry before an agent is active', () => {
+ chatStoreStateMock.activeAgentId = undefined;
+
+ const { result } = renderHook(() => useOpenActiveAgentTopics());
+
+ expect(result.current).toBeUndefined();
+ });
});
diff --git a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
index 25f4987e066..4858a3728e1 100644
--- a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
+++ b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
@@ -124,3 +124,22 @@ export const useNavigateToAgentTopics = () => {
[router],
);
};
+
+/**
+ * Opens the active agent's full topic page from the sidebar. Leaves the current
+ * topic first so the page doesn't open over a stale chat. `undefined` until an
+ * agent is active, so callers can hide the entry instead of rendering a no-op.
+ */
+export const useOpenActiveAgentTopics = () => {
+ const [activeAgentId, switchTopic] = useChatStore((s) => [s.activeAgentId, s.switchTopic]);
+ const navigateToAgentTopics = useNavigateToAgentTopics();
+
+ return useMemo(() => {
+ if (!activeAgentId) return undefined;
+
+ return () => {
+ switchTopic(null, { skipRefreshMessage: true });
+ navigateToAgentTopics(activeAgentId);
+ };
+ }, [activeAgentId, navigateToAgentTopics, switchTopic]);
+};
diff --git a/src/features/AgentSidebar/Topic/index.tsx b/src/features/AgentSidebar/Topic/index.tsx
index 82e02edef1c..084a08c09d6 100644
--- a/src/features/AgentSidebar/Topic/index.tsx
+++ b/src/features/AgentSidebar/Topic/index.tsx
@@ -21,12 +21,14 @@ import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useFetchChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
import { operationSelectors, topicSelectors } from '@/store/chat/selectors';
+import { isMobileSurface } from '@/utils/mobileSurface';
import Actions from './Actions';
import Filter from './Filter';
import List from './List';
import ToggleGroups from './ToggleGroups';
import { useTopicActionsDropdownMenu } from './useDropdownMenu';
+import ViewAllAction from './ViewAllAction';
/**
* Cadence of the candidate-gated stale-run sweep. A run whose terminal frame
@@ -136,9 +138,13 @@ const Topic = memo<TopicProps>(({ expanded, itemKey }) => {
'accordion-action',
accordionStyles.action,
accordionStyles.actionBorderless,
+ // Touch has no hover to reveal these, and the arrow is the only
+ // entry to the full topic page.
+ isMobileSurface() && accordionStyles.actionAlwaysVisible,
)}
>
<Flexbox horizontal align="center" gap={2}>
+ <ViewAllAction />
<ToggleGroups />
<Filter />
<Actions />