fix(instances): reset stale server/node filter on workspace switch
All checks were successful
Deploy to Production / Trigger production update (push) Successful in 10s

Persisted instances-server-filter/instances-node-filter kept an old id
after switching workspace, emptying the list and showing the raw id in
the Select. Drop the filter to 'all' when the server/node is no longer
present in the active workspace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 03:25:44 +05:00
parent 7117c8adc3
commit 28fa6eb5b4

View File

@@ -304,6 +304,16 @@ export default function InstancesPage() {
localStorage.setItem('instances-column-filters', JSON.stringify(columnFilters));
}, [columnFilters]);
// Drop a stale persisted server filter when its server is not in the active
// workspace anymore (otherwise the list silently empties and the Select shows
// the raw server id instead of a name).
useEffect(() => {
if (serverFilter !== 'all' && servers.length > 0 && !servers.some((s) => String(s.id) === serverFilter)) {
setServerFilter('all');
localStorage.setItem('instances-server-filter', 'all');
}
}, [servers, serverFilter]);
// Filter real VMs
const filteredVMs = useMemo(() => {
if (!vms) return [];
@@ -399,6 +409,15 @@ export default function InstancesPage() {
return [...new Set(source.map((v) => v.node))].sort();
}, [vms, serverFilter]);
// Drop a stale persisted node filter when that node is gone from the active
// workspace / selected server (same failure mode as the server filter above).
useEffect(() => {
if (nodeFilter !== 'all' && vms && vms.length > 0 && !uniqueNodes.includes(nodeFilter)) {
setNodeFilter('all');
localStorage.setItem('instances-node-filter', 'all');
}
}, [uniqueNodes, nodeFilter, vms]);
// Counts (ghosts not counted in tabs)
const counts = useMemo(() => {
if (!vms) return { all: 0, vm: 0, lxc: 0 };