Skip to content

Commit 699ec38

Browse files
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.
1 parent 173f096 commit 699ec38

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/web/src/components/dashboard/Dashboard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Link, useNavigate } from "@tanstack/react-router";
22
import { motion } from "framer-motion";
33
import { Boxes, LayoutDashboard, Network, Settings as SettingsIcon } from "lucide-react";
4-
import { useCallback, useMemo, useState } from "react";
4+
import { useCallback, useEffect, useMemo, useState } from "react";
55
import {
66
computeFleetAggregates,
77
DEFAULT_ROW_METRICS,
@@ -29,6 +29,12 @@ export function Dashboard() {
2929
const [serverFilter, setServerFilter] = useState<string>(ALL_SERVERS);
3030
const [metricsById, setMetricsById] = useState<Record<string, FleetRowMetrics>>({});
3131

32+
useEffect(() => {
33+
if (serverFilter !== ALL_SERVERS && !instances.find((i) => i.id === serverFilter)) {
34+
setServerFilter(ALL_SERVERS);
35+
}
36+
}, [instances, serverFilter]);
37+
3238
const onMetrics = useCallback((id: string, m: FleetRowMetrics) => {
3339
setMetricsById((prev) => ({ ...prev, [id]: m }));
3440
}, []);

0 commit comments

Comments
 (0)