From 2332c4e1d2e71637965aba1493ba9bcf3e0d0655 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 1 Jan 2024 09:11:36 +0700 Subject: [PATCH] feat: change layout thread setting right panel --- web/containers/CardSidebar/index.tsx | 43 +++--- web/containers/Layout/TopBar/index.tsx | 177 +++++++++++++++++++++---- web/screens/Chat/Sidebar/index.tsx | 73 +++++++--- 3 files changed, 228 insertions(+), 65 deletions(-) diff --git a/web/containers/CardSidebar/index.tsx b/web/containers/CardSidebar/index.tsx index e3851214b7..de0a409aee 100644 --- a/web/containers/CardSidebar/index.tsx +++ b/web/containers/CardSidebar/index.tsx @@ -39,34 +39,37 @@ export default function CardSidebar({ return (
- -
setMore(!more)} - > - + {title} +
+
setMore(!more)} + > + +
+
+ {more && (
{ const activeThread = useAtomValue(activeThreadAtom) @@ -20,6 +33,13 @@ const TopBar = () => { const { requestCreateNewThread } = useCreateNewThread() const { assistants } = useGetAssistants() const setShowRightSideBar = useSetAtom(showRightSideBarAtom) + const showing = useAtomValue(showRightSideBarAtom) + const threadStates = useAtomValue(threadStatesAtom) + const [more, setMore] = useState(false) + const [menu, setMenu] = useState(null) + const [toggle, setToggle] = useState(null) + + useClickOutside(() => setMore(false), null, [menu, toggle]) const titleScreen = (viewStateName: MainViewState) => { switch (viewStateName) { @@ -47,15 +67,45 @@ const TopBar = () => { } } + const onReviewInFinderClick = async () => { + if (!activeThread) return + const activeThreadState = threadStates[activeThread.id] + if (!activeThreadState.isFinishInit) { + alert('Thread is not started yet') + return + } + + const userSpace = await getUserSpace() + let filePath = undefined + filePath = await joinPath(['threads', activeThread.id]) + + if (!filePath) return + const fullPath = await joinPath([userSpace, filePath]) + openFileExplorer(fullPath) + } + + const onViewJsonClick = async () => { + if (!activeThread) return + const activeThreadState = threadStates[activeThread.id] + if (!activeThreadState.isFinishInit) { + alert('Thread is not started yet') + return + } + + const userSpace = await getUserSpace() + let filePath = undefined + filePath = await joinPath(['threads', activeThread.id, 'thread.json']) + if (!filePath) return + const fullPath = await joinPath([userSpace, filePath]) + openFileExplorer(fullPath) + } + return (
{mainViewState === MainViewState.Thread && ( -
- )} -
- {mainViewState === MainViewState.Thread ? ( -
-
+
+
+
{ />
- - {titleScreen(mainViewState)} - +
+
+
+ + {titleScreen(mainViewState)} + +
+
+
{activeThread && ( -
setShowRightSideBar((show) => !show)} - > - +
+ {showing && ( +
+ + Threads Settings + +
setMore(!more)} + > + +
+ + {more && ( +
+
{ + onReviewInFinderClick() + setMore(false) + }} + > + + + Show in Finder + +
+
{ + onViewJsonClick() + setMore(false) + }} + > + +
+ + View as JSON + + + Opens thread.json. Changes affect this thread + only. + +
+
+
+ )} +
+ )} +
setShowRightSideBar((show) => !show)} + > + +
)}
- ) : ( -
- - {titleScreen(mainViewState)} - -
- )} - - -
+
+ )} + + {mainViewState !== MainViewState.Thread && ( +
+ + {titleScreen(mainViewState)} + +
+ )} + +
) } diff --git a/web/screens/Chat/Sidebar/index.tsx b/web/screens/Chat/Sidebar/index.tsx index e04f9ff870..7b663a5ee3 100644 --- a/web/screens/Chat/Sidebar/index.tsx +++ b/web/screens/Chat/Sidebar/index.tsx @@ -119,11 +119,44 @@ const Sidebar: React.FC = () => { >
- +
+ + { + if (activeThread) + updateThreadMetadata({ + ...activeThread, + title: e.target.value || '', + }) + }} + /> +
+
+ + + {activeThread?.id || '-'} + +
+
+ + {/* {
- - */} + + {/* { />
- - {experimentalFeatureEnabed && Object.keys(modelSettingParams).length ? ( - -
- -
-
- ) : null} - */} + + {/* {
+ + {experimentalFeatureEnabed && + Object.keys(modelSettingParams).length ? ( + +
+ +
+
+ ) : null}
- + */}
)