From 61237f02d6eb2dee8c7e21aba455a62846991790 Mon Sep 17 00:00:00 2001 From: rathi Date: Wed, 11 Dec 2024 15:46:25 -0500 Subject: [PATCH] Ui changes and loading state updates. Fixed routing issues and debugged --- src/components/chat/Message.tsx | 174 ++--- src/components/chat/TypingIndicator.tsx | 23 + .../layout/DashboardLayout/index.tsx | 30 +- src/components/layout/Sidebar/index.tsx | 51 +- src/hooks/useChatRouting.ts | 36 ++ src/hooks/useLatestChat.ts | 31 + src/index.css | 27 + src/lib/chat-service.ts | 2 +- src/pages/dashboard/ask.tsx | 601 ++++++++---------- src/pages/dashboard/history.tsx | 43 +- src/routes/index.tsx | 3 +- 11 files changed, 554 insertions(+), 467 deletions(-) create mode 100644 src/components/chat/TypingIndicator.tsx create mode 100644 src/hooks/useChatRouting.ts create mode 100644 src/hooks/useLatestChat.ts diff --git a/src/components/chat/Message.tsx b/src/components/chat/Message.tsx index ac198f9..b6e8d3c 100644 --- a/src/components/chat/Message.tsx +++ b/src/components/chat/Message.tsx @@ -64,51 +64,59 @@ export const Message: React.FC = ({ message, isLast }) => { }; return ( -
- - +
+ - {isUser ? 'You' : 'AI'} - - + + {isUser ? : } + + -
-
+
( -
-
+                  
+
+ +
+
                   
), code: ({ node, inline, ...props }) => inline ? ( - + ) : ( ), @@ -120,70 +128,66 @@ export const Message: React.FC = ({ message, isLast }) => { {!isUser && usedTools.length > 0 && ( <> - -
-
+ +
+
Used Tools:
{usedTools.map((tool, index) => ( -
+
{tool}
))}
)} -
-
- {!isUser && ( - <> - - - - - - - - )} - - - +
+ {!isUser && ( + <> + + + + + + + + + + + )} +
diff --git a/src/components/chat/TypingIndicator.tsx b/src/components/chat/TypingIndicator.tsx new file mode 100644 index 0000000..d501820 --- /dev/null +++ b/src/components/chat/TypingIndicator.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { cn } from '../../lib/utils'; + +export const TypingIndicator = () => { + return ( +
+
+ {[...Array(3)].map((_, i) => ( +
+ ))} +
+
+ ); +}; diff --git a/src/components/layout/DashboardLayout/index.tsx b/src/components/layout/DashboardLayout/index.tsx index 6e89c63..3cf3294 100644 --- a/src/components/layout/DashboardLayout/index.tsx +++ b/src/components/layout/DashboardLayout/index.tsx @@ -5,15 +5,27 @@ import { Sidebar } from '../Sidebar/index'; const DashboardLayout = () => { return ( -
-
-
- -
-
- -
-
+
+ {/* Fixed header */} +
+
+
+ + {/* Sidebar and main content */} +
+ {/* Fixed sidebar */} +
+ +
+ + {/* Main content area */} +
+
+
+ +
+
+
); diff --git a/src/components/layout/Sidebar/index.tsx b/src/components/layout/Sidebar/index.tsx index 8c34636..3dfe29d 100644 --- a/src/components/layout/Sidebar/index.tsx +++ b/src/components/layout/Sidebar/index.tsx @@ -2,17 +2,18 @@ import React from 'react'; import { Link, useLocation } from 'react-router-dom'; import { Settings, - MessageSquarePlus, + MessageSquare, Upload, History } from 'lucide-react'; import { cn } from '../../../lib/utils'; +import { useLatestChat } from '../../../hooks/useLatestChat'; const sidebarItems = [ { - icon: MessageSquarePlus, - label: 'Ask a Question', - path: '/dashboard/ask' + icon: MessageSquare, + label: 'Chat', + path: '/dashboard/ask?new=true' }, { icon: History, @@ -33,22 +34,48 @@ const sidebarItems = [ const Sidebar = () => { const location = useLocation(); + const { navigateToChat } = useLatestChat(); const isActive = (path: string) => { - if (path === '/dashboard/ask') { + if (path.startsWith('/dashboard/ask')) { return location.pathname.startsWith('/dashboard/ask') || location.pathname === '/dashboard'; } return location.pathname === path; }; return ( -
-
-