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: dynamic input box width and remove tooltip image option #4315

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
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
42 changes: 18 additions & 24 deletions web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,30 +231,24 @@ const ChatInput = () => {
)}
>
<ul>
<Tooltip
trigger={
<li
className={twMerge(
'text-[hsla(var(--text-secondary)] hover:bg-secondary flex w-full items-center space-x-2 px-4 py-2 hover:bg-[hsla(var(--dropdown-menu-hover-bg))]',
activeAssistant?.model.settings?.vision_model ||
isModelSupportRagAndTools
? 'cursor-pointer'
: 'cursor-not-allowed opacity-50'
)}
onClick={() => {
if (activeAssistant?.model.settings?.vision_model) {
imageInputRef.current?.click()
setShowAttacmentMenus(false)
}
}}
>
<ImageIcon size={16} />
<span className="font-medium">Image</span>
</li>
}
content="This feature only supports multimodal models."
disabled={activeAssistant?.model.settings?.vision_model}
/>
<li
className={twMerge(
'text-[hsla(var(--text-secondary)] hover:bg-secondary flex w-full items-center space-x-2 px-4 py-2 hover:bg-[hsla(var(--dropdown-menu-hover-bg))]',
activeAssistant?.model.settings?.vision_model &&
isModelSupportRagAndTools
? 'cursor-pointer'
: 'cursor-not-allowed opacity-50'
)}
onClick={() => {
if (activeAssistant?.model.settings?.vision_model) {
imageInputRef.current?.click()
setShowAttacmentMenus(false)
}
}}
>
<ImageIcon size={16} />
<span className="font-medium">Image</span>
</li>
<Tooltip
side="bottom"
trigger={
Expand Down
11 changes: 10 additions & 1 deletion web/screens/Thread/ThreadCenterPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import { showSystemMonitorPanelAtom } from '@/helpers/atoms/App.atom'
import { experimentalFeatureEnabledAtom } from '@/helpers/atoms/AppConfig.atom'
import { activeAssistantAtom } from '@/helpers/atoms/Assistant.atom'
import { chatWidthAtom } from '@/helpers/atoms/Setting.atom'
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'

import {
Expand All @@ -38,18 +39,18 @@
} from '@/helpers/atoms/Thread.atom'

const renderError = (code: string) => {
switch (code) {

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

View workflow job for this annotation

GitHub Actions / coverage-check

42 line is not covered with tests
case 'multiple-upload':
return 'Currently, we only support 1 attachment at the same time'

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

View workflow job for this annotation

GitHub Actions / coverage-check

44 line is not covered with tests

case 'retrieval-off':
return 'Turn on Retrieval in Assistant Settings to use this feature'

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

View workflow job for this annotation

GitHub Actions / coverage-check

47 line is not covered with tests

case 'file-invalid-type':
return 'We do not support this file type'

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

View workflow job for this annotation

GitHub Actions / coverage-check

50 line is not covered with tests

default:
return 'Oops, something error, please try again.'

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

View workflow job for this annotation

GitHub Actions / coverage-check

53 line is not covered with tests
}
}

Expand All @@ -59,6 +60,7 @@
const experimentalFeature = useAtomValue(experimentalFeatureEnabledAtom)
const activeThread = useAtomValue(activeThreadAtom)
const activeAssistant = useAtomValue(activeAssistantAtom)
const chatWidth = useAtomValue(chatWidthAtom)
const upload = uploader()
const acceptedFormat: Accept = activeAssistant?.model.settings?.vision_model
? {
Expand All @@ -78,23 +80,23 @@

onDragOver: (e) => {
// Retrieval file drag and drop is experimental feature
if (!experimentalFeature) return
if (

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

View workflow job for this annotation

GitHub Actions / coverage-check

83-84 lines are not covered with tests
e.dataTransfer.items.length === 1 &&
((activeAssistant?.tools && activeAssistant?.tools[0]?.enabled) ||
activeAssistant?.model.settings?.vision_model)
) {
setDragOver(true)
} else if (

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

View workflow job for this annotation

GitHub Actions / coverage-check

89-90 lines are not covered with tests
activeAssistant?.tools &&
!activeAssistant?.tools[0]?.enabled
) {
setDragRejected({ code: 'retrieval-off' })

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

View workflow job for this annotation

GitHub Actions / coverage-check

94 line is not covered with tests
} else {
setDragRejected({ code: 'multiple-upload' })

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

View workflow job for this annotation

GitHub Actions / coverage-check

96 line is not covered with tests
}
},
onDragLeave: () => setDragOver(false),

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

View workflow job for this annotation

GitHub Actions / coverage-check

99 line is not covered with tests
onDrop: async (files, rejectFiles) => {
// Retrieval file drag and drop is experimental feature
if (!experimentalFeature) return
Expand Down Expand Up @@ -235,7 +237,14 @@
{reloadModel && <ModelReload />}

{activeModel && isGeneratingResponse && <GenerateResponse />}
<ChatInput />
<div
className={twMerge(
'mx-auto w-full',
chatWidth === 'compact' && 'max-w-[700px]'
)}
>
<ChatInput />
</div>
</div>
</div>
</CenterPanelContainer>
Expand Down
Loading