From 1321a8bd4d91d5ff3667a6f3799876d6293338cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fur=20Kellecio=C4=9Flu?= Date: Sun, 28 Dec 2025 12:26:20 +0300 Subject: [PATCH] feat: enhance AgentView with adjustable textarea and improved input handling #294 --- apps/ui/src/components/views/agent-view.tsx | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/ui/src/components/views/agent-view.tsx b/apps/ui/src/components/views/agent-view.tsx index 950d77de..3daf0bec 100644 --- a/apps/ui/src/components/views/agent-view.tsx +++ b/apps/ui/src/components/views/agent-view.tsx @@ -51,6 +51,7 @@ import { DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { CLAUDE_MODELS } from '@/components/views/board-view/shared/model-constants'; +import { Textarea } from '@/components/ui/textarea'; export function AgentView() { const { currentProject, setLastSelectedSession, getLastSelectedSession } = useAppStore(); @@ -73,7 +74,7 @@ export function AgentView() { const [isUserAtBottom, setIsUserAtBottom] = useState(true); // Input ref for auto-focus - const inputRef = useRef(null); + const inputRef = useRef(null); // Ref for quick create session function from SessionManager const quickCreateSessionRef = useRef<(() => Promise) | null>(null); @@ -368,13 +369,24 @@ export function AgentView() { [processDroppedFiles] ); - const handleKeyPress = (e: React.KeyboardEvent) => { + const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); } }; + const adjustTextareaHeight = useCallback(() => { + const textarea = inputRef.current; + if (!textarea) return; + textarea.style.height = 'auto'; + textarea.style.height = `${textarea.scrollHeight}px`; + }, []); + + useEffect(() => { + adjustTextareaHeight(); + }, [input, adjustTextareaHeight]); + const handleClearChat = async () => { if (!confirm('Are you sure you want to clear this conversation?')) return; await clearHistory(); @@ -878,7 +890,7 @@ export function AgentView() { onDrop={handleDrop} >
- setInput(e.target.value)} - onKeyPress={handleKeyPress} + onKeyDown={handleKeyDown} onPaste={handlePaste} disabled={!isConnected} data-testid="agent-input" + rows={1} className={cn( - 'h-11 bg-background border-border rounded-xl pl-4 pr-20 text-sm transition-all', + 'min-h-11 bg-background border-border rounded-xl pl-4 pr-20 text-sm transition-all resize-none max-h-36 overflow-y-auto py-2.5', 'focus:ring-2 focus:ring-primary/20 focus:border-primary/50', (selectedImages.length > 0 || selectedTextFiles.length > 0) && 'border-primary/30', @@ -1000,7 +1013,11 @@ export function AgentView() {

Press{' '} Enter to - send + send,{' '} + + Shift+Enter + {' '} + for new line

)}