🤯 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
🐛 fix(topic): keep the workspace prefix on copied topic links (#21353)
Arvin Xu2153c4f6079b
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsxindex a361c230603..87c643fa8d4 100644--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx@@ -35,7 +35,10 @@ const permissionMock = vi.hoisted(() => ({edit_own_content: true,}));const versionMock = vi.hoisted(() => ({ isDesktop: false }));-const workspaceMock = vi.hoisted(() => ({ id: null as string | null }));+const workspaceMock = vi.hoisted(() => ({+ id: null as string | null,+ slug: null as string | null,+}));vi.mock('antd', async (importOriginal) => ({...(await importOriginal<object>()),@@ -55,6 +58,10 @@ vi.mock('@/business/client/hooks/useActiveWorkspaceId', () => ({useActiveWorkspaceId: () => workspaceMock.id,}));+vi.mock('@/business/client/hooks/useActiveWorkspaceSlug', () => ({+ useActiveWorkspaceSlug: () => workspaceMock.slug,+}));+const labState = vi.hoisted(() => ({ enableTopicBugReport: false }));const bugReportTargetMock = vi.hoisted(() => vi.fn());vi.mock('@/business/client/hooks/useTopicBugReportMenuItem', () => ({@@ -148,6 +155,7 @@ describe('useTopicItemDropdownMenu', () => {permissionMock.edit_own_content = true;versionMock.isDesktop = false;workspaceMock.id = null;+ workspaceMock.slug = null;labState.enableTopicBugReport = false;});@@ -235,6 +243,19 @@ describe('useTopicItemDropdownMenu', () => {expect(writeText).toHaveBeenCalledWith('https://example.com/agent/agent-other/topic-1');});+ it('keeps the active workspace prefix in the copied link', async () => {+ workspaceMock.slug = 'lobehub';+ const writeText = vi.fn();+ vi.spyOn(navigator, 'clipboard', 'get').mockReturnValue({ writeText } as unknown as Clipboard);+ const { result } = renderHook(() =>+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),+ );+ const item = getMenuItem(result.current.dropdownMenu(), 'copyLink');+ if (!item || !('onClick' in item)) throw new Error('Missing copy link');+ await item.onClick?.({} as never);+ expect(writeText).toHaveBeenCalledWith('https://example.com/lobehub/agent/agent-1/topic-1');+ });+it.each(['favorite', 'markCompleted'])('refreshes the Project list immediately after %s',async (key) => {diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsxindex 1d6ca185841..7fd24e01efd 100644--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx@@ -241,7 +241,10 @@ export const useTopicItemDropdownMenu = ({label: t('actions.copyLink'),onClick: async () => {if (!activeAgentId) return;- const url = `${appOrigin}${AGENT_CHAT_TOPIC_URL(activeAgentId, id)}`;+ const url = `${appOrigin}${buildWorkspaceAwarePath(+ AGENT_CHAT_TOPIC_URL(activeAgentId, id),+ activeWorkspaceSlug,+ )}`;await copyToClipboard(url);toast.success(t('actions.copyLinkSuccess'));},diff --git a/src/features/PageEditor/Copilot/TopicSelector/useDropdownMenu.tsx b/src/features/PageEditor/Copilot/TopicSelector/useDropdownMenu.tsxindex 9d36e39ef30..828850e3904 100644--- a/src/features/PageEditor/Copilot/TopicSelector/useDropdownMenu.tsx+++ b/src/features/PageEditor/Copilot/TopicSelector/useDropdownMenu.tsx@@ -202,7 +202,10 @@ export const useDropdownMenu = ({label: t('actions.copyLink', { ns: 'topic' }),onClick: () => {if (!agentId) return;- const url = `${appOrigin}${AGENT_CHAT_TOPIC_URL(agentId, topicId)}`;+ const url = `${appOrigin}${buildWorkspaceAwarePath(+ AGENT_CHAT_TOPIC_URL(agentId, topicId),+ activeWorkspaceSlug,+ )}`;void navigator.clipboard.writeText(url);toast.success(t('actions.copyLinkSuccess', { ns: 'topic' }));},