feat: add orphaned app cleanup — auto-filter stale discovered apps, manual dismiss with data purge

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-12 16:19:59 +02:00
parent d161ad38a8
commit 90c82238a0
4 changed files with 149 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useQuery } from '@tanstack/react-query';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { config } from '../../config';
import { useAuthStore } from '../../auth/auth-store';
import { useRefreshInterval } from './use-refresh-interval';
@@ -61,6 +61,27 @@ export function useCatalog(environment?: string) {
});
}
export function useDismissApp() {
const qc = useQueryClient();
return useMutation({
mutationFn: async (applicationId: string) => {
const token = useAuthStore.getState().accessToken;
const res = await fetch(`${config.apiBaseUrl}/catalog/${applicationId}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token}`,
'X-Cameleer-Protocol-Version': '1',
},
});
if (res.status === 409) throw new Error('Cannot dismiss — live agents are still connected');
if (!res.ok) throw new Error(`Failed to dismiss: ${res.status}`);
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['catalog'] });
},
});
}
export function useRouteMetrics(from?: string, to?: string, appId?: string, environment?: string) {
const refetchInterval = useRefreshInterval(30_000);
return useQuery({