diff --git a/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx b/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx index 1a7af105..77ab01ef 100644 --- a/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx +++ b/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx @@ -4,7 +4,7 @@ import { AgenticAPITool } from "../../../lib/types/agents_api_types"; import { WorkflowPrompt, WorkflowAgent, Workflow } from "../../../lib/types/workflow_types"; import { DataSource } from "../../../lib/types/datasource_types"; import { z } from "zod"; -import { PlusIcon, Sparkles, X as XIcon, ChevronDown, ChevronRight, Trash2 } from "lucide-react"; +import { PlusIcon, Sparkles, X as XIcon, ChevronDown, ChevronRight, Trash2, Maximize2, Minimize2 } from "lucide-react"; import { useState, useEffect, useRef } from "react"; import { usePreviewModal } from "../workflow/preview-modal"; import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Select, SelectItem } from "@heroui/react"; @@ -59,6 +59,8 @@ export function AgentConfig({ }) { const [isAdvancedConfigOpen, setIsAdvancedConfigOpen] = useState(false); const [showGenerateModal, setShowGenerateModal] = useState(false); + const [isInstructionsMaximized, setIsInstructionsMaximized] = useState(false); + const [isExamplesMaximized, setIsExamplesMaximized] = useState(false); const { showPreview } = usePreviewModal(); const [localName, setLocalName] = useState(agent.name); const [nameError, setNameError] = useState(null); @@ -75,6 +77,23 @@ export function AgentConfig({ } }, [agent.controlType, agent, handleUpdate]); + // Add effect to handle escape key + useEffect(() => { + const handleEscape = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + if (isInstructionsMaximized) { + setIsInstructionsMaximized(false); + } + if (isExamplesMaximized) { + setIsExamplesMaximized(false); + } + } + }; + + window.addEventListener('keydown', handleEscape); + return () => window.removeEventListener('keydown', handleEscape); + }, [isInstructionsMaximized, isExamplesMaximized]); + const validateName = (value: string) => { if (value.length === 0) { setNameError("Name cannot be empty"); @@ -463,9 +482,24 @@ export function AgentConfig({ {activeTab === 'instructions' && (
- +
+ + setIsInstructionsMaximized(!isInstructionsMaximized)} + showHoverContent={true} + hoverContent={isInstructionsMaximized ? "Minimize" : "Maximize"} + > + {isInstructionsMaximized ? ( + + ) : ( + + )} + +
-
-
- { - handleUpdate({ - ...agent, - instructions: value - }); - }} - markdown - multiline - mentions - mentionsAtValues={atMentions} - showSaveButton={true} - showDiscardButton={true} - className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" - /> + {isInstructionsMaximized ? ( +
+
+
+
+ + setIsInstructionsMaximized(false)} + showHoverContent={true} + hoverContent="Minimize" + > + + +
+ setShowGenerateModal(true)} + startContent={} + > + Generate + +
+
+ { + handleUpdate({ + ...agent, + instructions: value + }); + }} + markdown + multiline + mentions + mentionsAtValues={atMentions} + showSaveButton={true} + showDiscardButton={true} + className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" + /> +
+
-
+ ) : ( +
+
+ { + handleUpdate({ + ...agent, + instructions: value + }); + }} + markdown + multiline + mentions + mentionsAtValues={atMentions} + showSaveButton={true} + showDiscardButton={true} + className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" + /> +
+
+ )}
)} {activeTab === 'examples' && (
- -
-
- { - handleUpdate({ - ...agent, - examples: value - }); - }} - placeholder="Enter examples for this agent" - markdown - multiline - mentions - mentionsAtValues={atMentions} - showSaveButton={true} - showDiscardButton={true} - className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" - /> +
+
+ + setIsExamplesMaximized(!isExamplesMaximized)} + showHoverContent={true} + hoverContent={isExamplesMaximized ? "Minimize" : "Maximize"} + > + {isExamplesMaximized ? ( + + ) : ( + + )} +
+ {isExamplesMaximized ? ( +
+
+
+
+ + setIsExamplesMaximized(false)} + showHoverContent={true} + hoverContent="Minimize" + > + + +
+
+
+ { + handleUpdate({ + ...agent, + examples: value + }); + }} + placeholder="Enter examples for this agent" + markdown + multiline + mentions + mentionsAtValues={atMentions} + showSaveButton={true} + showDiscardButton={true} + className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" + /> +
+
+
+ ) : ( +
+
+ { + handleUpdate({ + ...agent, + examples: value + }); + }} + placeholder="Enter examples for this agent" + markdown + multiline + mentions + mentionsAtValues={atMentions} + showSaveButton={true} + showDiscardButton={true} + className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto" + /> +
+
+ )}
)}