🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(topic): offer Unarchive in the bulk bar when every selected topic is archived (#21876)
AmAzing-0a2806017ca4
diff --git a/locales/en-US/topic.json b/locales/en-US/topic.jsonindex b9e7487a02b..60cf2ddbac8 100644--- a/locales/en-US/topic.json+++ b/locales/en-US/topic.json@@ -180,6 +180,7 @@"management.bulk.pin": "Pin","management.bulk.selectedCount_one": "{{count}} selected","management.bulk.selectedCount_other": "{{count}} selected",+ "management.bulk.unarchive": "Unarchive","management.card.noPreview": "No preview available","management.columns.project": "Project","management.columns.status": "Status",diff --git a/locales/zh-CN/topic.json b/locales/zh-CN/topic.jsonindex 7e71d840fce..c13c02b8834 100644--- a/locales/zh-CN/topic.json+++ b/locales/zh-CN/topic.json@@ -180,6 +180,7 @@"management.bulk.pin": "置顶","management.bulk.selectedCount_one": "已选 {{count}} 项","management.bulk.selectedCount_other": "已选 {{count}} 项",+ "management.bulk.unarchive": "取消归档","management.card.noPreview": "暂无预览内容","management.columns.project": "项目","management.columns.status": "状态",diff --git a/packages/locales/src/default/topic.ts b/packages/locales/src/default/topic.tsindex 2d2254c5bcc..107b62938e3 100644--- a/packages/locales/src/default/topic.ts+++ b/packages/locales/src/default/topic.ts@@ -235,6 +235,7 @@ export default {'management.bulk.moveSearchPlaceholder': 'Search agents…','management.bulk.selectedCount_one': '{{count}} selected','management.bulk.selectedCount_other': '{{count}} selected',+ 'management.bulk.unarchive': 'Unarchive','management.card.noPreview': 'No preview available','management.columns.project': 'Project','management.columns.status': 'Status',diff --git a/src/features/AgentTopicManager/BulkActionBar.tsx b/src/features/AgentTopicManager/BulkActionBar.tsxindex 78822050856..ae05b823f9b 100644--- a/src/features/AgentTopicManager/BulkActionBar.tsx+++ b/src/features/AgentTopicManager/BulkActionBar.tsx@@ -1,17 +1,19 @@'use client';import { ActionIcon, createStaticStyles, cssVar, Flexbox, Text } from '@lobehub/ui';-import { Archive, FolderInput, Pin, Trash2, X } from 'lucide-react';-import { memo, useCallback } from 'react';+import { Archive, ArchiveRestore, FolderInput, Pin, Trash2, X } from 'lucide-react';+import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { confirmRemoveTopic } from '@/features/DeleteTopicConfirm';import { openAssociateTopicModal } from '@/features/Projects/WorkingDirectories/AssociateTopicModal';import { usePermission } from '@/hooks/usePermission';import { useChatStore } from '@/store/chat';+import type { ChatTopic } from '@/types/topic';import MoveToAgentButton from './MoveToAgentButton';import { useTopicsViewStore } from './store';+import { areAllTopicsArchived } from './utils';const styles = createStaticStyles(({ css }) => ({bar: css`@@ -44,7 +46,11 @@ const styles = createStaticStyles(({ css }) => ({`,}));-const BulkActionBar = memo(() => {+interface BulkActionBarProps {+ topics: ChatTopic[];+}++const BulkActionBar = memo<BulkActionBarProps>(({ topics }) => {const { t } = useTranslation('topic');const { allowed: canEditTopic } = usePermission('edit_own_content');@@ -55,6 +61,12 @@ const BulkActionBar = memo(() => {const favoriteTopic = useChatStore((s) => s.favoriteTopic);const updateTopicStatus = useChatStore((s) => s.updateTopicStatus);const removeTopic = useChatStore((s) => s.removeTopic);+ const unmarkTopicCompleted = useChatStore((s) => s.unmarkTopicCompleted);++ const allArchived = useMemo(+ () => areAllTopicsArchived(topics, selectedIds),+ [topics, selectedIds],+ );const handleBatchFavorite = useCallback(async () => {await Promise.all(selectedIds.map((id) => favoriteTopic(id, true)));@@ -70,6 +82,11 @@ const BulkActionBar = memo(() => {exitSelectMode();}, [selectedIds, updateTopicStatus, exitSelectMode]);+ const handleBatchUnarchive = useCallback(async () => {+ await Promise.all(selectedIds.map((id) => unmarkTopicCompleted(id)));+ exitSelectMode();+ }, [selectedIds, unmarkTopicCompleted, exitSelectMode]);+const handleBatchDelete = useCallback(() => {void confirmRemoveTopic({content: t('management.bulk.deleteConfirm', { count: selectedIds.length }),@@ -101,12 +118,21 @@ const BulkActionBar = memo(() => {title={t('management.bulk.pin')}onClick={handleBatchFavorite}/>- <ActionIcon- icon={Archive}- size={'small'}- title={t('management.bulk.archive')}- onClick={handleBatchArchive}- />+ {allArchived ? (+ <ActionIcon+ icon={ArchiveRestore}+ size={'small'}+ title={t('management.bulk.unarchive')}+ onClick={handleBatchUnarchive}+ />+ ) : (+ <ActionIcon+ icon={Archive}+ size={'small'}+ title={t('management.bulk.archive')}+ onClick={handleBatchArchive}+ />+ )}<MoveToAgentButton />{selectedIds.length === 1 && canEditTopic && (<ActionIcondiff --git a/src/features/AgentTopicManager/index.tsx b/src/features/AgentTopicManager/index.tsxindex 78312354a18..3fd6c0f9ed6 100644--- a/src/features/AgentTopicManager/index.tsx+++ b/src/features/AgentTopicManager/index.tsx@@ -241,7 +241,7 @@ const AgentTopicManager = memo(() => {projects={projects}statusCounts={statusCounts}/>- <BulkActionBar />+ <BulkActionBar topics={baseTopics} />{!isSearchMode && error && !isLoading && baseTopics.length === 0 ? (<AsyncErrorerror={error}diff --git a/src/features/AgentTopicManager/utils.test.ts b/src/features/AgentTopicManager/utils.test.tsindex 498d4e913a2..eb110d7c8af 100644--- a/src/features/AgentTopicManager/utils.test.ts+++ b/src/features/AgentTopicManager/utils.test.ts@@ -1,6 +1,7 @@import type { ChatTopic } from '@/types/topic';import {+ areAllTopicsArchived,buildBotChannelOptions,getBotPlatformName,getProjectFilterLabel,@@ -24,6 +25,19 @@ const createTopic = (});describe('AgentTopicManager utils', () => {+ it('offers unarchive only when every selected topic is archived', () => {+ const topics = [+ createTopic(undefined, { id: 'a', status: 'completed' }),+ createTopic(undefined, { id: 'b', status: 'archived' }),+ createTopic(undefined, { id: 'c', status: 'active' }),+ ];++ expect(areAllTopicsArchived(topics, ['a', 'b'])).toBe(true);+ expect(areAllTopicsArchived(topics, ['a', 'c'])).toBe(false);+ expect(areAllTopicsArchived(topics, ['missing'])).toBe(false);+ expect(areAllTopicsArchived(topics, [])).toBe(false);+ });+it('keeps channel search results hidden after clearing the trigger filter', () => {expect(matchesTrigger(createTopic({}, { trigger: 'channel' }), [])).toBe(false);expect(matchesTrigger(createTopic({}, { trigger: 'channel' }), ['chat'])).toBe(false);diff --git a/src/features/AgentTopicManager/utils.ts b/src/features/AgentTopicManager/utils.tsindex 95a4471435c..be3dd8fa472 100644--- a/src/features/AgentTopicManager/utils.ts+++ b/src/features/AgentTopicManager/utils.ts@@ -42,6 +42,19 @@ export const matchesStatus = (topic: ChatTopic, status: StatusFilter): boolean =}};+/**+ * True when every selected topic is already archived (`completed` in the UI),+ * so the bulk bar should offer "Unarchive" instead of "Archive".+ */+export const areAllTopicsArchived = (topics: ChatTopic[], ids: string[]): boolean => {+ if (ids.length === 0) return false;+ const statusById = new Map(topics.map((t) => [t.id, t.status]));+ return ids.every((id) => {+ const status = statusById.get(id);+ return status === 'completed' || status === 'archived';+ });+};+export const matchesGroup = (topic: ChatTopic, groupIds: string[]): boolean => {if (groupIds.length === 0) return true;// ChatTopic doesn't surface groupId on the client type; fall back to the