diff --git a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx index 35638c973dd..ccc64256e4f 100644 --- a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx +++ b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx @@ -1,5 +1,6 @@ -import { useId, useState } from 'react'; +import { Fragment, useId, useState } from 'react'; import * as Ariakit from '@ariakit/react'; +import { isCodeWorkspaceCheckoutAvailable } from 'librechat-data-provider'; import { TooltipAnchor, composerControlClasses, useToastContext } from '@librechat/client'; import { Check, ChevronDown, Folder, FolderSync, FolderX, RefreshCw, Monitor } from 'lucide-react'; import type { CodeWorkspaceSelection, TConversation } from 'librechat-data-provider'; @@ -103,10 +104,11 @@ function describeTransition( /** A sole advertised workspace is the only valid pick, so it counts as chosen until changed. */ function chosenWorkspaceId( target: CodeWorkspaceEnvironmentResult, - choices: Record, + choices: Record, ): string | undefined { const choice = choices[target.environment.id]; - if (choice != null && target.workspaces.some(({ id }) => id === choice)) return choice; + if (choice != null && target.workspaces.some(({ id }) => id === choice.workspaceId)) + return choice.workspaceId; return target.workspaces.length === 1 ? target.workspaces[0].id : undefined; } @@ -118,6 +120,8 @@ function EnvironmentWorkspaces({ hideOnClick, isSelected, onSelect, + checkout, + allowCheckoutSelection = false, }: { environment: CodeWorkspaceEnvironmentResult['environment']; requiredBy?: CodeWorkspaceEnvironmentResult['requiredBy']; @@ -126,6 +130,8 @@ function EnvironmentWorkspaces({ hideOnClick: boolean; isSelected: (workspaceId: string) => boolean; onSelect: (selection: CodeWorkspaceSelection) => void; + checkout?: CodeWorkspaceSelection['checkout']; + allowCheckoutSelection?: boolean; }) { const localize = useLocalize(); return ( @@ -146,47 +152,106 @@ function EnvironmentWorkspaces({ {workspaces.map((descriptor) => { const selected = isSelected(descriptor.id); return ( - onSelect({ environmentId: environment.id, workspaceId: descriptor.id })} - className={menuItemClasses(selected)} - > -