Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toolbar overlap chat input #3720

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
)

const isStreamingResponse = Object.values(threadStates).some(
(threadState) => threadState.waitingForResponse

Check warning on line 78 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

78 line is not covered with tests
)

const onPromptChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setCurrentPrompt(e.target.value)

Check warning on line 82 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

82 line is not covered with tests
}

const refAttachmentMenus = useClickOutside(() => setShowAttacmentMenus(false))
Expand All @@ -87,8 +87,8 @@

useEffect(() => {
if (isWaitingToSend && activeThreadId) {
setIsWaitingToSend(false)
sendChatMessage(currentPrompt)

Check warning on line 91 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

90-91 lines are not covered with tests
}
}, [
activeThreadId,
Expand All @@ -106,26 +106,26 @@

useEffect(() => {
if (textareaRef.current?.clientHeight) {
textareaRef.current.style.height = activeSettingInputBox

Check warning on line 109 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

109 line is not covered with tests
? '100px'
: '40px'
textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px'
textareaRef.current.style.overflow =

Check warning on line 113 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

112-113 lines are not covered with tests
textareaRef.current.clientHeight >= 390 ? 'auto' : 'hidden'
}
}, [textareaRef.current?.clientHeight, currentPrompt, activeSettingInputBox])

const onKeyDown = async (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault()
if (messages[messages.length - 1]?.status !== MessageStatus.Pending)
sendChatMessage(currentPrompt)
else onStopInferenceClick()

Check warning on line 123 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

119-123 lines are not covered with tests
}
}

const onStopInferenceClick = async () => {
stopInference()

Check warning on line 128 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

128 line is not covered with tests
}

const isModelSupportRagAndTools =
Expand All @@ -138,20 +138,20 @@
* @param event - The change event object.
*/
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0]
if (!file) return
setFileUpload([{ file: file, type: 'pdf' }])

Check warning on line 143 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

141-143 lines are not covered with tests
}

const handleImageChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0]
if (!file) return
setFileUpload([{ file: file, type: 'image' }])

Check warning on line 149 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

147-149 lines are not covered with tests
}

const renderPreview = (fileUpload: any) => {
if (fileUpload.length > 0) {
if (fileUpload[0].type === 'image') {

Check warning on line 154 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

154 line is not covered with tests
return <ImageUploadPreview file={fileUpload[0].file} />
} else {
return <FileUploadPreview />
Expand Down Expand Up @@ -392,7 +392,7 @@
{activeSettingInputBox && (
<div
className={twMerge(
'absolute bottom-[6px] left-[1px] flex w-[calc(100%-2px)] items-center justify-between rounded-lg bg-[hsla(var(--textarea-bg))] p-3',
'absolute bottom-[6px] left-[1px] flex w-[calc(100%-10px)] items-center justify-between rounded-b-lg bg-[hsla(var(--center-panel-bg))] p-3 pr-0',
!activeThread && 'bg-transparent',
stateModel.loading && 'bg-transparent'
)}
Expand Down
Loading