From 935dcf141ab06851ceb203a3f166a9e3f7b1b184 Mon Sep 17 00:00:00 2001 From: Mohit Davar Date: Wed, 7 Jan 2026 21:38:52 +0530 Subject: [PATCH 1/2] Copy Button --- community-chatbot/.gitignore | 1 + .../components/agent/Mode/Chat/InputBox.tsx | 6 +-- .../agent/Mode/Chat/Panel/ChatAvatar.tsx | 27 ------------ .../agent/Mode/Chat/Panel/CopyButton.tsx | 41 +++++++++++++++++++ .../agent/Mode/Chat/Panel/MessageList.tsx | 28 ++++++++----- 5 files changed, 62 insertions(+), 41 deletions(-) delete mode 100644 community-chatbot/components/agent/Mode/Chat/Panel/ChatAvatar.tsx create mode 100644 community-chatbot/components/agent/Mode/Chat/Panel/CopyButton.tsx diff --git a/community-chatbot/.gitignore b/community-chatbot/.gitignore index f398c97d..e7fbc9c1 100644 --- a/community-chatbot/.gitignore +++ b/community-chatbot/.gitignore @@ -31,3 +31,4 @@ next-env.d.ts __pycache__/ *.sql *.py +Jira/ \ No newline at end of file diff --git a/community-chatbot/components/agent/Mode/Chat/InputBox.tsx b/community-chatbot/components/agent/Mode/Chat/InputBox.tsx index 774c9add..44954df6 100644 --- a/community-chatbot/components/agent/Mode/Chat/InputBox.tsx +++ b/community-chatbot/components/agent/Mode/Chat/InputBox.tsx @@ -1,7 +1,7 @@ import { useSendMessage } from '@/hooks/agent/Mode/Chat/useSendMessage'; -import { MessageInput } from './InputBox/MessageInput'; -import { SubmitButton } from './InputBox/SubmitButton'; +import { MessageInput } from '@/components/agent/Mode/Chat/InputBox/MessageInput'; +import { SubmitButton } from '@/components/agent/Mode/Chat/InputBox/SubmitButton'; export function InputBox() { const { handleSendMessage } = useSendMessage(); @@ -20,4 +20,4 @@ export function InputBox() { ); -} \ No newline at end of file +} diff --git a/community-chatbot/components/agent/Mode/Chat/Panel/ChatAvatar.tsx b/community-chatbot/components/agent/Mode/Chat/Panel/ChatAvatar.tsx deleted file mode 100644 index 5f0ce12d..00000000 --- a/community-chatbot/components/agent/Mode/Chat/Panel/ChatAvatar.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Bot, User } from 'lucide-react'; - -import { Avatar, AvatarFallback } from '@/components/ui/avatar'; - -interface ChatAvatarProps { - role: "user" | "assistant" -} - -export function ChatAvatar({ role }: ChatAvatarProps) { - if (role === "user") { - return ( - - - - - - ) - } else { - return ( - - - - - - ) - } -} diff --git a/community-chatbot/components/agent/Mode/Chat/Panel/CopyButton.tsx b/community-chatbot/components/agent/Mode/Chat/Panel/CopyButton.tsx new file mode 100644 index 00000000..d67ae642 --- /dev/null +++ b/community-chatbot/components/agent/Mode/Chat/Panel/CopyButton.tsx @@ -0,0 +1,41 @@ +'use client'; + +import { useState } from 'react'; +import { Check, Copy } from 'lucide-react'; + +import { Button } from '@/components/ui/button'; +import { cn } from '@/lib/utils'; + +interface CopyButtonProps { + textToCopy: string; + className?: string; +} + +export function CopyButton({ textToCopy, className }: CopyButtonProps) { + const [isCopied, setIsCopied] = useState(false); + + const handleCopy = async () => { + try { + await navigator.clipboard.writeText(textToCopy); + setIsCopied(true); + setTimeout(() => setIsCopied(false), 2000); // Reset after 2 seconds + } catch (err) { + console.error('Failed to copy text: ', err); + } + }; + + return ( + + ); +} \ No newline at end of file diff --git a/community-chatbot/components/agent/Mode/Chat/Panel/MessageList.tsx b/community-chatbot/components/agent/Mode/Chat/Panel/MessageList.tsx index 911119b1..ccf88edc 100644 --- a/community-chatbot/components/agent/Mode/Chat/Panel/MessageList.tsx +++ b/community-chatbot/components/agent/Mode/Chat/Panel/MessageList.tsx @@ -1,23 +1,26 @@ import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; -import { ChatAvatar } from '@/components/agent/Mode/Chat/Panel/ChatAvatar'; import { Message } from '@/types/chat/types'; +import { CopyButton } from '@/components/agent/Mode/Chat/Panel/CopyButton'; interface MessageListProps { - messages:Message[] + messages: Message[]; } export function MessageList({ messages }: MessageListProps) { return ( - <> +
{messages.map((message) => ( -
- {message.role === "assistant" && } +
@@ -26,9 +29,12 @@ export function MessageList({ messages }: MessageListProps) {
- {message.role === "user" && } +
))} - +
); -} +} \ No newline at end of file From 7127a2d0e1edcee02e94285d451edcff0c38dc7a Mon Sep 17 00:00:00 2001 From: Mohit Davar Date: Wed, 7 Jan 2026 22:32:45 +0530 Subject: [PATCH 2/2] Implement auto-resizing textarea for input --- community-chatbot/app/globals.css | 41 ++++++++++++ .../components/agent/Mode/Chat/InputBox.tsx | 11 ++-- .../agent/Mode/Chat/InputBox/MessageInput.tsx | 22 +++++-- .../agent/Mode/Chat/InputBox/SubmitButton.tsx | 2 +- community-chatbot/package.json | 1 + community-chatbot/pnpm-lock.yaml | 64 +++++++++++++++++++ 6 files changed, 132 insertions(+), 9 deletions(-) diff --git a/community-chatbot/app/globals.css b/community-chatbot/app/globals.css index ac684423..86d0524e 100644 --- a/community-chatbot/app/globals.css +++ b/community-chatbot/app/globals.css @@ -92,3 +92,44 @@ body { @apply bg-background text-foreground; } } + +@layer utilities { + + /* Minimal aesthetic scrollbar */ + .scrollbar-aesthetic { + overflow-y: auto; + scrollbar-width: thin; + scrollbar-color: rgba(0, 0, 0, 0.8) transparent; + } + + /* Chrome / Edge / Safari */ + .scrollbar-aesthetic::-webkit-scrollbar { + width: 6px; + } + + .scrollbar-aesthetic::-webkit-scrollbar-track { + background: transparent; + } + + .scrollbar-aesthetic::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, 0.5); + border-radius: 9999px; + } + + .scrollbar-aesthetic::-webkit-scrollbar-thumb:hover { + background: rgba(0, 0, 0, 1); + } + + /* Dark mode */ + .dark .scrollbar-aesthetic { + scrollbar-color: rgba(255, 255, 255, 0.3) transparent; + } + + .dark .scrollbar-aesthetic::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.3); + } + + .dark .scrollbar-aesthetic::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.5); + } +} \ No newline at end of file diff --git a/community-chatbot/components/agent/Mode/Chat/InputBox.tsx b/community-chatbot/components/agent/Mode/Chat/InputBox.tsx index 44954df6..9a34ad07 100644 --- a/community-chatbot/components/agent/Mode/Chat/InputBox.tsx +++ b/community-chatbot/components/agent/Mode/Chat/InputBox.tsx @@ -1,8 +1,11 @@ +import { + MessageInput, +} from '@/components/agent/Mode/Chat/InputBox/MessageInput'; +import { + SubmitButton, +} from '@/components/agent/Mode/Chat/InputBox/SubmitButton'; import { useSendMessage } from '@/hooks/agent/Mode/Chat/useSendMessage'; -import { MessageInput } from '@/components/agent/Mode/Chat/InputBox/MessageInput'; -import { SubmitButton } from '@/components/agent/Mode/Chat/InputBox/SubmitButton'; - export function InputBox() { const { handleSendMessage } = useSendMessage(); const handleSubmit = async (event?: React.FormEvent) => { @@ -13,7 +16,7 @@ export function InputBox() { return (
-
+ diff --git a/community-chatbot/components/agent/Mode/Chat/InputBox/MessageInput.tsx b/community-chatbot/components/agent/Mode/Chat/InputBox/MessageInput.tsx index e10a0de9..3f74d580 100644 --- a/community-chatbot/components/agent/Mode/Chat/InputBox/MessageInput.tsx +++ b/community-chatbot/components/agent/Mode/Chat/InputBox/MessageInput.tsx @@ -1,28 +1,42 @@ import { usePathname } from 'next/navigation'; +import Textarea from 'react-textarea-autosize'; -import { Input } from '@/components/ui/input'; +import { useSendMessage } from '@/hooks/agent/Mode/Chat/useSendMessage'; import { integrationModes } from '@/lib/constants/chat'; import { useAgentStore } from '@/lib/store/agent/agentStore'; export function MessageInput() { const { input, setInput, status } = useAgentStore(); + const { handleSendMessage } = useSendMessage(); const pathname = usePathname(); const currentMode = pathname.split('/')[1]; const name = integrationModes.find((m) => m.id === currentMode)?.name; - const handleInputChange = (e: React.ChangeEvent) => { + const handleInputChange = (e: React.ChangeEvent) => { setInput(e.target.value); }; + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + if (input.trim()) { + handleSendMessage(); + } + } + }; + return ( -
- +