From 5b10b3c23f7e6258a6fced7ceba3e10a39f24c58 Mon Sep 17 00:00:00 2001 From: Benson Wong Date: Thu, 7 Aug 2025 11:07:03 -0700 Subject: [PATCH] UI Tweaks (#228) * sort model names in UI * add toggle to show model id/name on UI model page --- ui/src/contexts/APIProvider.tsx | 6 ++++++ ui/src/pages/Models.tsx | 31 +++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ui/src/contexts/APIProvider.tsx b/ui/src/contexts/APIProvider.tsx index f528777..5148e89 100644 --- a/ui/src/contexts/APIProvider.tsx +++ b/ui/src/contexts/APIProvider.tsx @@ -83,6 +83,12 @@ export function APIProvider({ children, autoStartAPIEvents = true }: APIProvider case "modelStatus": { const models = JSON.parse(message.data) as Model[]; + + // sort models by name and id + models.sort((a, b) => { + return (a.name + a.id).localeCompare(b.name + b.id); + }); + setModels(models); } break; diff --git a/ui/src/pages/Models.tsx b/ui/src/pages/Models.tsx index f448214..891b781 100644 --- a/ui/src/pages/Models.tsx +++ b/ui/src/pages/Models.tsx @@ -4,7 +4,7 @@ import { LogPanel } from "./LogViewer"; import { usePersistentState } from "../hooks/usePersistentState"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; import { useTheme } from "../contexts/ThemeProvider"; -import { RiEyeFill, RiEyeOffFill, RiStopCircleLine } from "react-icons/ri"; +import { RiEyeFill, RiEyeOffFill, RiStopCircleLine, RiSwapBoxFill } from "react-icons/ri"; export default function ModelsPage() { const { isNarrow } = useTheme(); @@ -40,6 +40,7 @@ function ModelsPanel() { const { models, loadModel, unloadAllModels } = useAPI(); const [isUnloading, setIsUnloading] = useState(false); const [showUnlisted, setShowUnlisted] = usePersistentState("showUnlisted", true); + const [showIdorName, setShowIdorName] = usePersistentState<"id" | "name">("showIdorName", "id"); // true = show ID, false = show name const filteredModels = useMemo(() => { return models.filter((model) => showUnlisted || !model.unlisted); @@ -58,18 +59,28 @@ function ModelsPanel() { } }, [unloadAllModels]); + const toggleIdorName = useCallback(() => { + setShowIdorName((prev) => (prev === "name" ? "id" : "name")); + }, [showIdorName]); + return (

Models

- +
+ + + +
@@ -80,7 +91,7 @@ function ModelsPanel() { - + @@ -90,7 +101,7 @@ function ModelsPanel() {
Name{showIdorName === "id" ? "Model ID" : "Name"} State
- {model.name !== "" ? model.name : model.id} + {showIdorName === "id" ? model.id : model.name !== "" ? model.name : model.id} {model.description !== "" && (