diff --git a/client/src/components/SidePanel/Agents/Instructions.tsx b/client/src/components/SidePanel/Agents/Instructions.tsx index e4b0ae58f6..347ad0a1d8 100644 --- a/client/src/components/SidePanel/Agents/Instructions.tsx +++ b/client/src/components/SidePanel/Agents/Instructions.tsx @@ -1,185 +1,42 @@ -import { useState, useId } from 'react'; -import * as Menu from '@ariakit/react/menu'; -import { PlusCircle, Maximize2 } from 'lucide-react'; -import { specialVariables } from 'librechat-data-provider'; import { Controller, useFormContext } from 'react-hook-form'; -import { - Label, - Button, - OGDialog, - Textarea, - DropdownPopup, - OGDialogClose, - TooltipAnchor, - OGDialogTitle, - OGDialogHeader, - OGDialogContent, -} from '@librechat/client'; -import type { TSpecialVarLabel } from 'librechat-data-provider'; import type { AgentForm } from '~/common'; +import { VariableEditor } from '~/components/Variables'; import { useLocalize } from '~/hooks'; -interface VariableOption { - label: TSpecialVarLabel; - value: string; -} - -const variableOptions: VariableOption[] = Object.keys(specialVariables).map((key) => ({ - label: `com_ui_special_var_${key}` as TSpecialVarLabel, - value: `{{${key}}}`, -})); - export default function Instructions() { - const menuId = useId(); - const dialogMenuId = useId(); const localize = useLocalize(); - const methods = useFormContext(); - const { control, setValue, getValues } = methods; - - const [isMenuOpen, setIsMenuOpen] = useState(false); - const [isDialogMenuOpen, setIsDialogMenuOpen] = useState(false); - const [isDialogOpen, setIsDialogOpen] = useState(false); - - const handleAddVariable = (label: TSpecialVarLabel, value: string) => { - const currentInstructions = getValues('instructions') || ''; - const spacer = currentInstructions.length > 0 ? '\n' : ''; - const prefix = localize(label); - setValue('instructions', currentInstructions + spacer + prefix + ': ' + value); - setIsMenuOpen(false); - setIsDialogMenuOpen(false); - }; - - const variableItems = variableOptions.map((option) => ({ - label: localize(option.label) || option.label, - onClick: () => handleAddVariable(option.label, option.value), - })); + const { control } = useFormContext(); return ( -
-
- -
- - - - } - items={variableItems} - menuId={menuId} - className="pointer-events-auto z-30" - /> - setIsDialogOpen(true)} - aria-label={localize('com_ui_expand_editor')} - className="h-7 w-7 p-0 text-text-secondary hover:bg-surface-secondary hover:text-text-primary" - > - - - } + ( +
+ + {error && ( + + {localize('com_ui_field_required')} + + )}
-
- ( - <> -