|
8 | 8 | type PointerEventHandler, |
9 | 9 | type ReactNode, |
10 | 10 | } from "react"; |
11 | | -import { useNavigate } from "react-router-dom"; |
12 | | -import { useAtom, useAtomValue, useSetAtom, useStore } from "jotai"; |
| 11 | +import { useAtom, useAtomValue, useSetAtom } from "jotai"; |
13 | 12 | import type { |
14 | 13 | ProjectResponse, |
15 | 14 | ThreadSectionResponse, |
@@ -41,15 +40,10 @@ import { useHosts, usePrimaryHost } from "@/hooks/queries/host-queries"; |
41 | 40 | import { useDialogState } from "@/hooks/useDialogState"; |
42 | 41 | import { usePromptDraftInputThreadIds } from "@/hooks/usePromptDraftStorage"; |
43 | 42 | import { getCollapsedChildActivity } from "@bb/client-core"; |
44 | | -import { getRootComposeRoutePath } from "@/lib/route-paths"; |
45 | | -import { openPaneContentInSplit } from "@/lib/split-layout/openPaneContentInSplit"; |
46 | | -import { useIsCompactViewport } from "@bb/shared-ui/hooks/use-compact-viewport"; |
47 | | - |
48 | | -const NEW_THREAD_PANE_CONTENT = { kind: "new-thread" } as const; |
| 43 | +import { useOpenNewThreadPane } from "@/hooks/useOpenNewThreadPane"; |
49 | 44 | import { getThreadDisplayTitle } from "@/lib/thread-title"; |
50 | 45 | import { getMutationErrorMessage } from "@/lib/mutation-errors"; |
51 | 46 | import { BbHttpError } from "@bb/sdk/browser"; |
52 | | -import { useSetRootComposeProjectId } from "@/lib/root-compose-selection"; |
53 | 47 | import { cn } from "@bb/shared-ui/lib/utils"; |
54 | 48 | import { Button } from "@bb/shared-ui/button"; |
55 | 49 | import { AppCommandShortcutHint } from "@/components/commands/AppCommandShortcutHint"; |
@@ -1519,10 +1513,7 @@ function ProjectListComponent({ |
1519 | 1513 | onProjectSelect, |
1520 | 1514 | isCreatingProject = false, |
1521 | 1515 | }: ProjectListProps) { |
1522 | | - const navigate = useNavigate(); |
1523 | | - const store = useStore(); |
1524 | | - const isCompactViewport = useIsCompactViewport(); |
1525 | | - const setRootComposeProjectId = useSetRootComposeProjectId(); |
| 1516 | + const openNewThreadPane = useOpenNewThreadPane(); |
1526 | 1517 | const sidebarNavigationQuery = useSidebarNavigation(); |
1527 | 1518 | const sidebarNavigation = sidebarNavigationQuery.data; |
1528 | 1519 | const sections = sidebarNavigation?.sections ?? EMPTY_SECTION_DEFINITIONS; |
@@ -1594,23 +1585,13 @@ function ProjectListComponent({ |
1594 | 1585 | ); |
1595 | 1586 | const openRootComposeForProject = useCallback( |
1596 | 1587 | (projectId: string, sectionId?: string) => { |
1597 | | - setRootComposeProjectId(projectId); |
1598 | 1588 | onProjectSelect?.(); |
1599 | | - const state = { |
1600 | | - focusPrompt: true, |
1601 | | - ...(sectionId ? { sectionId } : {}), |
1602 | | - }; |
1603 | | - openPaneContentInSplit({ |
1604 | | - store, |
1605 | | - navigate: (route, options) => { |
1606 | | - navigate(route, { ...options, state }); |
1607 | | - }, |
1608 | | - content: NEW_THREAD_PANE_CONTENT, |
1609 | | - route: getRootComposeRoutePath(), |
1610 | | - enabled: !isCompactViewport, |
| 1589 | + openNewThreadPane({ |
| 1590 | + projectId, |
| 1591 | + ...(sectionId ? { state: { sectionId } } : {}), |
1611 | 1592 | }); |
1612 | 1593 | }, |
1613 | | - [isCompactViewport, navigate, onProjectSelect, setRootComposeProjectId, store], |
| 1594 | + [onProjectSelect, openNewThreadPane], |
1614 | 1595 | ); |
1615 | 1596 | const handleCreateProjectThread = useCallback( |
1616 | 1597 | (projectId: string) => { |
|
0 commit comments