From b10562b1e9974f724e7d73b44602939cb7f57eb4 Mon Sep 17 00:00:00 2001 From: Mike-FreeAI <145850829+Mike-FreeAI@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:30:45 +0100 Subject: [PATCH] Add Workspace wrapper to components Implement mobile support for the application. * **Workspace Component**: Update `Workspace` component to accept `children` prop and render `children` inside the component. * **Layout Component**: Wrap the returned JSX with `Workspace` component and pass `databaseId` and `visibility` props to `Workspace`. * **Sidebar Component**: Wrap the returned JSX with `Workspace` component and pass `databaseId` and `visibility` props to `Workspace`. * **Chat Component**: Wrap the returned JSX with `Workspace` component and pass `databaseId` and `visibility` props to `Workspace`. --- apps/postgres-new/components/chat.tsx | 544 +++++++++++---------- apps/postgres-new/components/layout.tsx | 12 +- apps/postgres-new/components/sidebar.tsx | 5 +- apps/postgres-new/components/workspace.tsx | 7 + 4 files changed, 290 insertions(+), 278 deletions(-) diff --git a/apps/postgres-new/components/chat.tsx b/apps/postgres-new/components/chat.tsx index 65b40f75..99e08bf3 100644 --- a/apps/postgres-new/components/chat.tsx +++ b/apps/postgres-new/components/chat.tsx @@ -24,7 +24,7 @@ import { AiIconAnimation } from './ai-icon-animation' import { useApp } from './app-provider' import ChatMessage from './chat-message' import SignInButton from './sign-in-button' -import { useWorkspace } from './workspace' +import { useWorkspace, Workspace } from './workspace' export function getInitialMessages(tables: TablesData): Message[] { return [ @@ -208,126 +208,181 @@ export default function Chat() { })) return ( -
- {isDraggingOver && ( - - )} - {dropZoneCursor} -
- {isLoadingMessages || isLoadingSchema ? ( -
- - - - - - -
- ) : isConversationStarted ? ( -
- setIsMessageAnimationComplete(false)} - onAnimationComplete={() => setIsMessageAnimationComplete(true)} - initial="show" - animate="show" + +
+ {isDraggingOver && ( + + )} + {dropZoneCursor} +
+ {isLoadingMessages || isLoadingSchema ? ( +
+ + + + + + +
+ ) : isConversationStarted ? ( +
- {messages.map((message, i) => ( - - ))} - - {isLoading && ( - setIsMessageAnimationComplete(false)} + onAnimationComplete={() => setIsMessageAnimationComplete(true)} + initial="show" + animate="show" + > + {messages.map((message, i) => ( + + ))} + + {isLoading && ( + + + + + {lastMessage && + (lastMessage.role === 'user' || + (lastMessage.role === 'assistant' && !lastMessage.content)) && ( + + Working on it... + + )} + + )} + + +
+ ) : ( +
+ {user ? ( + + What would you like to create? + + ) : ( + + +

+ To prevent abuse we ask you to sign in before chatting with AI. +

+

{ + setIsSignInDialogOpen(true) }} - initial="hidden" - animate="show" - exit="hidden" > - - - - {lastMessage && - (lastMessage.role === 'user' || - (lastMessage.role === 'assistant' && !lastMessage.content)) && ( - - Working on it... - - )} - - )} - - -

- ) : ( -
- {user ? ( - + + )} +
+ )} + + {!isSticky && ( + - What would you like to create? - - ) : ( + + + )} + +
+
+ + {!user && !isLoadingUser && isConversationStarted && ( -

+

To prevent abuse we ask you to sign in before chatting with AI.

{ setIsSignInDialogOpen(true) }} @@ -336,183 +391,130 @@ export default function Chat() {

)} -
- )} - - {!isSticky && ( - - - - )} - -
-
- - {!user && !isLoadingUser && isConversationStarted && ( - - -

- To prevent abuse we ask you to sign in before chatting with AI. -

-

{ - setIsSignInDialogOpen(true) - }} + +

+ {/* + * This is a hidden dummy message acting as an animation anchor + * before the real message is added to the chat. + * + * The animation starts in this element's position and moves over to + * the location of the real message after submit. + * + * It works by sharing the same `layoutId` between both message elements + * which framer motion requires to animate between them. + */} + {input && ( + - Why do I need to sign in? -

-
- )} - - - {/* - * This is a hidden dummy message acting as an animation anchor - * before the real message is added to the chat. - * - * The animation starts in this element's position and moves over to - * the location of the real message after submit. - * - * It works by sharing the same `layoutId` between both message elements - * which framer motion requires to animate between them. - */} - {input && ( - - {input} - - )} - -