Skip to content

Commit

Permalink
enhancement: update app layout with system monitor open (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur authored Jan 28, 2025
1 parent afae57b commit 65c9bb9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
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 { uploader } from '@/utils/file'
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 Down Expand Up @@ -158,22 +157,6 @@ const ThreadCenterPanel = () => {

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 @@ const ThreadCenterPanel = () => {
</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

0 comments on commit 65c9bb9

Please sign in to comment.