🤯 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 path-group "+" path-only and offer binding instead (#20880)
Arvin Xu22aa4364bdbd
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.test.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.test.tsxindex 8bbb12c56fa..b09e96360fa 100644--- a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.test.tsx+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.test.tsx@@ -82,8 +82,9 @@ vi.mock('@/helpers/agentWorkingDirectory', () => ({resolveTargetDeviceId: () => 'device-1',}));+const openBindDirectoryModalMock = vi.hoisted(() => vi.fn());vi.mock('@/features/Projects/WorkingDirectories/BindDirectoryModal', () => ({- openBindDirectoryModal: vi.fn(),+ openBindDirectoryModal: openBindDirectoryModalMock,}));const openProjectTopicModalMock = vi.hoisted(() => vi.fn());@@ -454,7 +455,7 @@ describe('Project topic group item', () => {expect(routerPushMock).toHaveBeenCalled();});- it('opens the new-topic composer for the project directory without creating a topic', async () => {+ it('opens a path-only composer from a path group even when a project registered that path', async () => {// The group "+" must not persist anything: it opens the composer, and the// topic is created once the user sends the first message. Regression for// the straight-to-server start that dropped an empty "untitled" topic into@@ -489,12 +490,49 @@ describe('Project topic group item', () => {expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });expect(routerPushMock).toHaveBeenCalledWith('/agent/agent-1');expect(startTopicMock).not.toHaveBeenCalled();- // The deferred row must still be born inside the project: the staged- // directory rides along to the first-message creation.- expect(setPendingNewTopicDirectoryMock).toHaveBeenCalledWith({- agentId: 'agent-1',- projectWorkingDirectoryId: 'binding-1',+ // A plain path group stays path-only: a project directory registered at+ // the same path must not pull the new topic into that project.+ expect(setPendingNewTopicDirectoryMock).toHaveBeenCalledWith(undefined);+ });++ it('offers binding a path group even when a project registered that path', async () => {+ directoryRows.push({+ deviceId: 'device-1',+ id: 'binding-1',+ path: '/Users/me/project',+ projectAvatar: '',+ projectId: 'prj-1',+ projectName: 'LobeHub',+ projectSlug: 'lobehub',});+ openBindDirectoryModalMock.mockReset();++ render(+ <AccordionRoot>+ <GroupItem+ expanded+ group={{+ children: [+ { id: 't1', metadata: { workingDirectory: '/Users/me/project' }, title: 'Loose' },+ ] as any,+ id: 'project:/Users/me/project',+ title: 'project',+ }}+ />+ </AccordionRoot>,+ );++ fireEvent.click(screen.getByRole('button', { name: 'directories.projectBinding' }));+ expect(screen.queryByText('topics.viewProject')).toBeNull();+ fireEvent.click(await screen.findByText('directories.bind'));++ expect(openBindDirectoryModalMock).toHaveBeenCalledWith(+ expect.objectContaining({+ deviceId: 'device-1',+ path: '/Users/me/project',+ topicIds: ['t1'],+ }),+ );});it('preserves the detected route prefix when adding a project topic without an active workspace slug', async () => {diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsxindex c41cfa68e71..8e3ff0ca9d4 100644--- a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx@@ -410,6 +410,7 @@ const GroupItem = memo<GroupItemComponentProps>(({ group, expanded }) => {agentId={currentAgentId!}extraMenuItems={archiveMenuItems}path={workingDirectory!}+ pathOnly={!isProjectGroup}topics={children}onLegacyStart={handleAddTopic}/>diff --git a/src/features/Projects/WorkingDirectories/AgentDirectoryActions.tsx b/src/features/Projects/WorkingDirectories/AgentDirectoryActions.tsxindex 6fc4e7a5d1a..deda56e80ec 100644--- a/src/features/Projects/WorkingDirectories/AgentDirectoryActions.tsx+++ b/src/features/Projects/WorkingDirectories/AgentDirectoryActions.tsx@@ -25,6 +25,7 @@ export function AgentDirectoryActions({topics,onLegacyStart,hideStartAction = false,+ pathOnly = false,extraMenuItems,}: {agentId: string;@@ -33,6 +34,12 @@ export function AgentDirectoryActions({onLegacyStart: (projectWorkingDirectoryId?: string) => Promise<void>;/** Render only the binding/menu affordance; the caller provides its own start action. */hideStartAction?: boolean;+ /**+ * A plain path group: never resolve a project directory by path. A project+ * that registered the same path must not adopt new topics started here; the+ * menu offers binding instead so the user files the group explicitly.+ */+ pathOnly?: boolean;/** Group-level actions appended to the "more" menu after a divider. */extraMenuItems?: DropdownItem[];}) {@@ -49,12 +56,14 @@ export function AgentDirectoryActions({useProjectDirectoryStore((s) => s.useFetchDirectories)();const directories = useProjectDirectories();const bindingId = topics[0]?.projectWorkingDirectoryId;- const bindings = directories.filter((directory) =>- bindingId- ? directory.id === bindingId- : directory.deviceId === deviceId &&- directory.path.replace(/[\\/]+$/, '') === path.replace(/[\\/]+$/, ''),- );+ const bindings = pathOnly+ ? []+ : directories.filter((directory) =>+ bindingId+ ? directory.id === bindingId+ : directory.deviceId === deviceId &&+ directory.path.replace(/[\\/]+$/, '') === path.replace(/[\\/]+$/, ''),+ );const [pending, setPending] = useState(false);// "+" opens the new-topic composer for this group; it must never create a// topic. The row is persisted on the first message, which is also when the