From 65c9bb9fe17e2a6ad23a4a9c4fe7b64041840def Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Tue, 28 Jan 2025 12:33:03 +0700 Subject: [PATCH] enhancement: update app layout with system monitor open (#4528) --- web/containers/MainViewContainer/index.tsx | 26 ++++++++++++++++--- .../Thread/ThreadCenterPanel/index.tsx | 25 +----------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/web/containers/MainViewContainer/index.tsx b/web/containers/MainViewContainer/index.tsx index 811f19c6e..6417ec63a 100644 --- a/web/containers/MainViewContainer/index.tsx +++ b/web/containers/MainViewContainer/index.tsx @@ -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' @@ -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(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) { @@ -37,7 +54,10 @@ const MainViewContainer = () => { } return ( -
+
{ const isGeneratingResponse = useAtomValue(isGeneratingResponseAtom) - const showSystemMonitorPanel = useAtomValue(showSystemMonitorPanelAtom) - - const [height, setHeight] = useState(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 (
{
)} -
+
{activeThread ? (