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

enhancement: Update app layout with an expanded system monitor #4528

Merged
merged 1 commit into from
Jan 28, 2025
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
26 changes: 23 additions & 3 deletions web/containers/MainViewContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo } from 'react'
import { memo, useEffect, useState } from 'react'

import { motion as m } from 'framer-motion'
import { useAtomValue } from 'jotai'
Expand All @@ -12,10 +12,27 @@ import LocalServerScreen from '@/screens/LocalServer'
import SettingsScreen from '@/screens/Settings'
import ThreadScreen from '@/screens/Thread'

import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
import {
mainViewStateAtom,
showSystemMonitorPanelAtom,
} from '@/helpers/atoms/App.atom'

const MainViewContainer = () => {
const mainViewState = useAtomValue(mainViewStateAtom)
const showSystemMonitorPanel = useAtomValue(showSystemMonitorPanelAtom)
const [height, setHeight] = useState<number>(0)

useEffect(() => {
if (showSystemMonitorPanel) {
const element = document.querySelector('.system-monitor-panel')

if (element) {
setHeight(element.clientHeight) // You can also use offsetHeight if needed
}
} else {
setHeight(0)
}
}, [showSystemMonitorPanel])

let children = null
switch (mainViewState) {
Expand All @@ -37,7 +54,10 @@ const MainViewContainer = () => {
}

return (
<div className={twMerge('relative flex w-[calc(100%-48px)]')}>
<div
className={twMerge('relative flex w-[calc(100%-48px)]')}
style={{ height: `calc(100% - ${height}px)` }}
>
<div className="w-full">
<m.div
key={mainViewState}
Expand Down
25 changes: 1 addition & 24 deletions web/screens/Thread/ThreadCenterPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import ChatInput from './ChatInput'
import RequestDownloadModel from './RequestDownloadModel'

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'
Expand All @@ -39,18 +38,18 @@
} from '@/helpers/atoms/Thread.atom'

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

43 line is not covered with tests

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

46 line is not covered with tests

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

49 line is not covered with tests

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

52 line is not covered with tests
}
}

Expand Down Expand Up @@ -80,23 +79,23 @@

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

82-83 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 89 in web/screens/Thread/ThreadCenterPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

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

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

View workflow job for this annotation

GitHub Actions / coverage-check

98 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 @@ -158,22 +157,6 @@

const isGeneratingResponse = useAtomValue(isGeneratingResponseAtom)

const showSystemMonitorPanel = useAtomValue(showSystemMonitorPanelAtom)

const [height, setHeight] = useState<number>(0)

useEffect(() => {
if (showSystemMonitorPanel) {
const element = document.querySelector('.system-monitor-panel')

if (element) {
setHeight(element.clientHeight) // You can also use offsetHeight if needed
}
} else {
setHeight(0)
}
}, [showSystemMonitorPanel])

return (
<CenterPanelContainer>
<div
Expand Down Expand Up @@ -217,13 +200,7 @@
</div>
</div>
)}
<div
className={twMerge(
'flex h-full w-full flex-col justify-between'
// showSystemMonitorPanel && `h-[calc(100%-${height}px)]`
)}
style={{ height: `calc(100% - ${height}px)` }}
>
<div className={twMerge('flex h-full w-full flex-col justify-between')}>
{activeThread ? (
<div className="flex h-full w-full overflow-x-hidden">
<ChatBody />
Expand Down
Loading