From bdf24092ffc68197bd766d564e386ab185298fad Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Wed, 8 Apr 2026 11:28:16 +0300 Subject: [PATCH] refactor: update onNewSession to accept workspaceId for navigation --- src/components/refactored/sidebar/hooks/useWorkspaces.ts | 4 ++-- .../refactored/sidebar/view/SidebarWorkspaceItem.tsx | 6 +++--- .../refactored/sidebar/view/SidebarWorkspaceList.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/refactored/sidebar/hooks/useWorkspaces.ts b/src/components/refactored/sidebar/hooks/useWorkspaces.ts index 72bbb540..bcd7c55c 100644 --- a/src/components/refactored/sidebar/hooks/useWorkspaces.ts +++ b/src/components/refactored/sidebar/hooks/useWorkspaces.ts @@ -126,8 +126,8 @@ export const useWorkspaces = () => { [navigate, workspaces], ); - const openNewSession = useCallback(() => { - navigate('/'); + const openNewSession = useCallback((workspaceId: string) => { + navigate(`/workspaces/${encodeURIComponent(workspaceId)}/chat`); }, [navigate]); const toggleWorkspaceStar = useCallback(async (workspaceId: string) => { diff --git a/src/components/refactored/sidebar/view/SidebarWorkspaceItem.tsx b/src/components/refactored/sidebar/view/SidebarWorkspaceItem.tsx index 7ceea31d..c640ea03 100644 --- a/src/components/refactored/sidebar/view/SidebarWorkspaceItem.tsx +++ b/src/components/refactored/sidebar/view/SidebarWorkspaceItem.tsx @@ -40,7 +40,7 @@ type SidebarWorkspaceItemProps = { onDeleteWorkspace: (workspace: WorkspaceRecord) => void; onSessionSelect: (workspacePath: string, sessionId: string) => void; onSessionDelete: (workspacePath: string, sessionId: string) => void; - onNewSession: () => void; + onNewSession: (workspaceId: string) => void; }; export function SidebarWorkspaceItem({ @@ -396,7 +396,7 @@ export function SidebarWorkspaceItem({ className="flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]" onClick={(event) => { event.stopPropagation(); - onNewSession(); + onNewSession(workspace.workspaceId); }} > @@ -408,7 +408,7 @@ export function SidebarWorkspaceItem({ variant="default" size="sm" className="mt-1 hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex" - onClick={onNewSession} + onClick={() => onNewSession(workspace.workspaceId)} > New Session diff --git a/src/components/refactored/sidebar/view/SidebarWorkspaceList.tsx b/src/components/refactored/sidebar/view/SidebarWorkspaceList.tsx index 030a52bd..daf33ee0 100644 --- a/src/components/refactored/sidebar/view/SidebarWorkspaceList.tsx +++ b/src/components/refactored/sidebar/view/SidebarWorkspaceList.tsx @@ -27,7 +27,7 @@ type SidebarWorkspaceListProps = { onDeleteWorkspace: (workspace: WorkspaceRecord) => void; onSessionSelect: (workspacePath: string, sessionId: string) => void; onSessionDelete: (workspacePath: string, sessionId: string) => void; - onNewSession: () => void; + onNewSession: (workspaceId: string) => void; }; const SectionHeading = ({ title }: { title: string }) => (