fix(web): reset serverFilter when the selected instance is removed

If the user filters to a specific server and that instance is then deleted
(e.g. from Settings), shownInstances becomes [] — empty table, no message.
A useEffect resets the filter to ALL_SERVERS whenever the selected ID
disappears from the instances list.
This commit is contained in:
Offending Commit
2026-06-03 17:03:10 -05:00
parent 173f096e33
commit 699ec38480

View File

@@ -1,7 +1,7 @@
import { Link, useNavigate } from "@tanstack/react-router"; import { Link, useNavigate } from "@tanstack/react-router";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import { Boxes, LayoutDashboard, Network, Settings as SettingsIcon } from "lucide-react"; import { Boxes, LayoutDashboard, Network, Settings as SettingsIcon } from "lucide-react";
import { useCallback, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { import {
computeFleetAggregates, computeFleetAggregates,
DEFAULT_ROW_METRICS, DEFAULT_ROW_METRICS,
@@ -29,6 +29,12 @@ export function Dashboard() {
const [serverFilter, setServerFilter] = useState<string>(ALL_SERVERS); const [serverFilter, setServerFilter] = useState<string>(ALL_SERVERS);
const [metricsById, setMetricsById] = useState<Record<string, FleetRowMetrics>>({}); const [metricsById, setMetricsById] = useState<Record<string, FleetRowMetrics>>({});
useEffect(() => {
if (serverFilter !== ALL_SERVERS && !instances.find((i) => i.id === serverFilter)) {
setServerFilter(ALL_SERVERS);
}
}, [instances, serverFilter]);
const onMetrics = useCallback((id: string, m: FleetRowMetrics) => { const onMetrics = useCallback((id: string, m: FleetRowMetrics) => {
setMetricsById((prev) => ({ ...prev, [id]: m })); setMetricsById((prev) => ({ ...prev, [id]: m }));
}, []); }, []);