Skip to content

Commit

Permalink
update: init
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Dec 18, 2024
1 parent ff982ba commit c54e3f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions ee/tabby-ui/components/chat/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ function ChatPanelRenderer(
setInput={setInput}
isLoading={isLoading}
chatInputRef={chatInputRef}
isInitializing={!initialized}
/>
<FooterText className="hidden sm:block" />
</div>
Expand Down
10 changes: 2 additions & 8 deletions ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -142,7 +141,7 @@ function ChatRenderer(
}: ChatProps,
ref: React.ForwardedRef<ChatRef>
) {
const [initialized, setInitialzed] = React.useState(false)
const [initialized, setInitialized] = React.useState(false)
const [threadId, setThreadId] = React.useState<string | undefined>()
const isOnLoadExecuted = React.useRef(false)
const [qaPairs, setQaPairs] = React.useState(initialMessages ?? [])
Expand Down Expand Up @@ -548,7 +547,7 @@ function ChatRenderer(
}
}

setInitialzed(true)
setInitialized(true)
}

if (!fetchingSources && !initialized) {
Expand Down Expand Up @@ -578,11 +577,6 @@ function ChatRenderer(
)

const chatMaxWidthClass = maxWidth ? `max-w-${maxWidth}` : 'max-w-2xl'
if (!initialized) {
return (
<ListSkeleton className={`${chatMaxWidthClass} mx-auto pt-4 md:pt-10`} />
)
}

return (
<ChatContext.Provider
Expand Down
14 changes: 11 additions & 3 deletions ee/tabby-ui/components/chat/prompt-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ export interface PromptProps
onSubmit: (value: string) => Promise<void>
isLoading: boolean
chatInputRef: React.RefObject<HTMLTextAreaElement>
isInitializing?: boolean
}

export interface PromptFormRef {
focus: () => void
}

function PromptFormRenderer(
{ onSubmit, input, setInput, isLoading, chatInputRef }: PromptProps,
{
onSubmit,
input,
setInput,
isLoading,
chatInputRef,
isInitializing
}: PromptProps,
ref: React.ForwardedRef<PromptFormRef>
) {
const { formRef, onKeyDown } = useEnterSubmit()
Expand Down Expand Up @@ -137,7 +145,7 @@ function PromptFormRenderer(
HTMLFormElement
> = async e => {
e.preventDefault()
if (!input?.trim() || isLoading) {
if (!input?.trim() || isLoading || isInitializing) {
return
}

Expand Down Expand Up @@ -233,7 +241,7 @@ function PromptFormRenderer(
<Button
type="submit"
size="icon"
disabled={isLoading || input === ''}
disabled={isInitializing || isLoading || input === ''}
>
<IconArrowElbow />
<span className="sr-only">Send message</span>
Expand Down

0 comments on commit c54e3f2

Please sign in to comment.