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.

✨ feat(topic): one-click archive on heterogeneous agent topic rows (#21624)

AmAzing-ab95ec6d629a
diff --git a/packages/database/src/models/__tests__/project.test.ts b/packages/database/src/models/__tests__/project.test.ts
index 6174c5628c0..828cbd1b9ad 100644
--- a/packages/database/src/models/__tests__/project.test.ts
+++ b/packages/database/src/models/__tests__/project.test.ts
@@ -1060,6 +1060,33 @@ describe('ProjectModel', () => {
});
});
+ it("carries each agent's heterogeneous provider type on its project topics", async () => {
+ const project = await createProject(model, { name: 'External runtime' });
+ const [external] = await serverDB
+ .insert(agents)
+ .values({
+ agencyConfig: { heterogeneousProvider: { command: 'claude', type: 'claude-code' } },
+ title: 'Claude Code',
+ userId,
+ })
+ .returning();
+ const topicModel = new TopicModel(serverDB, userId);
+ await topicModel.create({ agentId: external.id, projectId: project.id, title: 'External' });
+ await topicModel.create({
+ agentId: project.coordinatorAgentId,
+ projectId: project.id,
+ title: 'Built-in',
+ });
+
+ const list = await model.listTopics(project.id);
+ expect(list.find((t) => t.agentId === external.id)).toMatchObject({
+ agentHeterogeneousProviderType: 'claude-code',
+ });
+ expect(list.find((t) => t.agentId === project.coordinatorAgentId)).toMatchObject({
+ agentHeterogeneousProviderType: null,
+ });
+ });
+
it('keeps agentless conversations visible in project listings', async () => {
const project = await createProject(model, { name: 'Agentless host' });
const topic = await new TopicModel(serverDB, userId).create({
diff --git a/packages/database/src/models/project.ts b/packages/database/src/models/project.ts
index cbe7ecd299c..87f36d8b740 100644
--- a/packages/database/src/models/project.ts
+++ b/packages/database/src/models/project.ts
@@ -1074,6 +1074,11 @@ export class ProjectModel {
string | null
>`${agents.agencyConfig}->>'executionTargetSelectionPolicy'`,
agentBoundDeviceId: sql<string | null>`${agents.agencyConfig}->>'boundDeviceId'`,
+ // Lets a row act on its agent's external runtime (Claude Code / Codex)
+ // when that agent's config has never been loaded into the client store.
+ agentHeterogeneousProviderType: sql<
+ string | null
+ >`${agents.agencyConfig}->'heterogeneousProvider'->>'type'`,
updatedAt: topics.updatedAt,
projectWorkingDirectoryId: topics.projectWorkingDirectoryId,
})
diff --git a/src/features/AgentSidebar/Topic/List/Item/Actions.tsx b/src/features/AgentSidebar/Topic/List/Item/Actions.tsx
index b70d4a2f81e..f3f942eba70 100644
--- a/src/features/AgentSidebar/Topic/List/Item/Actions.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/Actions.tsx
@@ -1,20 +1,40 @@
import { ActionIcon, DropdownMenu } from '@lobehub/ui';
-import { MoreHorizontalIcon } from 'lucide-react';
+import { Archive, ArchiveRestore, MoreHorizontalIcon } from 'lucide-react';
import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
import { useOverlayDropdownPortalProps } from '@/features/NavPanel/OverlayContainer';
import { type TopicItemDropdownMenuProps, useTopicItemDropdownMenu } from './useDropdownMenu';
-const Actions = memo<TopicItemDropdownMenuProps>(({ completionLabel, fav, id, status, title }) => {
- const { dropdownMenu } = useTopicItemDropdownMenu({ completionLabel, fav, id, status, title });
- const dropdownPortalProps = useOverlayDropdownPortalProps();
+interface ActionsProps extends TopicItemDropdownMenuProps {
+ /** Only the sidebar row opts in to the inline archive icon — headers keep the menu. */
+ showInlineArchive?: boolean;
+}
- return (
- <DropdownMenu items={dropdownMenu} portalProps={dropdownPortalProps}>
- <ActionIcon icon={MoreHorizontalIcon} size={'small'} />
- </DropdownMenu>
- );
-});
+const Actions = memo<ActionsProps>(
+ ({ completionLabel, fav, id, showInlineArchive, status, title }) => {
+ const { t } = useTranslation('topic');
+ const { canInlineArchive, dropdownMenu, isCompleted, toggleCompleted } =
+ useTopicItemDropdownMenu({ completionLabel, fav, id, status, title });
+ const dropdownPortalProps = useOverlayDropdownPortalProps();
+
+ return (
+ <>
+ {showInlineArchive && canInlineArchive && (
+ <ActionIcon
+ icon={isCompleted ? ArchiveRestore : Archive}
+ size={'small'}
+ title={isCompleted ? t('actions.unmarkCompleted') : t('actions.markCompleted')}
+ onClick={() => void toggleCompleted()}
+ />
+ )}
+ <DropdownMenu items={dropdownMenu} portalProps={dropdownPortalProps}>
+ <ActionIcon icon={MoreHorizontalIcon} size={'small'} />
+ </DropdownMenu>
+ </>
+ );
+ },
+);
export default Actions;
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index 1dabe4c7edc..1d2d8a8be34 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -591,7 +591,6 @@ const TopicItemRow = memo<TopicItemRowProps>(
<TopicItemContextMenu fav={fav} id={id} status={status} title={title}>
<NavItem
draggable
- actions={() => <Actions fav={fav} id={id} status={status} title={title} />}
active={isTopicActive}
description={workingDirectoryNode}
href={href}
@@ -599,6 +598,9 @@ const TopicItemRow = memo<TopicItemRowProps>(
slots={{ titlePrefix: draftPrefix }}
title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}
titleColor={cssVar.colorText}
+ actions={() => (
+ <Actions showInlineArchive fav={fav} id={id} status={status} title={title} />
+ )}
extra={
<>
{scopedTopic && !suppressAgentAvatar && ownIconNode}
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
index bf5cae82a64..22af87b8f4e 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
@@ -13,7 +13,10 @@ const confirmDeleteMock = vi.hoisted(() => vi.fn());
vi.mock('@/features/DeleteTopicConfirm', () => ({ confirmRemoveTopic: confirmDeleteMock }));
vi.mock('@/hooks/useActiveLocation', () => ({ useActiveLocation: () => locationFixture }));
-const scopeFixture = vi.hoisted(() => ({ enabled: false }));
+const scopeFixture = vi.hoisted(() => ({
+ enabled: false,
+ providerType: null as string | null,
+}));
const refreshProjectMock = vi.hoisted(() => vi.fn());
const navigateMock = vi.hoisted(() => vi.fn());
const autoRenameMock = vi.hoisted(() => vi.fn());
@@ -22,7 +25,13 @@ const completeMock = vi.hoisted(() => vi.fn());
const cloneMock = vi.hoisted(() => vi.fn());
vi.mock('../../useScopedTopics', () => ({
useScopedTopic: () =>
- scopeFixture.enabled ? { id: 'topic-1', agentId: 'agent-other' } : undefined,
+ scopeFixture.enabled
+ ? {
+ agentHeterogeneousProviderType: scopeFixture.providerType,
+ agentId: 'agent-other',
+ id: 'topic-1',
+ }
+ : undefined,
useScopedTopics: () => ({
scope: scopeFixture.enabled ? { projectId: 'project-1' } : null,
refresh: refreshProjectMock,
@@ -114,9 +123,10 @@ vi.mock('@/hooks/usePermission', () => ({
}),
}));
+const agentMapFixture = vi.hoisted(() => ({ value: {} as Record<string, unknown> }));
vi.mock('@/store/agent', () => ({
useAgentStore: (selector: (state: Record<string, unknown>) => unknown) =>
- selector({ activeAgentId: 'agent-1' }),
+ selector({ activeAgentId: 'agent-1', agentMap: agentMapFixture.value }),
}));
vi.mock('@/store/chat', () => ({
@@ -150,6 +160,7 @@ const getMenuItem = (
describe('useTopicItemDropdownMenu', () => {
beforeEach(() => {
scopeFixture.enabled = false;
+ scopeFixture.providerType = null;
vi.clearAllMocks();
permissionMock.create_content = true;
permissionMock.edit_own_content = true;
@@ -157,6 +168,7 @@ describe('useTopicItemDropdownMenu', () => {
workspaceMock.id = null;
workspaceMock.slug = null;
labState.enableTopicBugReport = false;
+ agentMapFixture.value = {};
});
afterEach(() => {
@@ -378,4 +390,62 @@ describe('useTopicItemDropdownMenu', () => {
expect(getMenuItem(items, 'copyLink')).not.toMatchObject({ disabled: true });
expect(getMenuItem(items, 'copyTopicPrompt')).not.toMatchObject({ disabled: true });
});
+
+ describe('inline archive', () => {
+ const heterogeneousAgent = {
+ agencyConfig: { heterogeneousProvider: { type: 'claude-code' } },
+ };
+
+ it('is offered for heterogeneous agent topics and archives on toggle', async () => {
+ agentMapFixture.value = { 'agent-1': heterogeneousAgent };
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+
+ expect(result.current.canInlineArchive).toBe(true);
+ expect(result.current.isCompleted).toBe(false);
+ await result.current.toggleCompleted();
+
+ expect(completeMock).toHaveBeenCalledWith('topic-1');
+ });
+
+ it('resolves the row Agent rather than the active one', () => {
+ scopeFixture.enabled = true;
+ agentMapFixture.value = { 'agent-other': heterogeneousAgent };
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+
+ expect(result.current.canInlineArchive).toBe(true);
+ });
+
+ it('is offered for a project row whose agent config was never loaded', () => {
+ scopeFixture.enabled = true;
+ scopeFixture.providerType = 'claude-code';
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+
+ expect(result.current.canInlineArchive).toBe(true);
+ });
+
+ it('is not offered for regular agents', () => {
+ agentMapFixture.value = { 'agent-1': { agencyConfig: {} } };
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+
+ expect(result.current.canInlineArchive).toBe(false);
+ });
+
+ it('is not offered to viewers without edit permission', () => {
+ agentMapFixture.value = { 'agent-1': heterogeneousAgent };
+ permissionMock.edit_own_content = false;
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+
+ expect(result.current.canInlineArchive).toBe(false);
+ });
+ });
});
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
index f7e91ca1613..37b1818f418 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
@@ -42,6 +42,7 @@ import { useAppOrigin } from '@/hooks/useAppOrigin';
import { usePermission } from '@/hooks/usePermission';
import { topicService } from '@/services/topic';
import { useAgentStore } from '@/store/agent';
+import { agentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
import { useElectronStore } from '@/store/electron';
import { useGlobalStore } from '@/store/global';
@@ -83,6 +84,14 @@ export const useTopicItemDropdownMenu = ({
const { scope, refresh } = useScopedTopics();
const fallbackAgentId = useAgentStore((s) => s.activeAgentId);
const activeAgentId = scopedTopic?.agentId ?? fallbackAgentId;
+ // Project rows carry their agent's provider type, since a cold project visit
+ // never loads each row agent's config into the store.
+ const isHeterogeneous = useAgentStore(
+ (s) =>
+ !!scopedTopic?.agentHeterogeneousProviderType ||
+ (!!activeAgentId &&
+ !!agentSelectors.getAgentConfigById(activeAgentId)(s)?.agencyConfig?.heterogeneousProvider),
+ );
const addTab = useElectronStore((s) => s.addTab);
const appOrigin = useAppOrigin();
const enableTopicBugReport = useUserStore(labPreferSelectors.enableTopicBugReport);
@@ -107,6 +116,13 @@ export const useTopicItemDropdownMenu = ({
]);
const isCompleted = status === 'completed';
+ const toggleCompleted = useCallback(async () => {
+ if (!id) return;
+ if (isCompleted) await unmarkTopicCompleted(id);
+ else await markTopicCompleted(id);
+ if (scope) await refresh();
+ }, [id, isCompleted, markTopicCompleted, unmarkTopicCompleted, scope, refresh]);
+
const handleOpenShareModal = useCallback(() => {
if (!id) return;
@@ -124,11 +140,7 @@ export const useTopicItemDropdownMenu = ({
label:
completionLabel ??
(isCompleted ? t('actions.unmarkCompleted') : t('actions.markCompleted')),
- onClick: async () => {
- if (isCompleted) await unmarkTopicCompleted(id);
- else await markTopicCompleted(id);
- if (scope) await refresh();
- },
+ onClick: toggleCompleted,
sfSymbol: isCompleted ? 'tray.and.arrow.up' : 'archivebox',
},
{
@@ -376,8 +388,7 @@ export const useTopicItemDropdownMenu = ({
autoRenameTopicTitle,
duplicateTopic,
favoriteTopic,
- markTopicCompleted,
- unmarkTopicCompleted,
+ toggleCompleted,
removeTopic,
updateTopicTitle,
openTopicInNewWindow,
@@ -387,5 +398,9 @@ export const useTopicItemDropdownMenu = ({
t,
handleOpenShareModal,
]);
- return { dropdownMenu };
+ // Heterogeneous agents (Claude Code / Codex) run task-like topics that get
+ // archived once done, so their sidebar rows surface archive as a one-click action.
+ const canInlineArchive = !!id && canEditTopic && isHeterogeneous;
+
+ return { canInlineArchive, dropdownMenu, isCompleted, toggleCompleted };
};