From 2d844a2fc34ab213e02d52d2739f63cdc998f08f Mon Sep 17 00:00:00 2001 From: liangfung Date: Wed, 18 Dec 2024 10:03:57 +0700 Subject: [PATCH] update: init --- ee/tabby-ui/components/chat/chat-panel.tsx | 1 + ee/tabby-ui/components/chat/chat.tsx | 10 ++-------- ee/tabby-ui/components/chat/prompt-form.tsx | 14 +++++++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ee/tabby-ui/components/chat/chat-panel.tsx b/ee/tabby-ui/components/chat/chat-panel.tsx index c488e3727cd5..92d5a7746e7e 100644 --- a/ee/tabby-ui/components/chat/chat-panel.tsx +++ b/ee/tabby-ui/components/chat/chat-panel.tsx @@ -323,6 +323,7 @@ function ChatPanelRenderer( setInput={setInput} isLoading={isLoading} chatInputRef={chatInputRef} + isInitializing={!initialized} /> diff --git a/ee/tabby-ui/components/chat/chat.tsx b/ee/tabby-ui/components/chat/chat.tsx index 4da7c9999252..e0939fdfcf42 100644 --- a/ee/tabby-ui/components/chat/chat.tsx +++ b/ee/tabby-ui/components/chat/chat.tsx @@ -38,7 +38,6 @@ import { } from '@/lib/types/chat' import { cn, nanoid } from '@/lib/utils' -import { ListSkeleton } from '../skeleton' import { ChatPanel, ChatPanelRef } from './chat-panel' import { ChatScrollAnchor } from './chat-scroll-anchor' import { EmptyScreen } from './empty-screen' @@ -142,7 +141,7 @@ function ChatRenderer( }: ChatProps, ref: React.ForwardedRef ) { - const [initialized, setInitialzed] = React.useState(false) + const [initialized, setInitialized] = React.useState(false) const [threadId, setThreadId] = React.useState() const isOnLoadExecuted = React.useRef(false) const [qaPairs, setQaPairs] = React.useState(initialMessages ?? []) @@ -548,7 +547,7 @@ function ChatRenderer( } } - setInitialzed(true) + setInitialized(true) } if (!fetchingSources && !initialized) { @@ -578,11 +577,6 @@ function ChatRenderer( ) const chatMaxWidthClass = maxWidth ? `max-w-${maxWidth}` : 'max-w-2xl' - if (!initialized) { - return ( - - ) - } return ( Promise isLoading: boolean chatInputRef: React.RefObject + isInitializing?: boolean } export interface PromptFormRef { @@ -39,7 +40,14 @@ export interface PromptFormRef { } function PromptFormRenderer( - { onSubmit, input, setInput, isLoading, chatInputRef }: PromptProps, + { + onSubmit, + input, + setInput, + isLoading, + chatInputRef, + isInitializing + }: PromptProps, ref: React.ForwardedRef ) { const { formRef, onKeyDown } = useEnterSubmit() @@ -137,7 +145,7 @@ function PromptFormRenderer( HTMLFormElement > = async e => { e.preventDefault() - if (!input?.trim() || isLoading) { + if (!input?.trim() || isLoading || isInitializing) { return } @@ -233,7 +241,7 @@ function PromptFormRenderer(