From 69ff85f66aaee0a7b3a2a82a9a2e0d4d0ce3f607 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 22 Jan 2024 18:49:44 +0700 Subject: [PATCH] feat: improvement ux for local api server --- web/containers/DropdownListSidebar/index.tsx | 6 +- web/containers/Layout/TopBar/index.tsx | 53 ++--- web/screens/LocalServer/index.tsx | 213 ++++++++++--------- web/screens/Settings/Models/Row.tsx | 12 +- 4 files changed, 160 insertions(+), 124 deletions(-) diff --git a/web/containers/DropdownListSidebar/index.tsx b/web/containers/DropdownListSidebar/index.tsx index a85986adf..fdc39063a 100644 --- a/web/containers/DropdownListSidebar/index.tsx +++ b/web/containers/DropdownListSidebar/index.tsx @@ -162,7 +162,11 @@ export default function DropdownListSidebar() { stateModel.loading && 'pointer-events-none bg-blue-200 text-blue-600' )} > - {stateModel.loading && ( diff --git a/web/containers/Layout/TopBar/index.tsx b/web/containers/Layout/TopBar/index.tsx index ae3706f07..ac05e4e1a 100644 --- a/web/containers/Layout/TopBar/index.tsx +++ b/web/containers/Layout/TopBar/index.tsx @@ -49,6 +49,9 @@ const TopBar = () => { case MainViewState.Thread: return activeThread ? activeThread?.title : 'New Thread' + case MainViewState.LocalServer: + return 'Local API Server' + default: return MainViewState[viewStateName]?.replace(/([A-Z])/g, ' $1').trim() } @@ -78,34 +81,36 @@ const TopBar = () => { ) : (
-
-
-
setShowLeftSideBar((show) => !show)} - > - -
-
- + {mainViewState == MainViewState.Thread && ( +
+
+
setShowLeftSideBar((show) => !show)} + > + +
+
+ +
-
+ )}
diff --git a/web/screens/LocalServer/index.tsx b/web/screens/LocalServer/index.tsx index 6f6261f78..83b5989af 100644 --- a/web/screens/LocalServer/index.tsx +++ b/web/screens/LocalServer/index.tsx @@ -2,6 +2,8 @@ import React, { useEffect, useState } from 'react' +import ScrollToBottom from 'react-scroll-to-bottom' + import { Button, Switch, @@ -99,7 +101,7 @@ const LocalServerScreen = () => {
-
-
- + + +
+
+

+ Server Options +

+
+ - setPort(e.target.value)} - maxLength={4} - disabled={serverEnabled} - /> -
-
- -
- setIsCorsEnabled(e)} - name="cors" - disabled={serverEnabled} - /> -
-
-
-
+
+ +
+ setIsCorsEnabled(e)} + name="cors" + disabled={serverEnabled} /> - - - - - Verbose Server Logs provide extensive details about server - activities. Enable to capture thorough records, aiding in - troubleshooting and monitoring server performance - effectively. - - - - - - -
- setIsVerboseEnabled(e)} - name="verbose" - disabled={serverEnabled} - /> +
+
+
+ +
+ setIsVerboseEnabled(e)} + name="verbose" + disabled={serverEnabled} + /> +
+
-
-
+
+ + {serverEnabled && ( + + + Settings cannot be modified while the server is running + + + + )} + +
{/* Middle Bar */} -
+

Server Logs

@@ -279,8 +300,8 @@ const LocalServerScreen = () => {
- You cannot chat with your assistant while the server is - running. + Once you start the server, you cannot chat with your + assistant.
+ {/* Right bar */}
{ setTimeout(async () => { - await stopModel() - deleteModel(props.data) + if (serverEnabled) { + await stopModel() + deleteModel(props.data) + } }, 500) setMore(false) }}