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: edge case tiny chat input box show randomly #3887

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
)

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

77 line is not covered with tests
)

const refAttachmentMenus = useClickOutside(() => setShowAttacmentMenus(false))
Expand All @@ -82,12 +82,12 @@

useEffect(() => {
if (textareaRef.current) {
textareaRef.current.focus()

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

View workflow job for this annotation

GitHub Actions / coverage-check

85 line is not covered with tests
}
}, [activeThreadId])

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

90 line is not covered with tests
}

const isModelSupportRagAndTools =
Expand All @@ -100,23 +100,23 @@
* @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 105 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

103-105 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 111 in web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

109-111 lines are not covered with tests
}

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

116 line is not covered with tests
return <ImageUploadPreview file={fileUpload[0].file} />
} else {
return <FileUploadPreview />

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

View workflow job for this annotation

GitHub Actions / coverage-check

119 line is not covered with tests
}
}
}
Expand All @@ -125,7 +125,6 @@
<div className="relative p-4 pb-2">
<div className="relative flex w-full flex-col">
{renderPreview(fileUpload)}

<RichTextEditor
className={twMerge(
'relative mb-1 max-h-[400px] resize-none rounded-lg border border-[hsla(var(--app-border))] p-3 pr-20',
Expand All @@ -141,9 +140,9 @@
disabled={stateModel.loading || !activeThread}
/>
<TextArea
className="absolute inset-0 top-14 h-0 w-0"
className="sr-only"
data-testid="txt-input-chat"
onChange={(e) => setCurrentPrompt(e.target.value)}

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

View workflow job for this annotation

GitHub Actions / coverage-check

145 line is not covered with tests
/>
{experimentalFeature && (
<Tooltip
Expand All @@ -152,13 +151,13 @@
theme="icon"
className="absolute left-3 top-2.5"
onClick={(e) => {
if (

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
fileUpload.length > 0 ||
(activeThread?.assistants[0].tools &&
!activeThread?.assistants[0].tools[0]?.enabled &&
!activeThread?.assistants[0].model.settings.vision_model)
) {
e.stopPropagation()

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

View workflow job for this annotation

GitHub Actions / coverage-check

160 line is not covered with tests
} else {
setShowAttacmentMenus(!showAttacmentMenus)
}
Expand Down
Loading