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.

♻️ refactor(project): serve project topics under /topic instead of /conversation (#21558)

LiJianf507455bbdfd
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
index 2ac99900c73..bd171ce618f 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
@@ -251,7 +251,7 @@ describe('TopicItem active state', () => {
);
expect(screen.getByTestId('nav-item')).toHaveAttribute(
'data-href',
- '/team/project/project-1/conversation/project-topic',
+ '/team/project/project-1/topic/project-topic',
);
expect(screen.getByTestId('nav-item')).toHaveAttribute('data-active', 'true');
});
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index 056344e8b86..1dabe4c7edc 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -37,7 +37,7 @@ import DirIcon from '@/features/ChatInput/ControlBar/DirIcon';
import { useHasDraft } from '@/features/ChatInput/draftStorage';
import { startTopicDrag } from '@/features/ChatInput/InputEditor/ReferTopic/topicDragData';
import NavItem from '@/features/NavPanel/components/NavItem';
-import { getProjectConversationPath } from '@/features/Projects/Layout/navigation';
+import { getProjectTopicPath } from '@/features/Projects/Layout/navigation';
import TopicCreatorAvatar, { useTopicCreator } from '@/features/TopicCreatorAvatar';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
import { getWorkingDirectoryName } from '@/helpers/workingDirectoryPath';
@@ -301,9 +301,7 @@ const TopicItemRow = memo<TopicItemRowProps>(
const href = useMemo(() => {
if (!activeAgentId || !id) return undefined;
return buildWorkspaceAwarePath(
- scope
- ? getProjectConversationPath(scope.projectId, id)
- : AGENT_CHAT_TOPIC_URL(activeAgentId, id),
+ scope ? getProjectTopicPath(scope.projectId, id) : AGENT_CHAT_TOPIC_URL(activeAgentId, id),
activeWorkspaceSlug,
);
}, [activeAgentId, activeWorkspaceSlug, id, scope]);
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
index 87c643fa8d4..bf5cae82a64 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { buildTopicPrompt } from './buildTopicPrompt';
import { useTopicItemDropdownMenu } from './useDropdownMenu';
-const locationFixture = vi.hoisted(() => ({ pathname: '/project/project-1/conversation/topic-1' }));
+const locationFixture = vi.hoisted(() => ({ pathname: '/project/project-1/topic/topic-1' }));
const removeMock = vi.hoisted(() => vi.fn());
const confirmDeleteMock = vi.hoisted(() => vi.fn());
vi.mock('@/features/DeleteTopicConfirm', () => ({ confirmRemoveTopic: confirmDeleteMock }));
@@ -208,8 +208,8 @@ describe('useTopicItemDropdownMenu', () => {
});
it.each([
- ['/team/project/project-1/conversation/topic-1', true],
- ['/project/project-1/conversation/topic-other', false],
+ ['/team/project/project-1/topic/topic-1', true],
+ ['/project/project-1/topic/topic-other', false],
['/project/project-1/settings', false],
])(
'after deleting a Project row at %s, navigates home only for the current Topic',
@@ -293,7 +293,7 @@ describe('useTopicItemDropdownMenu', () => {
await item.onClick?.({} as never);
expect(cloneMock).toHaveBeenCalled();
expect(refreshProjectMock).toHaveBeenCalledOnce();
- expect(navigateMock).toHaveBeenCalledWith('/project/project-1/conversation/topic-copy');
+ expect(navigateMock).toHaveBeenCalledWith('/project/project-1/topic/topic-copy');
});
it('keeps project association out of the individual topic menu', () => {
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
index 7fd24e01efd..f7e91ca1613 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
@@ -32,7 +32,7 @@ import { isDesktop } from '@/const/version';
import { createMoveTopicsModal } from '@/features/AgentTopicManager/MoveTopicsModal';
import { createTopicForwardModal } from '@/features/Conversation/MessageForward/TopicForwardModal';
import { confirmRemoveTopic } from '@/features/DeleteTopicConfirm';
-import { getProjectConversationPath } from '@/features/Projects/Layout/navigation';
+import { getProjectTopicPath } from '@/features/Projects/Layout/navigation';
import { openShareModal } from '@/features/ShareModal';
import { openTopicDoctorModal } from '@/features/TopicDoctorModal';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -72,7 +72,7 @@ export const useTopicItemDropdownMenu = ({
const navigate = useWorkspaceAwareNavigate();
const activeWorkspaceId = useActiveWorkspaceId();
const { pathname } = useActiveLocation();
- const routeTopicId = pathname.match(/\/project\/[^/]+\/conversation\/([^/]+)\/?$/)?.[1];
+ const routeTopicId = pathname.match(/\/project\/[^/]+\/topic\/([^/]+)\/?$/)?.[1];
const activeWorkspaceSlug = useActiveWorkspaceSlug();
const { allowed: canCreateTopic } = usePermission('create_content');
const { allowed: canEditTopic } = usePermission('edit_own_content');
@@ -275,7 +275,7 @@ export const useTopicItemDropdownMenu = ({
t('duplicateTitle', { ns: 'chat', title }),
);
await refresh();
- navigate(getProjectConversationPath(scope.projectId, newId));
+ navigate(getProjectTopicPath(scope.projectId, newId));
toast.success(t('duplicateSuccess', { ns: 'topic' }));
} finally {
loadingToast.close();
diff --git a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
index 0e5efaba515..b1046d4cad2 100644
--- a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
+++ b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.test.tsx
@@ -77,7 +77,7 @@ describe('useTopicNavigation', () => {
),
});
await act(async () => result.current.navigateToTopic('topic-other-agent'));
- expect(pushMock).toHaveBeenCalledWith('/team/project/project-1/conversation/topic-other-agent');
+ expect(pushMock).toHaveBeenCalledWith('/team/project/project-1/topic/topic-other-agent');
expect(switchTopicMock).not.toHaveBeenCalled();
expect(focusTopicPopupMock).not.toHaveBeenCalled();
});
diff --git a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
index 6e1073f2470..25f4987e066 100644
--- a/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
+++ b/src/features/AgentSidebar/Topic/hooks/useTopicNavigation.ts
@@ -3,7 +3,7 @@ import { useCallback, useMemo } from 'react';
import urlJoin from 'url-join';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
-import { getProjectConversationPath } from '@/features/Projects/Layout/navigation';
+import { getProjectTopicPath } from '@/features/Projects/Layout/navigation';
import { useFocusTopicPopup } from '@/features/TopicPopupGuard/useTopicPopupsRegistry';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
import { useActiveLocation } from '@/hooks/useActiveLocation';
@@ -66,7 +66,7 @@ export const useTopicNavigation = () => {
if (scope && topicId) {
router.push(
buildWorkspaceAwarePath(
- getProjectConversationPath(scope.projectId, topicId),
+ getProjectTopicPath(scope.projectId, topicId),
activeWorkspaceSlug,
),
);
diff --git a/src/features/Electron/ActiveConversationBridge/coordinate.test.ts b/src/features/Electron/ActiveConversationBridge/coordinate.test.ts
index 3b4a373117c..2b2f0986ea2 100644
--- a/src/features/Electron/ActiveConversationBridge/coordinate.test.ts
+++ b/src/features/Electron/ActiveConversationBridge/coordinate.test.ts
@@ -56,63 +56,63 @@ describe('active conversation coordinate', () => {
it('resolves a project conversation route and keeps topic navigation in the project route', () => {
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1', topicId: 'tpc_1' },
- url: '/project/prj_1/conversation/tpc_1?thread=thread-a',
+ url: '/project/prj_1/topic/tpc_1?thread=thread-a',
});
expect(coordinate).toMatchObject({
isConversation: true,
- projectBasePath: '/project/prj_1/conversation',
+ projectBasePath: '/project/prj_1/topic',
projectId: 'prj_1',
threadId: 'thread-a',
topicId: 'tpc_1',
});
expect(buildActiveConversationUrl(coordinate, 'tpc_2', null)).toBe(
- '/project/prj_1/conversation/tpc_2',
+ '/project/prj_1/topic/tpc_2',
);
});
it('keeps the workspace prefix in the project conversation base path', () => {
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1', topicId: 'tpc_1' },
- url: '/acme/project/prj_1/conversation/tpc_1',
+ url: '/acme/project/prj_1/topic/tpc_1',
});
- expect(coordinate.projectBasePath).toBe('/acme/project/prj_1/conversation');
+ expect(coordinate.projectBasePath).toBe('/acme/project/prj_1/topic');
expect(buildActiveConversationUrl(coordinate, 'tpc_2', null)).toBe(
- '/acme/project/prj_1/conversation/tpc_2',
+ '/acme/project/prj_1/topic/tpc_2',
);
});
it('resolves the route root when the project slug is literally "project"', () => {
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'project', topicId: 'tpc_1' },
- url: '/project/project/conversation/tpc_1',
+ url: '/project/project/topic/tpc_1',
});
expect(coordinate).toMatchObject({
isConversation: true,
- projectBasePath: '/project/project/conversation',
+ projectBasePath: '/project/project/topic',
projectId: 'project',
topicId: 'tpc_1',
});
expect(buildActiveConversationUrl(coordinate, 'tpc_2', null)).toBe(
- '/project/project/conversation/tpc_2',
+ '/project/project/topic/tpc_2',
);
});
it('resolves a project conversation route without a topic id', () => {
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1' },
- url: '/project/prj_1/conversation',
+ url: '/project/prj_1/topic',
});
expect(coordinate).toMatchObject({
isConversation: true,
- projectBasePath: '/project/prj_1/conversation',
+ projectBasePath: '/project/prj_1/topic',
projectId: 'prj_1',
topicId: null,
});
expect(buildActiveConversationUrl(coordinate, 'tpc_2', null)).toBe(
- '/project/prj_1/conversation/tpc_2',
+ '/project/prj_1/topic/tpc_2',
);
});
diff --git a/src/features/Electron/ActiveConversationBridge/coordinate.ts b/src/features/Electron/ActiveConversationBridge/coordinate.ts
index fd63a93c34c..f743fc59afc 100644
--- a/src/features/Electron/ActiveConversationBridge/coordinate.ts
+++ b/src/features/Electron/ActiveConversationBridge/coordinate.ts
@@ -46,18 +46,18 @@ export const resolveActiveConversationCoordinate = ({
(segment, index) =>
segment === 'project' &&
segments[index + 1] === params.projectId &&
- segments[index + 2] === 'conversation',
+ segments[index + 2] === 'topic',
)
: -1;
const projectSuffixLength =
- projectSegmentIndex < 0 || segments[projectSegmentIndex + 2] !== 'conversation'
+ projectSegmentIndex < 0 || segments[projectSegmentIndex + 2] !== 'topic'
? -1
: segments.length - projectSegmentIndex - 3;
const projectConversation =
!!params.projectId &&
projectSegmentIndex >= 0 &&
segments[projectSegmentIndex + 1] === params.projectId &&
- segments[projectSegmentIndex + 2] === 'conversation' &&
+ segments[projectSegmentIndex + 2] === 'topic' &&
(projectSuffixLength === 0 || (projectSuffixLength === 1 && params.topicId !== undefined));
const isConversation = agentConversation || groupConversation || projectConversation;
const agentBasePath =
diff --git a/src/features/Electron/ActiveConversationBridge/navigation.test.ts b/src/features/Electron/ActiveConversationBridge/navigation.test.ts
index a5769ed5c9d..ff4c5d6c837 100644
--- a/src/features/Electron/ActiveConversationBridge/navigation.test.ts
+++ b/src/features/Electron/ActiveConversationBridge/navigation.test.ts
@@ -82,7 +82,7 @@ describe('active conversation navigation', () => {
);
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1', topicId: 'tpc_1' },
- url: '/project/prj_1/conversation/tpc_1',
+ url: '/project/prj_1/topic/tpc_1',
});
const navigate = vi.fn();
projectActiveConversationCoordinate(coordinate);
@@ -91,7 +91,7 @@ describe('active conversation navigation', () => {
useChatStore.setState({ activeTopicId: 'tpc_2' }, false);
expect(navigate).toHaveBeenCalledTimes(1);
- expect(navigate).toHaveBeenCalledWith('/project/prj_1/conversation/tpc_2', { replace: true });
+ expect(navigate).toHaveBeenCalledWith('/project/prj_1/topic/tpc_2', { replace: true });
unsubscribe();
});
});
diff --git a/src/features/Electron/ActiveConversationBridge/projectCoordinate.test.ts b/src/features/Electron/ActiveConversationBridge/projectCoordinate.test.ts
index 110c2f42405..dded4c4514b 100644
--- a/src/features/Electron/ActiveConversationBridge/projectCoordinate.test.ts
+++ b/src/features/Electron/ActiveConversationBridge/projectCoordinate.test.ts
@@ -243,7 +243,7 @@ describe('active conversation projection', () => {
);
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1', topicId: 'tpc_1' },
- url: '/project/prj_1/conversation/tpc_1?thread=thread-new',
+ url: '/project/prj_1/topic/tpc_1?thread=thread-new',
});
projectActiveConversationCoordinate(coordinate);
@@ -274,7 +274,7 @@ describe('active conversation projection', () => {
);
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1', topicId: 'tpc_1' },
- url: '/project/prj_1/conversation/tpc_1',
+ url: '/project/prj_1/topic/tpc_1',
});
projectActiveConversationCoordinate(coordinate);
@@ -289,7 +289,7 @@ describe('active conversation projection', () => {
it('keeps the active agent on a project conversation route without a topic id', () => {
const coordinate = resolveActiveConversationCoordinate({
params: { projectId: 'prj_1' },
- url: '/project/prj_1/conversation',
+ url: '/project/prj_1/topic',
});
projectActiveConversationCoordinate(coordinate);
diff --git a/src/features/Electron/titlebar/TabBar/scope.test.ts b/src/features/Electron/titlebar/TabBar/scope.test.ts
index d2e92ad6e13..6e046668fd3 100644
--- a/src/features/Electron/titlebar/TabBar/scope.test.ts
+++ b/src/features/Electron/titlebar/TabBar/scope.test.ts
@@ -15,7 +15,7 @@ describe('desktop tab scope', () => {
// resolve as a phantom `workspace:<segment>` scope, so entering a project
// page scope-swapped the tab and replayed stale tabs from that bucket.
it('marks project, agents and goal routes as personal scope, not phantom workspaces', () => {
- expect(resolveTabScope('/project/prj_1/conversation/tpc_1')).toEqual({ type: 'personal' });
+ expect(resolveTabScope('/project/prj_1/topic/tpc_1')).toEqual({ type: 'personal' });
expect(resolveTabScope('/project/prj_1/acceptance')).toEqual({ type: 'personal' });
expect(resolveTabScope('/projects')).toEqual({ type: 'personal' });
expect(resolveTabScope('/agents')).toEqual({ type: 'personal' });
diff --git a/src/features/Projects/Conversation/index.tsx b/src/features/Projects/Conversation/index.tsx
index f2a87512ace..9b0c6703eca 100644
--- a/src/features/Projects/Conversation/index.tsx
+++ b/src/features/Projects/Conversation/index.tsx
@@ -25,7 +25,7 @@ import {
useProjectTopics,
} from '@/store/projectWorkingDirectory';
-import { getProjectConversationPath } from '../Layout/navigation';
+import { getProjectTopicPath } from '../Layout/navigation';
import { freshProjectTopicAgentId } from './freshProjectTopicAgentId';
import { projectConversationStage } from './projectConversationStage';
import { useMarkProjectTopicRead } from './useMarkProjectTopicRead';
@@ -107,12 +107,9 @@ const ProjectConversation = memo(() => {
);
}, [conversationAgentId]);
- const getConversationPath = useCallback(
- () => getProjectConversationPath(projectSlug!),
- [projectSlug],
- );
+ const getConversationPath = useCallback(() => getProjectTopicPath(projectSlug!), [projectSlug]);
const getTopicPath = useCallback(
- (_agentId: string, topicId: string) => getProjectConversationPath(projectSlug!, topicId),
+ (_agentId: string, topicId: string) => getProjectTopicPath(projectSlug!, topicId),
[projectSlug],
);
diff --git a/src/features/Projects/Layout/navigation.test.ts b/src/features/Projects/Layout/navigation.test.ts
index 845e5846291..ee5709f872b 100644
--- a/src/features/Projects/Layout/navigation.test.ts
+++ b/src/features/Projects/Layout/navigation.test.ts
@@ -3,13 +3,13 @@ import { describe, expect, it } from 'vitest';
import {
getProjectAcceptancePath,
getProjectAgentPath,
- getProjectConversationPath,
getProjectDashboardPath,
getProjectGoalsPath,
getProjectHomePath,
getProjectLibraryPath,
getProjectSettingsPath,
getProjectTasksPath,
+ getProjectTopicPath,
isProjectSectionActive,
toProjectPathname,
} from './navigation';
@@ -31,8 +31,8 @@ describe('project workspace navigation', () => {
});
it('builds new and existing conversation routes inside the project', () => {
- expect(getProjectConversationPath('prj_1')).toBe('/project/prj_1/conversation');
- expect(getProjectConversationPath('prj_1', 'tpc_1')).toBe('/project/prj_1/conversation/tpc_1');
+ expect(getProjectTopicPath('prj_1')).toBe('/project/prj_1/topic');
+ expect(getProjectTopicPath('prj_1', 'tpc_1')).toBe('/project/prj_1/topic/tpc_1');
});
});
diff --git a/src/features/Projects/Layout/navigation.ts b/src/features/Projects/Layout/navigation.ts
index d79da351049..07bbfc52d16 100644
--- a/src/features/Projects/Layout/navigation.ts
+++ b/src/features/Projects/Layout/navigation.ts
@@ -2,8 +2,8 @@ export const getProjectAgentPath = (agentId: string) => `/agent/${agentId}`;
export const getProjectHomePath = (projectId: string) => `/project/${projectId}`;
-export const getProjectConversationPath = (projectId: string, topicId?: string) =>
- topicId ? `/project/${projectId}/conversation/${topicId}` : `/project/${projectId}/conversation`;
+export const getProjectTopicPath = (projectId: string, topicId?: string) =>
+ topicId ? `/project/${projectId}/topic/${topicId}` : `/project/${projectId}/topic`;
/**
* A blank project conversation a sidebar "+" opened for one agent on one
@@ -11,7 +11,7 @@ export const getProjectConversationPath = (projectId: string, topicId?: string)
* survives a reload); nothing is created until its first message.
*/
export const getProjectDraftPath = (projectId: string, agentId: string, directoryId: string) =>
- `${getProjectConversationPath(projectId)}?${new URLSearchParams({ agent: agentId, dir: directoryId })}`;
+ `${getProjectTopicPath(projectId)}?${new URLSearchParams({ agent: agentId, dir: directoryId })}`;
export const getProjectLibraryPath = (projectId: string, libraryId: string) =>
`/project/${projectId}/library/${libraryId}`;
diff --git a/src/features/Projects/WorkingDirectories/AssociateTopicModal.tsx b/src/features/Projects/WorkingDirectories/AssociateTopicModal.tsx
index 1bd88929a03..674585672cd 100644
--- a/src/features/Projects/WorkingDirectories/AssociateTopicModal.tsx
+++ b/src/features/Projects/WorkingDirectories/AssociateTopicModal.tsx
@@ -21,7 +21,7 @@ import { useCurrentProjectList, useProjectStore } from '@/store/project';
import { useProjectDirectories, useProjectDirectoryStore } from '@/store/projectWorkingDirectory';
import { openCreateProjectModal } from '../CreateProjectModal';
-import { getProjectConversationPath } from '../Layout/navigation';
+import { getProjectTopicPath } from '../Layout/navigation';
import { openBindDirectoryModal } from './BindDirectoryModal';
function AssociateTopicContent({ topicId, agentId }: { topicId: string; agentId?: string }) {
@@ -72,7 +72,7 @@ function AssociateTopicContent({ topicId, agentId }: { topicId: string; agentId?
});
await useChatStore.getState().refreshTopic();
close();
- navigate(getProjectConversationPath(projectId, topicId));
+ navigate(getProjectTopicPath(projectId, topicId));
} catch (error) {
console.error('Failed to associate topic', error);
setError(error);
@@ -87,7 +87,7 @@ function AssociateTopicContent({ topicId, agentId }: { topicId: string; agentId?
<Button
onClick={() => {
close();
- navigate(getProjectConversationPath(projectId, topicId));
+ navigate(getProjectTopicPath(projectId, topicId));
}}
>
{t('topics.viewProject')}
diff --git a/src/features/Projects/WorkingDirectories/StartDirectoryModal.tsx b/src/features/Projects/WorkingDirectories/StartDirectoryModal.tsx
index 9697e8b2d45..da801227e28 100644
--- a/src/features/Projects/WorkingDirectories/StartDirectoryModal.tsx
+++ b/src/features/Projects/WorkingDirectories/StartDirectoryModal.tsx
@@ -21,7 +21,7 @@ import {
useProjectDirectoryStore,
} from '@/store/projectWorkingDirectory';
-import { getProjectConversationPath } from '../Layout/navigation';
+import { getProjectTopicPath } from '../Layout/navigation';
import { openAddDirectoryModal } from './AddDirectoryModal';
import { openEnvironmentModal } from './EnvironmentModal';
import { useDirectoryAgent } from './useDirectoryAgent';
@@ -63,7 +63,7 @@ export function StartDirectoryContent({
? await startTopic(directory.id, agentId, t('directories.untitled'))
: await createTopic({ projectId, agentId, title: t('directories.untitled') });
close();
- navigate(getProjectConversationPath(projectId, topic.id));
+ navigate(getProjectTopicPath(projectId, topic.id));
} catch (error) {
console.error('Failed to start directory work', error);
setError(error);
diff --git a/src/features/Projects/WorkingDirectories/startProjectTopicDraft.test.ts b/src/features/Projects/WorkingDirectories/startProjectTopicDraft.test.ts
index 3b52c08919a..a284113137d 100644
--- a/src/features/Projects/WorkingDirectories/startProjectTopicDraft.test.ts
+++ b/src/features/Projects/WorkingDirectories/startProjectTopicDraft.test.ts
@@ -78,6 +78,6 @@ describe('startProjectTopicDraft', () => {
projectWorkingDirectoryId: 'pwd_1',
});
// The draft rides in the route so it stays with the pane that opened it.
- expect(navigate).toHaveBeenCalledWith('/project/prj_1/conversation?agent=agt_1&dir=pwd_1');
+ expect(navigate).toHaveBeenCalledWith('/project/prj_1/topic?agent=agt_1&dir=pwd_1');
});
});
diff --git a/src/features/Projects/Workspace/useProjectComposer.test.ts b/src/features/Projects/Workspace/useProjectComposer.test.ts
index 7d89e756119..f1afa97fba8 100644
--- a/src/features/Projects/Workspace/useProjectComposer.test.ts
+++ b/src/features/Projects/Workspace/useProjectComposer.test.ts
@@ -150,7 +150,7 @@ describe('useProjectComposer', () => {
message: 'Plan the next milestone\nwith details',
onMessageAccepted: expect.any(Function),
});
- expect(mocks.navigate).toHaveBeenCalledWith('/project/apollo/conversation/tpc_1');
+ expect(mocks.navigate).toHaveBeenCalledWith('/project/apollo/topic/tpc_1');
expect(input.clearContent).toHaveBeenCalled();
expect(mocks.clearChatUploadFileList).toHaveBeenCalled();
expect(mocks.createTask).not.toHaveBeenCalled();
diff --git a/src/features/Projects/Workspace/useProjectComposer.ts b/src/features/Projects/Workspace/useProjectComposer.ts
index e95ac89b8c3..997846de246 100644
--- a/src/features/Projects/Workspace/useProjectComposer.ts
+++ b/src/features/Projects/Workspace/useProjectComposer.ts
@@ -5,7 +5,7 @@ import { taskDetailPath } from '@/features/AgentTasks/shared/taskDetailPath';
import type { SendButtonHandler } from '@/features/ChatInput/store/initialState';
import { appendTaskAttachments } from '@/features/Home/InputArea/taskAttachments';
import { taskNameFromMessage } from '@/features/Home/InputArea/taskName';
-import { getProjectConversationPath } from '@/features/Projects/Layout/navigation';
+import { getProjectTopicPath } from '@/features/Projects/Layout/navigation';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { agentService } from '@/services/agent';
import { topicService } from '@/services/topic';
@@ -136,7 +136,7 @@ export const useProjectComposer = (
}
clearContent();
clearChatUploadFileList();
- navigate(getProjectConversationPath(project.slug ?? project.id, topic.id));
+ navigate(getProjectTopicPath(project.slug ?? project.id, topic.id));
} finally {
setSending(false);
}
diff --git a/src/routes/(main)/agent/features/Conversation/ChatHydration/index.test.tsx b/src/routes/(main)/agent/features/Conversation/ChatHydration/index.test.tsx
index 388f15d6a57..d6bcbfb445c 100644
--- a/src/routes/(main)/agent/features/Conversation/ChatHydration/index.test.tsx
+++ b/src/routes/(main)/agent/features/Conversation/ChatHydration/index.test.tsx
@@ -214,15 +214,15 @@ describe('ChatHydration', () => {
useParamsMock.mockReturnValue({ projectId: 'prj_1' });
useLocationMock.mockReturnValue({
hash: '',
- pathname: '/project/prj_1/conversation',
+ pathname: '/project/prj_1/topic',
search: '',
});
useSearchParamsMock.mockReturnValue([new URLSearchParams(''), setSearchParamsMock]);
render(
<ChatHydration
- getConversationPath={() => '/project/prj_1/conversation'}
- getTopicPath={(_agentId, topicId) => `/project/prj_1/conversation/${topicId}`}
+ getConversationPath={() => '/project/prj_1/topic'}
+ getTopicPath={(_agentId, topicId) => `/project/prj_1/topic/${topicId}`}
/>,
);
@@ -231,7 +231,7 @@ describe('ChatHydration', () => {
});
await waitFor(() => {
- expect(navigateMock).toHaveBeenCalledWith('/project/prj_1/conversation/tpc_project', {
+ expect(navigateMock).toHaveBeenCalledWith('/project/prj_1/topic/tpc_project', {
replace: true,
});
});
diff --git a/src/routes/(main)/project/[projectId]/conversation/index.tsx b/src/routes/(main)/project/[projectId]/topic/index.tsx
similarity index 100%
rename from src/routes/(main)/project/[projectId]/conversation/index.tsx
rename to src/routes/(main)/project/[projectId]/topic/index.tsx
diff --git a/src/spa/router/desktopRouter.meta.desktop.test.ts b/src/spa/router/desktopRouter.meta.desktop.test.ts
index 62b3369ab00..6e2fb3997cd 100644
--- a/src/spa/router/desktopRouter.meta.desktop.test.ts
+++ b/src/spa/router/desktopRouter.meta.desktop.test.ts
@@ -60,7 +60,7 @@ describe('mainAreaMetaRoutes (Electron adapter)', () => {
});
it('resolves project conversation meta with a dynamic title runner', () => {
- const matched = matchRouteMeta(mainAreaMetaRoutes, '/project/prj_1/conversation/tpc_1');
+ const matched = matchRouteMeta(mainAreaMetaRoutes, '/project/prj_1/topic/tpc_1');
expect(matched.static.titleKey).toBe('project:topics.title');
expect(matched.static.icon).toBeDefined();
@@ -89,7 +89,7 @@ describe('mainAreaMetaRoutes (Electron adapter)', () => {
});
it('resolves project meta for workspace-scoped tab urls', () => {
- const matched = matchRouteMeta(mainAreaMetaRoutes, '/team-x/project/prj_1/conversation/tpc_1');
+ const matched = matchRouteMeta(mainAreaMetaRoutes, '/team-x/project/prj_1/topic/tpc_1');
expect(matched.static.titleKey).toBe('project:topics.title');
expect(matched.params.projectId).toBe('prj_1');
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index a44a3e2dc59..fc0eb46eea9 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -208,6 +208,7 @@ describe('desktop router shared definition', () => {
.filter((routePath): routePath is string => Boolean(routePath));
expect(projectPaths).toEqual([
+ 'topic/:topicId?',
'conversation/:topicId?',
'tasks',
'settings/:section?',
diff --git a/src/spa/router/projectWorkspaceRoutes.test.tsx b/src/spa/router/projectWorkspaceRoutes.test.tsx
new file mode 100644
index 00000000000..3803781d01f
--- /dev/null
+++ b/src/spa/router/projectWorkspaceRoutes.test.tsx
@@ -0,0 +1,45 @@
+import { render, screen } from '@testing-library/react';
+import { createMemoryRouter, RouterProvider, useLocation } from 'react-router';
+import { describe, expect, it } from 'vitest';
+
+import { projectWorkspaceRoute } from './projectWorkspaceRoutes';
+
+const legacyRoute = projectWorkspaceRoute.children?.find(
+ (route) => route.path === 'conversation/:topicId?',
+);
+
+const Location = () => {
+ const { hash, pathname, search } = useLocation();
+ return <div data-testid="location">{`${pathname}${search}${hash}`}</div>;
+};
+
+const renderAt = (url: string) => {
+ const router = createMemoryRouter(
+ [
+ {
+ children: [
+ { element: <Location />, path: 'topic/:topicId?' },
+ { element: legacyRoute?.element, path: 'conversation/:topicId?' },
+ ],
+ path: ':workspace?/project/:projectId',
+ },
+ ],
+ { initialEntries: [url] },
+ );
+ render(<RouterProvider router={router} />);
+ return screen.getByTestId('location').textContent;
+};
+
+describe('legacy project conversation links', () => {
+ it('moves a topic link to the topic route, keeping its query and hash', async () => {
+ expect(renderAt('/project/prj_1/conversation/tpc_1?thread=thd_1#msg_1')).toBe(
+ '/project/prj_1/topic/tpc_1?thread=thd_1#msg_1',
+ );
+ });
+
+ it('moves a draft link without a topic and keeps the workspace prefix', () => {
+ expect(renderAt('/acme/project/prj_1/conversation?agent=agt_1&dir=pwd_1')).toBe(
+ '/acme/project/prj_1/topic?agent=agt_1&dir=pwd_1',
+ );
+ });
+});
diff --git a/src/spa/router/projectWorkspaceRoutes.tsx b/src/spa/router/projectWorkspaceRoutes.tsx
index b295eb0b7b0..1240db08c09 100644
--- a/src/spa/router/projectWorkspaceRoutes.tsx
+++ b/src/spa/router/projectWorkspaceRoutes.tsx
@@ -1,4 +1,4 @@
-import type { RouteObject } from 'react-router';
+import { Navigate, type RouteObject, useLocation, useParams } from 'react-router';
import { goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
import { tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
@@ -12,6 +12,15 @@ import { projectAcceptanceRoute } from '@/spa/router/projectAcceptanceRoutes';
import { scheduledTaskListLoader } from '@/spa/router/scheduledTaskListLoader';
import { dynamicElement, dynamicLayout, ErrorBoundary } from '@/utils/router';
+/** Topics used to live under `conversation/`: keep old links and restored tabs working. */
+const LegacyProjectConversationRedirect = () => {
+ const { topicId } = useParams<{ topicId?: string }>();
+ const { hash, search } = useLocation();
+ const pathname = topicId ? `../../topic/${topicId}` : '../topic';
+
+ return <Navigate replace relative="path" to={{ hash, pathname, search }} />;
+};
+
/**
* One project's workspace under `/project/:projectId`: its home, topics, tasks,
* settings, goals, dashboards and acceptance. Mounted under the workspace
@@ -30,13 +39,14 @@ export const projectWorkspaceRoute: RouteObject = {
},
{
element: dynamicElement(
- () => import('@/routes/(main)/project/[projectId]/conversation'),
- 'Desktop > Project Conversation',
- { preloadId: 'project-conversation' },
+ () => import('@/routes/(main)/project/[projectId]/topic'),
+ 'Desktop > Project Topic',
+ { preloadId: 'project-topic' },
),
handle: { meta: projectConversationRouteMeta },
- path: 'conversation/:topicId?',
+ path: 'topic/:topicId?',
},
+ { element: <LegacyProjectConversationRedirect />, path: 'conversation/:topicId?' },
{
element: dynamicElement(
() => import('@/routes/(main)/project/[projectId]/tasks'),