diff --git a/internal/server/apigroup.go b/internal/server/apigroup.go index 186a6148..7ca43922 100644 --- a/internal/server/apigroup.go +++ b/internal/server/apigroup.go @@ -105,7 +105,9 @@ func (s *Server) handleAPIMetrics(w http.ResponseWriter, r *http.Request) { // filtered to samples after the ?after= timestamp. func (s *Server) handleAPIPerformance(w http.ResponseWriter, r *http.Request) { if s.perf == nil { - shared.SendResponse(w, r, http.StatusServiceUnavailable, "performance monitor not available") + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusServiceUnavailable) + json.NewEncoder(w).Encode(map[string]bool{"enabled": false}) return } @@ -136,6 +138,7 @@ func (s *Server) handleAPIPerformance(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]any{ + "enabled": true, "sys_stats": sysStats, "gpu_stats": gpuStats, }) diff --git a/ui-svelte/src/App.svelte b/ui-svelte/src/App.svelte index b251258a..df2dc1a0 100644 --- a/ui-svelte/src/App.svelte +++ b/ui-svelte/src/App.svelte @@ -8,7 +8,7 @@ import Performance from "./routes/Performance.svelte"; import Playground from "./routes/Playground.svelte"; import PlaygroundStub from "./routes/PlaygroundStub.svelte"; - import { enableAPIEvents } from "./stores/api"; + import { enableAPIEvents, checkPerformanceEnabled } from "./stores/api"; import { initScreenWidth, initSystemThemeListener, isDarkMode, appTitle, connectionState } from "./stores/theme"; import { currentRoute } from "./stores/route"; @@ -39,6 +39,7 @@ const cleanupScreenWidth = initScreenWidth(); const cleanupSystemTheme = initSystemThemeListener(); enableAPIEvents(true); + checkPerformanceEnabled(); return () => { cleanupScreenWidth(); diff --git a/ui-svelte/src/components/Header.svelte b/ui-svelte/src/components/Header.svelte index 10665e8e..00a76b4d 100644 --- a/ui-svelte/src/components/Header.svelte +++ b/ui-svelte/src/components/Header.svelte @@ -3,6 +3,7 @@ import { screenWidth, toggleTheme, themeMode, appTitle, isNarrow } from "../stores/theme"; import { currentRoute } from "../stores/route"; import { playgroundActivity } from "../stores/playgroundActivity"; + import { performanceEnabled } from "../stores/api"; import ConnectionStatus from "./ConnectionStatus.svelte"; function handleTitleChange(newTitle: string): void { @@ -84,16 +85,18 @@ > Logs - - Performance - + {#if $performanceEnabled} + + Performance + + {/if}