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 (
| 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 !== "" && (
|