From 0ec8235d5cfa316eb98294bb5d52ca04f9312851 Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Tue, 6 May 2025 11:29:31 +0530 Subject: [PATCH] chore(ui): update input box --- .../src/app/(dashboard)/dashboard/page.tsx | 8 +- .../thread/chat-input/chat-input.tsx | 51 +++--- .../thread/chat-input/file-upload-handler.tsx | 9 +- .../thread/chat-input/message-input.tsx | 152 +++++++++++++----- .../thread/chat-input/model-selector.tsx | 4 +- 5 files changed, 136 insertions(+), 88 deletions(-) diff --git a/frontend/src/app/(dashboard)/dashboard/page.tsx b/frontend/src/app/(dashboard)/dashboard/page.tsx index be8bbd85..afc9bb12 100644 --- a/frontend/src/app/(dashboard)/dashboard/page.tsx +++ b/frontend/src/app/(dashboard)/dashboard/page.tsx @@ -205,12 +205,12 @@ function DashboardContent() { )} -
+
-

- Welcome to Suna +

+ Hey

-

+

What would you like Suna to do today?

diff --git a/frontend/src/components/thread/chat-input/chat-input.tsx b/frontend/src/components/thread/chat-input/chat-input.tsx index 24b2272a..78869495 100644 --- a/frontend/src/components/thread/chat-input/chat-input.tsx +++ b/frontend/src/components/thread/chat-input/chat-input.tsx @@ -10,10 +10,9 @@ import React, { import { motion } from 'framer-motion'; import { Loader2 } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; -import { FileUploadHandler, handleFiles } from './file-upload-handler'; +import { handleFiles } from './file-upload-handler'; import { MessageInput } from './message-input'; import { UploadedFilesDisplay } from './uploaded-file-display'; -import { ModelSelector } from './model-selector'; import { useModelSelection } from './_use-model-selection'; export interface ChatInputHandles { @@ -167,9 +166,9 @@ export const ChatInput = forwardRef( }; return ( -
+
{ @@ -190,7 +189,7 @@ export const ChatInput = forwardRef( }} >
- + ( onStopAgent={onStopAgent} isDraggingOver={isDraggingOver} uploadedFiles={uploadedFiles} + + fileInputRef={fileInputRef} + isUploading={isUploading} + sandboxId={sandboxId} + setPendingFiles={setPendingFiles} + setUploadedFiles={setUploadedFiles} + setIsUploading={setIsUploading} + hideAttachments={hideAttachments} + + selectedModel={selectedModel} + onModelChange={handleModelChange} + modelOptions={modelOptions} + currentTier={subscriptionTier} + canAccessModel={canAccessModel} /> - -
-
- {!hideAttachments && ( - - )} - - -
-
@@ -257,4 +244,4 @@ export const ChatInput = forwardRef( }, ); -ChatInput.displayName = 'ChatInput'; +ChatInput.displayName = 'ChatInput'; \ No newline at end of file diff --git a/frontend/src/components/thread/chat-input/file-upload-handler.tsx b/frontend/src/components/thread/chat-input/file-upload-handler.tsx index 8a051576..a3cb3149 100644 --- a/frontend/src/components/thread/chat-input/file-upload-handler.tsx +++ b/frontend/src/components/thread/chat-input/file-upload-handler.tsx @@ -188,8 +188,8 @@ export const FileUploadHandler = forwardRef< type="button" onClick={handleFileUpload} variant="ghost" - size="sm" - className="h-7 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800" + size="default" + className="h-7 rounded-md text-muted-foreground" disabled={ loading || (disabled && !isAgentRunning) || isUploading } @@ -199,7 +199,7 @@ export const FileUploadHandler = forwardRef< ) : ( )} - Attachments + Attachments @@ -220,8 +220,5 @@ export const FileUploadHandler = forwardRef< }, ); -// For easier access from other components FileUploadHandler.displayName = 'FileUploadHandler'; - -// Export the helper functions for use in other components export { handleFiles, handleLocalFiles, uploadFiles }; diff --git a/frontend/src/components/thread/chat-input/message-input.tsx b/frontend/src/components/thread/chat-input/message-input.tsx index a4fff3a8..126932e0 100644 --- a/frontend/src/components/thread/chat-input/message-input.tsx +++ b/frontend/src/components/thread/chat-input/message-input.tsx @@ -1,11 +1,12 @@ -'use client'; - import React, { forwardRef, useEffect } from 'react'; import { Textarea } from '@/components/ui/textarea'; import { Button } from '@/components/ui/button'; import { Square, Loader2, ArrowUp } from 'lucide-react'; import { cn } from '@/lib/utils'; import { UploadedFile } from './chat-input'; +import { FileUploadHandler } from './file-upload-handler'; +import { ModelSelector } from './model-selector'; +import { useModelSelection } from './_use-model-selection'; interface MessageInputProps { value: string; @@ -18,6 +19,20 @@ interface MessageInputProps { onStopAgent?: () => void; isDraggingOver: boolean; uploadedFiles: UploadedFile[]; + + fileInputRef: React.RefObject; + isUploading: boolean; + sandboxId?: string; + setPendingFiles: React.Dispatch>; + setUploadedFiles: React.Dispatch>; + setIsUploading: React.Dispatch>; + hideAttachments?: boolean; + + selectedModel: string; + onModelChange: (model: string) => void; + modelOptions: any[]; + currentTier: string; + canAccessModel: (model: string) => boolean; } export const MessageInput = forwardRef( @@ -33,6 +48,20 @@ export const MessageInput = forwardRef( onStopAgent, isDraggingOver, uploadedFiles, + + fileInputRef, + isUploading, + sandboxId, + setPendingFiles, + setUploadedFiles, + setIsUploading, + hideAttachments = false, + + selectedModel, + onModelChange, + modelOptions, + currentTier, + canAccessModel, }, ref, ) => { @@ -58,6 +87,10 @@ export const MessageInput = forwardRef( return () => window.removeEventListener('resize', adjustHeight); }, [value, ref]); + const { + subscriptionTier, + } = useModelSelection(); + const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); @@ -72,50 +105,81 @@ export const MessageInput = forwardRef( }; return ( -
-