From 2b5e9a0221d5cf558cd98e6bc9b3a5b4f8009bb1 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Wed, 15 Jul 2026 12:31:35 +0300 Subject: [PATCH] feat: pass selected project when opening new session drafts New drafts now receive the active project ID from sidebar project actions. Project-group draft creation also forwards the selected project. Aligns draft opening behavior across project and session selection flows. --- .../src/components/session/sidebar/SessionGroupSection.tsx | 6 +++--- .../src/components/session/sidebar/SidebarProjectsList.tsx | 7 +++++-- .../session/sidebar/hooks/useProjectSessionSelection.ts | 7 +++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx b/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx index 3eb58a2b..1838b51a 100644 --- a/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx +++ b/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx @@ -82,7 +82,7 @@ type Props = { setActiveProjectIdOnly: (id: string) => void; setActiveMainTab: (tab: MainTab) => void; setSessionSwitcherOpen: (open: boolean) => void; - openNewSessionDraft: (options?: { directoryOverride?: string | null; targetFolderId?: string }) => void; + openNewSessionDraft: (options?: { selectedProjectId?: string | null; directoryOverride?: string | null; targetFolderId?: string }) => void; addSessionToFolder: (scopeKey: string, folderId: string, sessionId: string) => void; createFolderAndStartRename: (scopeKey: string, parentId?: string | null) => { id: string } | null; renamingFolderId: string | null; @@ -897,7 +897,7 @@ function SessionGroupSectionBase(props: Props): React.ReactNode { if (projectId && projectId !== activeProjectId) setActiveProjectIdOnly(projectId); setActiveMainTab('chat'); if (mobileVariant) setSessionSwitcherOpen(false); - openNewSessionDraft({ directoryOverride: group.directory, targetFolderId: folder.id }); + openNewSessionDraft({ selectedProjectId: projectId, directoryOverride: group.directory, targetFolderId: folder.id }); }} onNewSubFolder={depth === 0 ? () => { if (!folderScopeKey) return; @@ -1269,7 +1269,7 @@ function SessionGroupSectionBase(props: Props): React.ReactNode { if (projectId && projectId !== activeProjectId) setActiveProjectIdOnly(projectId); setActiveMainTab('chat'); if (mobileVariant) setSessionSwitcherOpen(false); - openNewSessionDraft({ directoryOverride: group.directory }); + openNewSessionDraft({ selectedProjectId: projectId, directoryOverride: group.directory }); }} className="inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50" aria-label={t('sessions.sidebar.group.actions.newDraftInGroupAria', { label: group.label })} diff --git a/packages/ui/src/components/session/sidebar/SidebarProjectsList.tsx b/packages/ui/src/components/session/sidebar/SidebarProjectsList.tsx index 91dc346e..9efac151 100644 --- a/packages/ui/src/components/session/sidebar/SidebarProjectsList.tsx +++ b/packages/ui/src/components/session/sidebar/SidebarProjectsList.tsx @@ -64,7 +64,7 @@ type Props = { setActiveProjectIdOnly: (id: string) => void; setActiveMainTab: (tab: MainTab) => void; setSessionSwitcherOpen: (open: boolean) => void; - openNewSessionDraft: (options?: { directoryOverride?: string | null }) => void; + openNewSessionDraft: (options?: { selectedProjectId?: string | null; directoryOverride?: string | null }) => void; openNewWorktreeDialog: () => void; openProjectEditDialog: (id: string) => void; removeProject: (id: string) => void; @@ -243,7 +243,10 @@ export function SidebarProjectsList(props: Props): React.ReactNode { if (projectKey !== props.activeProjectId) props.setActiveProjectIdOnly(projectKey); props.setActiveMainTab('chat'); if (props.mobileVariant) props.setSessionSwitcherOpen(false); - props.openNewSessionDraft({ directoryOverride: project.normalizedPath }); + props.openNewSessionDraft({ + selectedProjectId: projectKey, + directoryOverride: project.normalizedPath, + }); }} onNewWorktreeSession={() => { if (projectKey !== props.activeProjectId) props.setActiveProjectIdOnly(projectKey); diff --git a/packages/ui/src/components/session/sidebar/hooks/useProjectSessionSelection.ts b/packages/ui/src/components/session/sidebar/hooks/useProjectSessionSelection.ts index 034eb679..421dfdff 100644 --- a/packages/ui/src/components/session/sidebar/hooks/useProjectSessionSelection.ts +++ b/packages/ui/src/components/session/sidebar/hooks/useProjectSessionSelection.ts @@ -19,7 +19,7 @@ type Args = { handleSessionSelect: (sessionId: string, sessionDirectory: string | null, projectId?: string | null) => void; newSessionDraftOpen: boolean; mobileVariant: boolean; - openNewSessionDraft: (options?: { directoryOverride?: string | null }) => void; + openNewSessionDraft: (options?: { selectedProjectId?: string | null; directoryOverride?: string | null }) => void; setActiveMainTab: (tab: MainTab) => void; setSessionSwitcherOpen: (open: boolean) => void; }; @@ -131,7 +131,10 @@ export const useProjectSessionSelection = (args: Args): void => { if (mobileVariant) { setSessionSwitcherOpen(false); } - openNewSessionDraft({ directoryOverride: section.project.normalizedPath }); + openNewSessionDraft({ + selectedProjectId: section.project.id, + directoryOverride: section.project.normalizedPath, + }); return; }